Fixes casting checks

This commit is contained in:
Kamron Batman 2018-08-19 01:38:55 +08:00
parent 7ea00fbf4f
commit 03dd5f1926
431 changed files with 5616 additions and 6250 deletions

View file

@ -84,7 +84,7 @@ namespace Server.Ethics
public static void Initialize()
{
if( Enabled )
if ( Enabled )
EventSink.Speech += new SpeechEventHandler( EventSink_Speech );
}
@ -134,7 +134,7 @@ namespace Server.Ethics
}
else
{
if ( e.Mobile is PlayerMobile && ( e.Mobile as PlayerMobile ).DuelContext != null )
if ( e.Mobile is PlayerMobile mobile && mobile.DuelContext != null )
return;
Ethic ethic = pl.Ethic;
@ -188,15 +188,13 @@ namespace Server.Ethics
if ( pl != null )
return pl.Ethic;
if ( inherit && mob is BaseCreature )
if ( inherit && mob is BaseCreature bc )
{
BaseCreature bc = (BaseCreature) mob;
if ( bc.Controlled )
return Find( bc.ControlMaster, false );
else if ( bc.Summoned )
if ( bc.Summoned )
return Find( bc.SummonMaster, false );
else if ( allegiance )
if ( allegiance )
return bc.EthicAllegiance;
}
@ -252,4 +250,4 @@ namespace Server.Ethics
Evil
};
}
}
}

View file

@ -23,13 +23,11 @@ namespace Server.Ethics
if ( pm == null )
{
if ( inherit && mob is BaseCreature )
if ( inherit && mob is BaseCreature bc )
{
BaseCreature bc = mob as BaseCreature;
if ( bc != null && bc.Controlled )
if ( bc.Controlled )
pm = bc.ControlMaster as PlayerMobile;
else if ( bc != null && bc.Summoned )
else if ( bc.Summoned )
pm = bc.SummonMaster as PlayerMobile;
}
@ -114,16 +112,16 @@ namespace Server.Ethics
public void Attach()
{
if ( m_Mobile is PlayerMobile )
( m_Mobile as PlayerMobile ).EthicPlayer = this;
if ( m_Mobile is PlayerMobile mobile )
mobile.EthicPlayer = this;
m_Ethic.Players.Add( this );
}
public void Detach()
{
if ( m_Mobile is PlayerMobile )
( m_Mobile as PlayerMobile ).EthicPlayer = null;
if ( m_Mobile is PlayerMobile mobile )
mobile.EthicPlayer = null;
m_Ethic.Players.Remove( this );
}

View file

@ -27,9 +27,7 @@ namespace Server.Ethics.Evil
{
Player from = state as Player;
IPoint3D p = obj as IPoint3D;
if ( p == null )
if ( !(obj is IPoint3D p) )
return;
if ( !CheckInvoke( from ) )

View file

@ -25,11 +25,10 @@ namespace Server.Ethics.Evil
private void Power_OnTarget( Mobile fromMobile, object obj, object state )
{
Player from = state as Player;
if (!(state is Player from))
return;
Item item = obj as Item;
if ( item == null )
if ( !(obj is Item item) )
{
from.Mobile.LocalOverheadMessage( Server.Network.MessageType.Regular, 0x3B2, false, "You may not imbue that." );
return;

View file

@ -25,11 +25,10 @@ namespace Server.Ethics.Hero
private void Power_OnTarget( Mobile fromMobile, object obj, object state )
{
Player from = state as Player;
if (!(state is Player from))
return;
IPoint3D p = obj as IPoint3D;
if ( p == null )
if ( !(obj is IPoint3D p) )
return;
if ( !CheckInvoke( from ) )

View file

@ -25,11 +25,10 @@ namespace Server.Ethics.Hero
private void Power_OnTarget( Mobile fromMobile, object obj, object state )
{
Player from = state as Player;
if (!(state is Player from))
return;
Item item = obj as Item;
if ( item == null )
if ( !(obj is Item item) )
{
from.Mobile.LocalOverheadMessage( Server.Network.MessageType.Regular, 0x3B2, false, "You may not imbue that." );
return;