Fixes casting, default parameters and null propogation in more files.

This commit is contained in:
Kamron Batman 2018-09-09 22:05:44 -07:00
parent 067dca8393
commit 403e2a8b9d
21 changed files with 328 additions and 523 deletions

View file

@ -62,9 +62,9 @@ namespace Server.Items
{
Item deed = this.Deed;
if ( this.Parent is Item )
if ( this.Parent is Item item )
{
((Item)this.Parent).AddItem( deed );
item.AddItem( deed );
deed.Location = this.Location;
}
else
@ -241,9 +241,7 @@ namespace Server.Items
public void Placement_OnTarget( Mobile from, object targeted, object state )
{
IPoint3D p = targeted as IPoint3D;
if ( p == null )
if ( !(targeted is IPoint3D p) )
return;
Point3D loc = new Point3D( p );

View file

@ -107,9 +107,8 @@ namespace Server.Items
{
from.SendLocalizedMessage( 1005576 ); // You can't throw this at yourself.
}
else if ( target is Mobile )
else if ( target is Mobile targ )
{
Mobile targ = (Mobile) target;
Container pack = targ.Backpack;
if ( from.Region.IsPartOf( typeof( Engines.ConPVP.SafeZone ) ) || targ.Region.IsPartOf( typeof( Engines.ConPVP.SafeZone ) ) )

View file

@ -93,16 +93,15 @@ namespace Server.Items
{
from.SendLocalizedMessage( 1005576 ); // You can't throw this at yourself.
}
else if ( target is Mobile )
else if ( target is Mobile targ )
{
Mobile targ = (Mobile) target;
Container pack = targ.Backpack;
if ( from.Region.IsPartOf( typeof( Engines.ConPVP.SafeZone ) ) || targ.Region.IsPartOf( typeof( Engines.ConPVP.SafeZone ) ) )
{
from.SendMessage( "You may not throw snow here." );
}
else if ( pack != null && pack.FindItemByType( new Type[]{ typeof( SnowPile ), typeof( PileOfGlacialSnow ) } ) != null )
else if ( pack?.FindItemByType( new Type[]{ typeof( SnowPile ), typeof( PileOfGlacialSnow ) } ) != null )
{
if ( from.BeginAction( typeof( SnowPile ) ) )
{