More casting fixes

This commit is contained in:
Kamron Batman 2018-09-11 18:59:11 -07:00
parent f211efc3bd
commit 20a80ea2f3
40 changed files with 125 additions and 211 deletions

View file

@ -172,8 +172,8 @@ namespace Server.Mobiles
if ( mount != null )
{
if ( mount is SwampDragon )
((SwampDragon)mount).HasBarding = false;
if ( mount is SwampDragon dragon )
dragon.HasBarding = false;
mount.Rider = null;
}

View file

@ -111,9 +111,9 @@ namespace Server.Mobiles
foreach ( Mobile m in this.GetMobilesInRange( 8 ) )
{
if ( m is JukaLord && IsFriend( m ) && m.Combatant != null && CanBeBeneficial( m ) && m.CanBeginAction( typeof( JukaMage ) ) && InLOS( m ) )
if ( m is JukaLord lord && IsFriend( lord ) && lord.Combatant != null && CanBeBeneficial( lord ) && lord.CanBeginAction( typeof( JukaMage ) ) && InLOS( lord ) )
{
toBuff = (JukaLord)m;
toBuff = lord;
break;
}
}

View file

@ -239,12 +239,7 @@ namespace Server.Mobiles
else if ( !Combat( SummonMaster ))
{
BaseCreature bc = null;
if ( Combatant is BaseCreature )
{
bc = (BaseCreature)Combatant;
}
if ( Combatant.Player || ( bc != null && ( bc.Controlled || bc.SummonMaster != null )))
if ( Combatant.Player || ( Combatant is BaseCreature bc && ( bc.Controlled || bc.SummonMaster != null )))
{
SummonMaster.Combatant = Combatant;
}
@ -258,14 +253,9 @@ namespace Server.Mobiles
private bool Combat( Mobile mobile )
{
Mobile combatant = mobile.Combatant;
if ( combatant == null || combatant.Deleted )
{
if ( combatant == null || combatant.Deleted || combatant.IsDeadBondedPet || !combatant.Alive )
return false;
}
else if ( combatant.IsDeadBondedPet || !combatant.Alive )
{
return false;
}
return true;
}

View file

@ -89,10 +89,8 @@ namespace Server.Mobiles
{
m_NextAbilityTime = DateTime.UtcNow + TimeSpan.FromSeconds( Utility.RandomMinMax( 20, 30 ) );
if ( combatant is BaseCreature )
if ( combatant is BaseCreature bc )
{
BaseCreature bc = (BaseCreature)combatant;
if ( bc.Controlled && bc.ControlMaster != null && !bc.ControlMaster.Deleted && bc.ControlMaster.Alive )
{
if ( bc.ControlMaster.Map == this.Map && bc.ControlMaster.InRange( this, 12 ) && !UnderEffect( bc.ControlMaster ) )
@ -109,8 +107,6 @@ namespace Server.Mobiles
new int[]{-4,-6}, new int[]{4,-6}, new int[]{0,-8}, new int[]{-5,5}, new int[]{5,5}
};
BaseCreature rabid;
for( int i=0; i<5; i++ )
{
int x = combatant.X + coord[i][0];
@ -121,6 +117,7 @@ namespace Server.Mobiles
if ( !combatant.Map.CanSpawnMobile( loc ) )
continue;
BaseCreature rabid;
switch ( i )
{
case 0: rabid = new EnragedRabbit( this ); break;
@ -155,9 +152,7 @@ namespace Server.Mobiles
public static void StopEffect( Mobile m, bool message )
{
Timer t = (Timer)m_Table[m];
if ( t != null )
if ( m_Table[m] is Timer t )
{
if ( message )
m.PublicOverheadMessage( Network.MessageType.Emote, m.SpeechHue, true, "* The open flame begins to scatter the swarm of insects *" );
@ -180,9 +175,7 @@ namespace Server.Mobiles
}
else
{
Torch torch = m.FindItemOnLayer( Layer.TwoHanded ) as Torch;
if ( torch != null && torch.Burning )
if ( m.FindItemOnLayer( Layer.TwoHanded ) is Torch torch && torch.Burning )
{
StopEffect( m, true );
}