More cast conversion fixes

This commit is contained in:
Kamron Batman 2018-09-06 18:07:42 -07:00
parent 3f45bd57b9
commit aba9452161
46 changed files with 359 additions and 506 deletions

View file

@ -41,9 +41,7 @@ namespace Server.Items
return;
}
ThrowTarget targ = from.Target as ThrowTarget;
if ( targ != null && targ.Potion == this )
if ( from.Target is ThrowTarget targ && targ.Potion == this )
return;
from.RevealingAction();
@ -87,9 +85,7 @@ namespace Server.Items
// Check if any other players are using this potion
for ( int i = 0; i < m_Users.Count; i ++ )
{
ThrowTarget targ = m_Users[ i ].Target as ThrowTarget;
if ( targ != null && targ.Potion == this )
if ( m_Users[ i ].Target is ThrowTarget targ && targ.Potion == this )
Target.Cancel( from );
}
@ -102,10 +98,8 @@ namespace Server.Items
foreach ( Mobile mobile in map.GetMobilesInRange( loc, Radius ) )
{
if ( mobile is BaseCreature )
if ( mobile is BaseCreature mon )
{
BaseCreature mon = (BaseCreature) mobile;
if ( mon.Controlled || mon.Summoned )
continue;
@ -134,9 +128,7 @@ namespace Server.Items
public static void AddDelay( Mobile m )
{
Timer timer = m_Delay[ m ] as Timer;
if ( timer != null )
if ( m_Delay[ m ] is Timer timer )
timer.Stop();
m_Delay[ m ] = Timer.DelayCall( TimeSpan.FromSeconds( 60 ), new TimerStateCallback( EndDelay_Callback ), m );
@ -144,9 +136,7 @@ namespace Server.Items
public static int GetDelay( Mobile m )
{
Timer timer = m_Delay[ m ] as Timer;
if ( timer != null && timer.Next > DateTime.UtcNow )
if ( m_Delay[ m ] is Timer timer && timer.Next > DateTime.UtcNow )
return (int) (timer.Next - DateTime.UtcNow).TotalSeconds;
return 0;
@ -154,15 +144,13 @@ namespace Server.Items
private static void EndDelay_Callback( object obj )
{
if ( obj is Mobile )
EndDelay( (Mobile) obj );
if ( obj is Mobile mobile )
EndDelay( mobile );
}
public static void EndDelay( Mobile m )
{
Timer timer = m_Delay[ m ] as Timer;
if ( timer != null )
if ( m_Delay[ m ] is Timer timer )
{
timer.Stop();
m_Delay.Remove( m );
@ -189,13 +177,11 @@ namespace Server.Items
if ( m_Potion.Deleted || m_Potion.Map == Map.Internal )
return;
IPoint3D p = targeted as IPoint3D;
if ( p == null || from.Map == null )
if ( !(targeted is IPoint3D p) || from.Map == null )
return;
// Add delay
BaseConfusionBlastPotion.AddDelay( from );
AddDelay( from );
SpellHelper.GetSurfaceTop( ref p );
@ -203,8 +189,8 @@ namespace Server.Items
IEntity to;
if ( p is Mobile )
to = (Mobile)p;
if ( p is Mobile mobile )
to = mobile;
else
to = new Entity( Serial.Zero, new Point3D( p ), from.Map );