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

@ -114,8 +114,7 @@ namespace Server.Mobiles
this.PlaySound( 0xEE );
defender.LocalOverheadMessage( MessageType.Regular, 0x3B2, false, "You have been stunned by a colossal blow!" );
BaseWeapon weapon = this.Weapon as BaseWeapon;
if ( weapon != null )
if ( this.Weapon is BaseWeapon weapon )
weapon.OnHit( this, defender );
if ( defender.Alive )
@ -128,9 +127,7 @@ namespace Server.Mobiles
private void Recover_Callback( object state )
{
Mobile defender = state as Mobile;
if ( defender != null )
if ( state is Mobile defender )
{
defender.Frozen = false;
defender.Combatant = null;

View file

@ -60,9 +60,8 @@ namespace Server.Mobiles
public void AddArcane( Item item )
{
if ( item is IArcaneEquip )
if ( item is IArcaneEquip eq )
{
IArcaneEquip eq = (IArcaneEquip)item;
eq.CurArcaneCharges = eq.MaxArcaneCharges = 20;
}

View file

@ -94,8 +94,8 @@ namespace Server.Mobiles
aggressor.PlaySound( 0x307 );
aggressor.SendLocalizedMessage( 1040008 ); // Your skin is scorched as the tribal paint burns away!
if ( aggressor is PlayerMobile )
((PlayerMobile)aggressor).SavagePaintExpiration = TimeSpan.Zero;
if ( aggressor is PlayerMobile mobile )
mobile.SavagePaintExpiration = TimeSpan.Zero;
}
}

View file

@ -64,7 +64,7 @@ namespace Server.Mobiles
if ( m == this || !CanBeHarmful( m ) )
continue;
if ( m is BaseCreature && (((BaseCreature)m).Controlled || ((BaseCreature)m).Summoned || ((BaseCreature)m).Team != this.Team) )
if ( m is BaseCreature creature && (creature.Controlled || creature.Summoned || creature.Team != this.Team) )
list.Add( m );
else if ( m.Player )
list.Add( m );

View file

@ -112,8 +112,7 @@ namespace Server.Mobiles
this.PlaySound( 0xEE );
defender.LocalOverheadMessage( MessageType.Regular, 0x3B2, false, "You have been stunned by a colossal blow!" );
BaseWeapon weapon = this.Weapon as BaseWeapon;
if ( weapon != null )
if ( this.Weapon is BaseWeapon weapon )
weapon.OnHit( this, defender );
if ( defender.Alive )
@ -126,9 +125,7 @@ namespace Server.Mobiles
private void Recover_Callback( object state )
{
Mobile defender = state as Mobile;
if ( defender != null )
if ( state is Mobile defender )
{
defender.Frozen = false;
defender.Combatant = null;

View file

@ -87,9 +87,7 @@ namespace Server.Mobiles
public override bool IsEnemy( Mobile m )
{
PlayerMobile player = m as PlayerMobile;
if ( player != null && Map == Map.Trammel && X >= 5199 && X <= 5271 && Y >= 1812 && Y <= 1865 ) // Schmendrick's cave
if ( m is PlayerMobile player && Map == Map.Trammel && X >= 5199 && X <= 5271 && Y >= 1812 && Y <= 1865 ) // Schmendrick's cave
{
QuestSystem qs = player.Quest;

View file

@ -88,8 +88,8 @@ namespace Server.Mobiles
aggressor.PlaySound( 0x307 );
aggressor.SendLocalizedMessage( 1040008 ); // Your skin is scorched as the tribal paint burns away!
if ( aggressor is PlayerMobile )
((PlayerMobile)aggressor).SavagePaintExpiration = TimeSpan.Zero;
if ( aggressor is PlayerMobile mobile )
mobile.SavagePaintExpiration = TimeSpan.Zero;
}
}

View file

@ -71,8 +71,8 @@ namespace Server.Mobiles
if ( mount != null )
mount.Rider = null;
if ( mount is Mobile )
((Mobile)mount).Delete();
if ( mount is Mobile mobile )
mobile.Delete();
return base.OnBeforeDeath();
}
@ -98,8 +98,8 @@ namespace Server.Mobiles
aggressor.PlaySound( 0x307 );
aggressor.SendLocalizedMessage( 1040008 ); // Your skin is scorched as the tribal paint burns away!
if ( aggressor is PlayerMobile )
((PlayerMobile)aggressor).SavagePaintExpiration = TimeSpan.Zero;
if ( aggressor is PlayerMobile mobile )
mobile.SavagePaintExpiration = TimeSpan.Zero;
}
}