Adds more formatting

This commit is contained in:
Kamron Batman 2018-08-19 21:28:24 +08:00
parent e77d695684
commit f674ec2be0
68 changed files with 530 additions and 876 deletions

View file

@ -61,9 +61,9 @@ namespace Server.Items
BaseHouse house = BaseHouse.FindHouseAt( this );
if ( house != null && house.IsLockedDown( this ) )
if ( house?.IsLockedDown( this ) == true )
{
if ( dropped is VendorRentalContract || ( dropped is Container && ((Container)dropped).FindItemByType( typeof( VendorRentalContract ) ) != null ) )
if ( dropped is VendorRentalContract || ( dropped is Container container && container.FindItemByType( typeof( VendorRentalContract ) ) != null ) )
{
from.SendLocalizedMessage( 1062492 ); // You cannot place a rental contract in a locked down container.
return false;
@ -95,9 +95,9 @@ namespace Server.Items
BaseHouse house = BaseHouse.FindHouseAt( this );
if ( house != null && house.IsLockedDown( this ) )
if ( house?.IsLockedDown( this ) == true )
{
if ( item is VendorRentalContract || ( item is Container && ((Container)item).FindItemByType( typeof( VendorRentalContract ) ) != null ) )
if ( item is VendorRentalContract || ( item is Container container && container.FindItemByType( typeof( VendorRentalContract ) ) != null ) )
{
from.SendLocalizedMessage( 1062492 ); // You cannot place a rental contract in a locked down container.
return false;
@ -119,8 +119,8 @@ namespace Server.Items
{
base.UpdateTotal( sender, type, delta );
if ( type == TotalType.Weight && RootParent is Mobile )
((Mobile) RootParent).InvalidateProperties();
if ( type == TotalType.Weight )
(RootParent as Mobile)?.InvalidateProperties();
}
public override void OnDoubleClick( Mobile from )
@ -238,12 +238,7 @@ namespace Server.Items
public override bool CheckContentDisplay( Mobile from )
{
object root = this.RootParent;
if ( root is BaseCreature && ((BaseCreature)root).Controlled && ((BaseCreature)root).ControlMaster == from )
return true;
return base.CheckContentDisplay( from );
return RootParent is BaseCreature creature && creature.Controlled && creature.ControlMaster == from || base.CheckContentDisplay( from );
}
public StrongBackpack( Serial serial ) : base( serial )
@ -279,16 +274,10 @@ namespace Server.Items
public override int DefaultMaxWeight {
get {
if ( Core.ML ) {
Mobile m = Parent as Mobile;
if ( m != null && m.Player && m.Backpack == this ) {
return 550;
} else {
return base.DefaultMaxWeight;
}
} else {
return base.DefaultMaxWeight;
}
if ( Core.ML && Parent is Mobile m && m.Player && m.Backpack == this )
return 550;
return base.DefaultMaxWeight;
}
}

View file

@ -616,8 +616,8 @@ namespace Server.Items
{
Item item = Loot.Construct( m_Types );
if ( item is Key )
( (Key)item ).ItemID = Utility.RandomList( (int)KeyType.Copper, (int)KeyType.Gold, (int)KeyType.Iron, (int)KeyType.Rusty );
if ( item is Key key )
key.ItemID = Utility.RandomList( (int)KeyType.Copper, (int)KeyType.Gold, (int)KeyType.Iron, (int)KeyType.Rusty );
else if ( item is Arrow || item is Bolt )
item.Amount = Utility.RandomMinMax( 2, 6 );
else if ( item is Bandage || item is Lockpick )
@ -662,10 +662,8 @@ namespace Server.Items
{
item = base.Construct();
if ( item is BaseBeverage )
if ( item is BaseBeverage bev )
{
BaseBeverage bev = (BaseBeverage)item;
bev.Content = m_Content;
bev.Quantity = bev.MaxQuantity;
}
@ -1514,9 +1512,7 @@ namespace Server.Items
if ( nearest != null && mob.GetDistanceToSqrt( loc ) > nearest.GetDistanceToSqrt( loc ) && !( nearest is Cobbler && mob is Provisioner ) )
continue;
FillableContent check = m_AcquireTable[ mob.GetType() ] as FillableContent;
if ( check != null )
if ( m_AcquireTable[ mob.GetType() ] is FillableContent check )
{
nearest = mob;
content = check;

View file

@ -202,34 +202,24 @@ namespace Server.Items
public override bool OnDragDrop( Mobile from, Item dropped )
{
RecallRune rune = dropped as RecallRune;
if ( rune != null && base.OnDragDrop( from, dropped ) )
if ( dropped is RecallRune rune && base.OnDragDrop( from, dropped ) )
{
Mark( rune );
return true;
}
else
{
return false;
}
return false;
}
public override bool OnDragDropInto( Mobile from, Item dropped, Point3D p )
{
RecallRune rune = dropped as RecallRune;
if ( rune != null && base.OnDragDropInto( from, dropped, p ) )
if ( dropped is RecallRune rune && base.OnDragDropInto( from, dropped, p ) )
{
Mark( rune );
return true;
}
else
{
return false;
}
return false;
}
public override void Serialize( GenericWriter writer )

View file

@ -122,17 +122,11 @@ namespace Server.Items
else
item = Loot.RandomArmorOrShieldOrWeapon();
if ( item is BaseWeapon )
if ( item is BaseWeapon weapon )
{
BaseWeapon weapon = (BaseWeapon)item;
if ( Core.AOS )
{
int attributeCount;
int min, max;
GetRandomAOSStats( out attributeCount, out min, out max );
GetRandomAOSStats( out var attributeCount, out var min, out var max );
BaseRunicTool.ApplyAttributesTo( weapon, attributeCount, min, max );
}
else
@ -142,19 +136,13 @@ namespace Server.Items
weapon.DurabilityLevel = (WeaponDurabilityLevel)Utility.Random( 6 );
}
DropItem( item );
DropItem( weapon );
}
else if ( item is BaseArmor )
else if ( item is BaseArmor armor )
{
BaseArmor armor = (BaseArmor)item;
if ( Core.AOS )
{
int attributeCount;
int min, max;
GetRandomAOSStats( out attributeCount, out min, out max );
GetRandomAOSStats( out var attributeCount, out var min, out var max );
BaseRunicTool.ApplyAttributesTo( armor, attributeCount, min, max );
}
else
@ -163,34 +151,24 @@ namespace Server.Items
armor.Durability = (ArmorDurabilityLevel)Utility.Random( 6 );
}
DropItem( item );
DropItem( armor );
}
else if ( item is BaseHat )
else if ( item is BaseHat hat )
{
BaseHat hat = (BaseHat)item;
if ( Core.AOS )
{
int attributeCount;
int min, max;
GetRandomAOSStats( out attributeCount, out min, out max );
GetRandomAOSStats( out var attributeCount, out var min, out var max );
BaseRunicTool.ApplyAttributesTo( hat, attributeCount, min, max );
}
DropItem( item );
DropItem( hat );
}
else if ( item is BaseJewel )
else if ( item is BaseJewel jewel )
{
int attributeCount;
int min, max;
GetRandomAOSStats( out var attributeCount, out var min, out var max );
BaseRunicTool.ApplyAttributesTo( jewel, attributeCount, min, max );
GetRandomAOSStats( out attributeCount, out min, out max );
BaseRunicTool.ApplyAttributesTo( (BaseJewel)item, attributeCount, min, max );
DropItem( item );
DropItem( jewel );
}
}

View file

@ -45,19 +45,14 @@ namespace Server.Items
{
foreach( Item i in Items )
{
if ( i != null && !i.Deleted )
if (i?.Deleted != false)
continue;
switch (i)
{
if ( i is BaseWeapon )
{
if ( CraftResources.GetType( ( (BaseWeapon)i ).Resource ) == CraftResourceType.Metal )
return true;
}
if ( i is BaseArmor )
{
if ( CraftResources.GetType( ( (BaseArmor)i ).Resource ) == CraftResourceType.Metal )
return true;
}
if ( i is DragonBardingDeed )
case BaseWeapon weapon when CraftResources.GetType( weapon.Resource ) == CraftResourceType.Metal:
case BaseArmor armor when CraftResources.GetType( armor.Resource ) == CraftResourceType.Metal:
case DragonBardingDeed _:
return true;
}
}
@ -68,20 +63,18 @@ namespace Server.Items
{
foreach( Item i in Items )
{
if ( i != null && !i.Deleted )
if (!(i is IScissorable && !i.Deleted))
continue;
switch (i)
{
if ( i is IScissorable )
{
if ( i is BaseClothing )
return true;
if ( i is BaseArmor )
{
if ( CraftResources.GetType( ( (BaseArmor)i ).Resource ) == CraftResourceType.Leather )
return true;
}
if ( ( i is Cloth ) || ( i is BoltOfCloth ) || ( i is Hides ) || ( i is BonePile ) )
return true;
}
case BaseClothing _:
case BaseArmor armor when CraftResources.GetType( armor.Resource ) == CraftResourceType.Leather:
case Cloth _:
case BoltOfCloth _:
case Hides _:
case BonePile _:
return true;
}
}
return false;
@ -128,7 +121,7 @@ namespace Server.Items
Type resourceType = info.ResourceTypes[ 0 ];
Item ingot = (Item)Activator.CreateInstance( resourceType );
if ( item is DragonBardingDeed || ( item is BaseArmor && ( (BaseArmor)item ).PlayerConstructed ) || ( item is BaseWeapon && ( (BaseWeapon)item ).PlayerConstructed ) || ( item is BaseClothing && ( (BaseClothing)item ).PlayerConstructed ) )
if ( item is DragonBardingDeed || ( item is BaseArmor armor && armor.PlayerConstructed ) || ( item is BaseWeapon weapon && weapon.PlayerConstructed ) || ( item is BaseClothing clothing && clothing.PlayerConstructed ) )
{
double mining = from.Skills[ SkillName.Mining ].Value;
if ( mining > 100.0 )
@ -176,7 +169,7 @@ namespace Server.Items
bool ToolFound = false;
foreach( Item tool in tools )
{
if ( tool is BaseTool && ( (BaseTool)tool ).CraftSystem == DefBlacksmithy.CraftSystem )
if ( tool is BaseTool baseTool && baseTool.CraftSystem == DefBlacksmithy.CraftSystem )
ToolFound = true;
}
@ -186,8 +179,7 @@ namespace Server.Items
return;
}
bool anvil, forge;
DefBlacksmithy.CheckAnvilAndForge( from, 2, out anvil, out forge );
DefBlacksmithy.CheckAnvilAndForge( from, 2, out _, out var forge );
if ( !forge )
{
@ -204,31 +196,28 @@ namespace Server.Items
for(int i = Smeltables.Count - 1; i >= 0; i--)
{
Item item = Smeltables[ i ];
if ( item is BaseArmor )
{
if ( Resmelt( from, item, ( (BaseArmor)item ).Resource ) )
salvaged++;
else
notSalvaged++;
}
else if ( item is BaseWeapon )
{
if ( Resmelt( from, item, ( (BaseWeapon)item ).Resource ) )
salvaged++;
else
notSalvaged++;
}
else if ( item is DragonBardingDeed )
{
if ( Resmelt( from, item, ( (DragonBardingDeed)item ).Resource ) )
salvaged++;
else
notSalvaged++;
}
}
switch (Smeltables[i])
{
case BaseArmor armor when Resmelt( from, armor, armor.Resource ):
salvaged++;
break;
case BaseArmor _:
notSalvaged++;
break;
case BaseWeapon weapon when Resmelt( from, weapon, weapon.Resource ):
salvaged++;
break;
case BaseWeapon _:
notSalvaged++;
break;
case DragonBardingDeed deed when Resmelt( from, deed, deed.Resource ):
salvaged++;
break;
case DragonBardingDeed _:
notSalvaged++;
break;
}
}
if ( m_Failure )
{
from.SendLocalizedMessage( 1079975 ); // You failed to smelt some metal for lack of skill.
@ -240,8 +229,7 @@ namespace Server.Items
private void SalvageCloth( Mobile from )
{
Scissors scissors = from.Backpack.FindItemByType( typeof( Scissors ) ) as Scissors;
if ( scissors == null )
if ( !(from.Backpack.FindItemByType( typeof( Scissors ) ) is Scissors scissors) )
{
from.SendLocalizedMessage( 1079823 ); // You need scissors in order to salvage cloth.
return;
@ -258,22 +246,18 @@ namespace Server.Items
{
Item item = scissorables[i];
if ( item is IScissorable )
{
IScissorable scissorable = (IScissorable)item;
if (!(item is IScissorable scissorable))
continue;
if ( Scissors.CanScissor( from, scissorable ) && scissorable.Scissor( from, scissors ) )
++salvaged;
else
++notSalvaged;
}
if ( Scissors.CanScissor( from, scissorable ) && scissorable.Scissor( from, scissors ) )
++salvaged;
else
++notSalvaged;
}
from.SendLocalizedMessage( 1079974, String.Format( "{0}\t{1}", salvaged, salvaged + notSalvaged ) ); // Salvaged: ~1_COUNT~/~2_NUM~ tailored items
Container pack = from.Backpack;
foreach (Item i in ((Container)this).FindItemsByType(typeof(Item), true))
foreach (Item i in this.FindItemsByType(typeof(Item), true))
{
if ( ( i is Leather ) || ( i is Cloth ) || ( i is SpinedLeather ) || ( i is HornedLeather ) || ( i is BarbedLeather ) || ( i is Bandage ) || ( i is Bone ) )
{

View file

@ -198,17 +198,11 @@ namespace Server.Items
else
item = Loot.RandomArmorOrShieldOrWeapon();
if ( item is BaseWeapon )
if ( item is BaseWeapon weapon )
{
BaseWeapon weapon = (BaseWeapon)item;
if ( Core.AOS )
{
int attributeCount;
int min, max;
GetRandomAOSStats( out attributeCount, out min, out max );
GetRandomAOSStats( out var attributeCount, out var min, out var max );
BaseRunicTool.ApplyAttributesTo( weapon, attributeCount, min, max );
}
else
@ -218,19 +212,13 @@ namespace Server.Items
weapon.DurabilityLevel = (WeaponDurabilityLevel)Utility.Random( 6 );
}
cont.DropItem( item );
cont.DropItem( weapon );
}
else if ( item is BaseArmor )
else if ( item is BaseArmor armor )
{
BaseArmor armor = (BaseArmor)item;
if ( Core.AOS )
{
int attributeCount;
int min, max;
GetRandomAOSStats( out attributeCount, out min, out max );
GetRandomAOSStats( out var attributeCount, out var min, out var max );
BaseRunicTool.ApplyAttributesTo( armor, attributeCount, min, max );
}
else
@ -239,34 +227,24 @@ namespace Server.Items
armor.Durability = (ArmorDurabilityLevel)Utility.Random( 6 );
}
cont.DropItem( item );
cont.DropItem( armor );
}
else if ( item is BaseHat )
else if ( item is BaseHat hat )
{
BaseHat hat = (BaseHat)item;
if ( Core.AOS )
{
int attributeCount;
int min, max;
GetRandomAOSStats( out attributeCount, out min, out max );
GetRandomAOSStats( out var attributeCount, out var min, out var max );
BaseRunicTool.ApplyAttributesTo( hat, attributeCount, min, max );
}
cont.DropItem( item );
cont.DropItem( hat );
}
else if ( item is BaseJewel )
else if ( item is BaseJewel jewel )
{
int attributeCount;
int min, max;
GetRandomAOSStats( out var attributeCount, out var min, out var max );
BaseRunicTool.ApplyAttributesTo( jewel, attributeCount, min, max );
GetRandomAOSStats( out attributeCount, out min, out max );
BaseRunicTool.ApplyAttributesTo( (BaseJewel)item, attributeCount, min, max );
cont.DropItem( item );
cont.DropItem( jewel );
}
}
}