Fixes more casting and other formatting issues.

This commit is contained in:
Kamron Batman 2018-08-19 10:14:40 +08:00
parent 03dd5f1926
commit 61937d9c97
67 changed files with 325 additions and 570 deletions

View file

@ -228,7 +228,7 @@ namespace Server.Engines.Plants
if ( info.ButtonID == 0 || m_Plant.Deleted || m_Plant.PlantStatus >= PlantStatus.DecorativePlant )
return;
if ( ( ( info.ButtonID >= 6 && info.ButtonID <= 10 ) || info.ButtonID == 12 ) && !from.InRange( m_Plant.GetWorldLocation(), 3 ) )
{
from.LocalOverheadMessage( MessageType.Regular, 0x3E9, 500446 ); // That is too far away.
@ -293,15 +293,15 @@ namespace Server.Engines.Plants
case 6: // Water
{
Item[] item = from.Backpack.FindItemsByType( typeof( BaseBeverage ) );
bool foundUsableWater = false;
if ( item != null && item.Length > 0 )
{
for ( int i = 0; i < item.Length; ++i )
{
BaseBeverage beverage = (BaseBeverage)item[i];
if ( !beverage.IsEmpty && beverage.Pourable && beverage.Content == BeverageType.Water )
{
foundUsableWater = true;
@ -310,7 +310,7 @@ namespace Server.Engines.Plants
}
}
}
if ( !foundUsableWater )
{
from.Target = new PlantPourTarget( m_Plant );
@ -400,10 +400,8 @@ namespace Server.Engines.Plants
foreach ( Item item in items )
{
if ( item is BasePotion )
if ( item is BasePotion potion )
{
BasePotion potion = (BasePotion)item;
if ( Array.IndexOf( effects, potion.PotionEffect ) >= 0 )
return potion;
}
@ -419,4 +417,4 @@ namespace Server.Engines.Plants
return null;
}
}
}
}

View file

@ -78,9 +78,7 @@ namespace Server.Items
return;
}
LandTarget land = targeted as LandTarget;
if ( land == null )
if ( !(targeted is LandTarget land) )
{
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1061912 ); // * You cannot plant a green thorn there! *
}

View file

@ -62,9 +62,7 @@ namespace Server.Items
return;
}
Item item = targeted as Item;
if ( item == null || !item.IsChildOf( from.Backpack ) )
if ( !(targeted is Item item) || !item.IsChildOf( from.Backpack ) )
{
from.SendLocalizedMessage( 1042664 ); // You must have the object in your backpack to use it.
}

View file

@ -52,12 +52,10 @@ namespace Server.Engines.Plants
return;
}
if ( targeted is FertileDirt )
if ( targeted is FertileDirt dirt )
{
int _dirtNeeded = Core.ML ? 20 : 40;
FertileDirt dirt = (FertileDirt)targeted;
if ( !dirt.IsChildOf( from.Backpack ) )
{
from.SendLocalizedMessage( 1042664 ); // You must have the object in your backpack to use it.
@ -132,12 +130,12 @@ namespace Server.Engines.Plants
{
int tileID;
if ( obj is Static && !((Static)obj).Movable )
tileID = (((Static)obj).ItemID & 0x3FFF) | 0x4000;
else if ( obj is StaticTarget )
tileID = (((StaticTarget)obj).ItemID & 0x3FFF) | 0x4000;
else if ( obj is LandTarget )
tileID = ((LandTarget)obj).TileID;
if ( obj is Static staticObj && !staticObj.Movable )
tileID = (staticObj.ItemID & 0x3FFF) | 0x4000;
else if ( obj is StaticTarget staticTarget )
tileID = (staticTarget.ItemID & 0x3FFF) | 0x4000;
else if ( obj is LandTarget landTarget )
tileID = landTarget.TileID;
else
return false;

View file

@ -151,8 +151,7 @@ namespace Server.Engines.Plants
return true;
Mobile owner = RootParent as Mobile;
if ( owner == null )
if ( !(RootParent is Mobile owner) )
return false;
if ( owner.Backpack != null && IsChildOf( owner.Backpack ) )
@ -318,8 +317,7 @@ namespace Server.Engines.Plants
public bool IsUsableBy( Mobile from )
{
Item root = RootParent as Item;
return IsChildOf( from.Backpack ) || IsChildOf( from.FindBankNoCreate() ) || IsLockedDown && IsAccessibleTo( from ) || root != null && root.IsSecure && root.IsAccessibleTo( from );
return IsChildOf( from.Backpack ) || IsChildOf( from.FindBankNoCreate() ) || IsLockedDown && IsAccessibleTo( from ) || RootParent is Item root && root.IsSecure && root.IsAccessibleTo( from );
}
public override void OnDoubleClick( Mobile from )
@ -408,10 +406,8 @@ namespace Server.Engines.Plants
return;
}
if ( item is BaseBeverage )
if ( item is BaseBeverage beverage )
{
BaseBeverage beverage = (BaseBeverage)item;
if ( beverage.IsEmpty || !beverage.Pourable || beverage.Content != BeverageType.Water )
{
LabelTo( from, 1053069 ); // You can't use that on a plant!
@ -427,12 +423,9 @@ namespace Server.Engines.Plants
from.PlaySound( 0x4E );
LabelTo( from, 1061858 ); // You soften the dirt with water.
}
else if ( item is BasePotion )
else if ( item is BasePotion potion )
{
BasePotion potion = (BasePotion)item;
int message;
if ( ApplyPotion( potion.PotionEffect, false, out message ) )
if ( ApplyPotion( potion.PotionEffect, false, out int message ) )
{
potion.Consume();
from.PlaySound( 0x240 );
@ -440,18 +433,15 @@ namespace Server.Engines.Plants
}
LabelTo( from, message );
}
else if ( item is PotionKeg )
else if ( item is PotionKeg keg )
{
PotionKeg keg = (PotionKeg)item;
if ( keg.Held <= 0 )
{
LabelTo( from, 1053069 ); // You can't use that on a plant!
return;
}
int message;
if ( ApplyPotion( keg.Type, false, out message ) )
if ( ApplyPotion( keg.Type, false, out int message ) )
{
keg.Held--;
from.PlaySound( 0x240 );

View file

@ -15,9 +15,9 @@ namespace Server.Engines.Plants
protected override void OnTarget( Mobile from, object targeted )
{
if ( !m_Plant.Deleted && from.InRange( m_Plant.GetWorldLocation(), 3 ) && targeted is Item )
if ( !m_Plant.Deleted && from.InRange( m_Plant.GetWorldLocation(), 3 ) && targeted is Item item )
{
m_Plant.Pour( from, (Item)targeted );
m_Plant.Pour( from, item );
}
}
@ -32,4 +32,4 @@ namespace Server.Engines.Plants
}
}
}
}
}

View file

@ -35,9 +35,7 @@ namespace Server.Engines.Plants
}
else
{
PlantItem targ = targeted as PlantItem;
if ( targ == null || targ.PlantStatus >= PlantStatus.DecorativePlant || targ.PlantStatus <= PlantStatus.BowlOfDirt )
if ( !(targeted is PlantItem targ) || targ.PlantStatus >= PlantStatus.DecorativePlant || targ.PlantStatus <= PlantStatus.BowlOfDirt )
{
m_Plant.LabelTo( from, 1053070 ); // You can only pollinate other specially grown plants!
}

View file

@ -158,22 +158,12 @@ namespace Server.Engines.Plants
public override bool StackWith( Mobile from, Item dropped, bool playSound )
{
if ( dropped is Seed )
{
Seed other = (Seed)dropped;
if ( other.PlantType == m_PlantType && other.PlantHue == m_PlantHue && other.ShowType == m_ShowType )
return base.StackWith( from, dropped, playSound );
}
return false;
return dropped is Seed other && other.PlantType == m_PlantType && other.PlantHue == m_PlantHue && other.ShowType == m_ShowType && base.StackWith( from, other, playSound );
}
public override void OnAfterDuped( Item newItem )
{
Seed newSeed = newItem as Seed;
if ( newSeed == null )
if ( !(newItem is Seed newSeed) )
return;
newSeed.PlantType = m_PlantType;
@ -202,15 +192,13 @@ namespace Server.Engines.Plants
return;
}
if ( targeted is PlantItem )
if ( targeted is PlantItem plant )
{
PlantItem plant = (PlantItem)targeted;
plant.PlantSeed( from, m_Seed );
}
else if ( targeted is Item )
else if ( targeted is Item item )
{
((Item)targeted).LabelTo( from, 1061919 ); // You must use a seed on a bowl of dirt!
item.LabelTo( from, 1061919 ); // You must use a seed on a bowl of dirt!
}
else
{