fix: Adds FindItemOnLayer generic (#1223)

This commit is contained in:
Kamron Batman 2022-11-01 00:49:20 -07:00 • committed by GitHub
parent 053dbcbad0
commit fd6f4239e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 112 additions and 169 deletions

View file

@ -530,20 +530,13 @@ namespace Server.Items
return list;
}
public static Spellbook FindEquippedSpellbook(Mobile from) => from.FindItemOnLayer(Layer.OneHanded) as Spellbook;
public static Spellbook FindEquippedSpellbook(Mobile from) => from.FindItemOnLayer<Spellbook>(Layer.OneHanded);
public static bool ValidateSpellbook(Spellbook book, int spellID, SpellbookType type) =>
book.SpellbookType == type && (spellID == -1 || book.HasSpell(spellID));
public override bool AllowSecureTrade(Mobile from, Mobile to, Mobile newOwner, bool accepted)
{
if (!Ethic.CheckTrade(from, to, newOwner, this))
{
return false;
}
return base.AllowSecureTrade(from, to, newOwner, accepted);
}
public override bool AllowSecureTrade(Mobile from, Mobile to, Mobile newOwner, bool accepted) =>
Ethic.CheckTrade(from, to, newOwner, this) && base.AllowSecureTrade(from, to, newOwner, accepted);
public override bool CanEquip(Mobile from)
{

View file

@ -1373,7 +1373,7 @@ namespace Server.Items
return false;
}
var shield = defender.FindItemOnLayer(Layer.TwoHanded) as BaseShield;
var shield = defender.FindItemOnLayer<BaseShield>(Layer.TwoHanded);
var parry = defender.Skills.Parry.Value;
var bushidoNonRacial = defender.Skills.Bushido.NonRacialValue;
@ -1489,7 +1489,7 @@ namespace Server.Items
defender.Stam += Utility.RandomMinMax(1, (int)(bushido / 5));
}
var shield = defender.FindItemOnLayer(Layer.TwoHanded) as BaseShield;
var shield = defender.FindItemOnLayer<BaseShield>(Layer.TwoHanded);
shield?.OnHit(this, damage);
}
@ -1785,9 +1785,11 @@ namespace Server.Items
out var direct
);
if (Core.ML && this is BaseRanged && attacker.FindItemOnLayer(Layer.Cloak) is BaseQuiver quiver)
if (Core.ML && this is BaseRanged)
{
quiver.AlterBowDamage(ref phys, ref fire, ref cold, ref pois, ref nrgy, ref chaos, ref direct);
attacker
.FindItemOnLayer<BaseQuiver>(Layer.Cloak)
?.AlterBowDamage(ref phys, ref fire, ref cold, ref pois, ref nrgy, ref chaos, ref direct);
}
if (Consecrated)

View file

@ -171,7 +171,7 @@ namespace Server.Items
{
if (attacker.Player)
{
var quiver = attacker.FindItemOnLayer(Layer.Cloak) as BaseQuiver;
var quiver = attacker.FindItemOnLayer<BaseQuiver>(Layer.Cloak);
var pack = attacker.Backpack;
if (quiver == null || Utility.Random(100) >= quiver.LowerAmmoCost)