Fixes unavailable syntax for Mono.

This commit is contained in:
Kamron Batman 2018-09-03 09:34:36 -07:00
parent f674ec2be0
commit 6ef32ce910
7 changed files with 99 additions and 144 deletions

View file

@ -247,13 +247,13 @@ namespace Server.Commands
if ( x is CategoryEntry entry ) if ( x is CategoryEntry entry )
a = entry.Title; a = entry.Title;
else if ( x is CategoryTypeEntry typeEntry ) else if ( x is CategoryTypeEntry xTypeEntry )
a = typeEntry.Type.Name; a = xTypeEntry.Type.Name;
if ( y is CategoryEntry categoryEntry ) if ( y is CategoryEntry categoryEntry )
b = categoryEntry.Title; b = categoryEntry.Title;
else if ( y is CategoryTypeEntry typeEntry ) else if ( y is CategoryTypeEntry yTypeEntry )
b = typeEntry.Type.Name; b = yTypeEntry.Type.Name;
if ( a == null && b == null ) if ( a == null && b == null )
return 0; return 0;

View file

@ -573,10 +573,10 @@ namespace Server.Factions
StartBandage(); StartBandage();
} }
if ( m_Mobile.Spell == null && Core.TickCount - m_Mobile.NextSpellTime >= 0 ) Spell spell = m_Mobile.Spell as Spell;
{
Spell spell = null;
if ( spell == null && Core.TickCount - m_Mobile.NextSpellTime >= 0 )
{
DateTime toRelease = DateTime.MinValue; DateTime toRelease = DateTime.MinValue;
if ( IsPoisoned ) if ( IsPoisoned )
@ -678,7 +678,7 @@ namespace Server.Factions
if ( types.Count > 1 ) if ( types.Count > 1 )
spell = new BlessSpell( m_Guard, null ); spell = new BlessSpell( m_Guard, null );
else if ( types.Count == 1 ) else if ( types.Count == 1 )
spell = (Spell) Activator.CreateInstance( types[0], new object[]{ m_Guard, null } ); spell = Activator.CreateInstance( types[0], new object[]{ m_Guard, null } ) as Spell;
} }
else if ( types.Count > 0 ) else if ( types.Count > 0 )
{ {
@ -757,7 +757,7 @@ namespace Server.Factions
if ( spell == null || !spell.Cast() ) if ( spell == null || !spell.Cast() )
EquipWeapon(); EquipWeapon();
} }
else if ( m_Mobile.Spell is Spell spell && spell.State == SpellState.Sequencing ) else if ( spell?.State == SpellState.Sequencing )
{ {
EquipWeapon(); EquipWeapon();
} }

View file

@ -43,17 +43,20 @@ namespace Server.Engines.MLQuests.Items
public static void Enhance( Item loot ) public static void Enhance( Item loot )
{ {
switch (loot) if (loot is BaseWeapon weapon)
{ {
case BaseWeapon weapon: BaseRunicTool.ApplyAttributesTo( weapon, Utility.RandomMinMax( 1, 5 ), 10, 80 );
BaseRunicTool.ApplyAttributesTo( weapon, Utility.RandomMinMax( 1, 5 ), 10, 80 ); return;
break; }
case BaseArmor armor:
BaseRunicTool.ApplyAttributesTo( armor, Utility.RandomMinMax( 1, 5 ), 10, 80 ); if (loot is BaseArmor armor)
break; {
default: BaseRunicTool.ApplyAttributesTo( armor, Utility.RandomMinMax( 1, 5 ), 10, 80 );
BaseRunicTool.ApplyAttributesTo((BaseJewel)loot, Utility.RandomMinMax( 1, 5 ), 10, 80 ); }
break;
if (loot is BaseJewel jewel)
{
BaseRunicTool.ApplyAttributesTo(jewel, Utility.RandomMinMax( 1, 5 ), 10, 80 );
} }
} }
} }

View file

@ -43,19 +43,14 @@ namespace Server.Items
#region Checks #region Checks
private bool Resmeltables() //Where context menu checks for metal items and dragon barding deeds private bool Resmeltables() //Where context menu checks for metal items and dragon barding deeds
{ {
foreach( Item i in Items ) foreach (Item i in Items)
{ {
if (i?.Deleted != false) return i?.Deleted == false && (
continue; i is BaseWeapon weapon && CraftResources.GetType(weapon.Resource) == CraftResourceType.Metal ||
i is BaseArmor armor && CraftResources.GetType(armor.Resource) == CraftResourceType.Metal ||
switch (i) 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;
}
} }
return false; return false;
} }
@ -63,20 +58,14 @@ namespace Server.Items
{ {
foreach( Item i in Items ) foreach( Item i in Items )
{ {
if (!(i is IScissorable && !i.Deleted)) if (!(i is IScissorable) || i.Deleted)
continue; continue;
switch (i) if (i is BaseClothing || i is Cloth || i is BoltOfCloth || i is Hides || i is BonePile ||
{ i is BaseArmor armor && CraftResources.GetType(armor.Resource) == CraftResourceType.Leather)
case BaseClothing _: return true;
case BaseArmor armor when CraftResources.GetType( armor.Resource ) == CraftResourceType.Leather:
case Cloth _:
case BoltOfCloth _:
case Hides _:
case BonePile _:
return true;
}
} }
return false; return false;
} }
#endregion #endregion
@ -192,32 +181,25 @@ namespace Server.Items
Container sBag = this; Container sBag = this;
List<Item> Smeltables = sBag.FindItemsByType<Item>(); List<Item> smeltables = sBag.FindItemsByType<Item>();
foreach (Item item in smeltables)
{
if (item?.Deleted != false)
continue;
if (item is BaseArmor armor && Resmelt(from, armor, armor.Resource) ||
item is BaseWeapon weapon && Resmelt(from, weapon, weapon.Resource) ||
item is DragonBardingDeed)
{
salvaged++;
}
else
{
notSalvaged++;
}
}
for(int i = Smeltables.Count - 1; i >= 0; i--)
{
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 ) if ( m_Failure )
{ {
from.SendLocalizedMessage( 1079975 ); // You failed to smelt some metal for lack of skill. from.SendLocalizedMessage( 1079975 ); // You failed to smelt some metal for lack of skill.

View file

@ -61,21 +61,11 @@ namespace Server.Items
if ( obj is IArcaneEquip eq && eq is Item item ) if ( obj is IArcaneEquip eq && eq is Item item )
{ {
CraftResource resource = CraftResource.None; BaseClothing clothing = item as BaseClothing;
BaseArmor armor = item as BaseArmor;
BaseWeapon weapon = item as BaseWeapon;
switch (item) CraftResource resource = clothing?.Resource ?? armor?.Resource ?? weapon?.Resource ?? CraftResource.None;
{
case BaseClothing clothing:
resource = clothing.Resource;
break;
case BaseArmor armor:
resource = armor.Resource;
break;
// Sanity, weapons cannot receive gems...
case BaseWeapon weapon:
resource = weapon.Resource;
break;
}
if ( !item.IsChildOf( from.Backpack ) ) if ( !item.IsChildOf( from.Backpack ) )
{ {
@ -119,39 +109,27 @@ namespace Server.Items
} }
else if ( from.Skills[SkillName.Tailoring].Value >= 80.0 ) else if ( from.Skills[SkillName.Tailoring].Value >= 80.0 )
{ {
bool isExceptional = false; bool isExceptional = clothing?.Quality == ClothingQuality.Exceptional ||
armor?.Quality == ArmorQuality.Exceptional ||
switch (item) weapon?.Quality == WeaponQuality.Exceptional;
{
case BaseClothing clothing:
isExceptional = clothing.Quality == ClothingQuality.Exceptional;
break;
case BaseArmor armor:
isExceptional = armor.Quality == ArmorQuality.Exceptional;
break;
case BaseWeapon weapon:
isExceptional = weapon.Quality == WeaponQuality.Exceptional;
break;
}
if ( isExceptional ) if ( isExceptional )
{ {
switch (item) if (clothing != null)
{ {
case BaseClothing clothing: clothing.Quality = ClothingQuality.Regular;
clothing.Quality = ClothingQuality.Regular; clothing.Crafter = from;
clothing.Crafter = @from; }
break; else if (armor != null)
case BaseArmor armor: {
armor.Quality = ArmorQuality.Regular; armor.Quality = ArmorQuality.Regular;
armor.Crafter = @from; armor.Crafter = from;
armor.PhysicalBonus = armor.FireBonus = armor.ColdBonus = armor.PoisonBonus = armor.EnergyBonus = 0; // Is there a method to remove bonuses? armor.PhysicalBonus = armor.FireBonus = armor.ColdBonus = armor.PoisonBonus = armor.EnergyBonus = 0; // Is there a method to remove bonuses?
break; }
// Sanity, weapons cannot receive gems... else if (weapon != null)
case BaseWeapon weapon: {
weapon.Quality = WeaponQuality.Regular; weapon.Quality = WeaponQuality.Regular;
weapon.Crafter = @from; weapon.Crafter = from;
break;
} }
eq.CurArcaneCharges = eq.MaxArcaneCharges = charges; eq.CurArcaneCharges = eq.MaxArcaneCharges = charges;

View file

@ -155,28 +155,25 @@ namespace Server.Items
BaseHouse house = BaseHouse.FindHouseAt( from ); BaseHouse house = BaseHouse.FindHouseAt( from );
bool isDecorableComponent = false; bool isDecorableComponent = false;
object addon = null;
int count = 0;
if ( item is AddonComponent || item is AddonContainerComponent || item is BaseAddonContainer ) if (item is AddonComponent component)
{ {
object addon = null; count = component.Addon.Components.Count;
int count = 0; addon = component.Addon;
} else if (item is AddonContainerComponent containerComponent)
switch (item) {
{ count = containerComponent.Addon.Components.Count;
case AddonComponent component: addon = containerComponent.Addon;
count = component.Addon.Components.Count; } else if (item is BaseAddonContainer container)
addon = component.Addon; {
break; count = container.Components.Count;
case AddonContainerComponent containerComponent: addon = container;
count = containerComponent.Addon.Components.Count; }
addon = containerComponent.Addon;
break;
case BaseAddonContainer container:
count = container.Components.Count;
addon = container;
break;
}
if (addon != null)
{
if ( count == 1 && Core.SE ) if ( count == 1 && Core.SE )
isDecorableComponent = true; isDecorableComponent = true;
@ -236,22 +233,17 @@ namespace Server.Items
private static void Turn( Item item, Mobile from ) private static void Turn( Item item, Mobile from )
{ {
if ( item is AddonComponent || item is AddonContainerComponent || item is BaseAddonContainer ) object addon = null;
{
object addon = null;
switch (item) if (item is AddonComponent component)
{ addon = component.Addon;
case AddonComponent component: else if (item is AddonContainerComponent containerComponent)
addon = component.Addon; addon = containerComponent.Addon;
break; else if (item is BaseAddonContainer container)
case AddonContainerComponent containerComponent: addon = container;
addon = containerComponent.Addon;
break; if (addon != null)
case BaseAddonContainer container: {
addon = container;
break;
}
FlippableAddonAttribute[] aAttributes = (FlippableAddonAttribute[]) addon.GetType().GetCustomAttributes( typeof( FlippableAddonAttribute ), false ); FlippableAddonAttribute[] aAttributes = (FlippableAddonAttribute[]) addon.GetType().GetCustomAttributes( typeof( FlippableAddonAttribute ), false );

View file

@ -39,7 +39,7 @@ namespace Server {
{ {
this.PermitBackgroundWrite = permitBackgroundWrite; this.PermitBackgroundWrite = permitBackgroundWrite;
Thread saveThread = new Thread( delegate { Thread saveThread = new Thread( delegate() {
SaveItems(metrics); SaveItems(metrics);
} ); } );