fix: Simplifies ore stack logic (#1319)
This commit is contained in:
parent
f47560e56c
commit
b18dfcbb63
3 changed files with 36 additions and 41 deletions
|
|
@ -2269,39 +2269,44 @@ public class Item : IHued, IComparable<Item>, ISpawnable, IObjectPropertyListEnt
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool CanStackWith(Item dropped) =>
|
public virtual bool CanStackWith(Item dropped) =>
|
||||||
dropped.Stackable && Stackable && dropped.GetType() == GetType() && dropped.ItemID == ItemID &&
|
dropped.Stackable && Stackable &&
|
||||||
dropped.Hue == Hue && dropped.Name == Name && dropped.Amount + Amount <= 60000 && dropped != this;
|
dropped.GetType() == GetType() &&
|
||||||
|
dropped.ItemID == ItemID &&
|
||||||
|
dropped.Hue == Hue &&
|
||||||
|
dropped.Name == Name &&
|
||||||
|
dropped.Amount + Amount <= 60000 &&
|
||||||
|
dropped != this;
|
||||||
|
|
||||||
public bool StackWith(Mobile from, Item dropped) => StackWith(from, dropped, true);
|
public bool StackWith(Mobile from, Item dropped) => StackWith(from, dropped, true);
|
||||||
|
|
||||||
public virtual bool StackWith(Mobile from, Item dropped, bool playSound)
|
public virtual bool StackWith(Mobile from, Item dropped, bool playSound)
|
||||||
{
|
{
|
||||||
if (CanStackWith(dropped))
|
if (!CanStackWith(dropped))
|
||||||
{
|
{
|
||||||
if (m_LootType != dropped.m_LootType)
|
return false;
|
||||||
{
|
|
||||||
m_LootType = LootType.Regular;
|
|
||||||
}
|
|
||||||
|
|
||||||
Amount += dropped.Amount;
|
|
||||||
dropped.Delete();
|
|
||||||
|
|
||||||
if (playSound && from != null)
|
|
||||||
{
|
|
||||||
var soundID = GetDropSound();
|
|
||||||
|
|
||||||
if (soundID == -1)
|
|
||||||
{
|
|
||||||
soundID = 0x42;
|
|
||||||
}
|
|
||||||
|
|
||||||
from.SendSound(soundID, GetWorldLocation());
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
if (m_LootType != dropped.m_LootType)
|
||||||
|
{
|
||||||
|
m_LootType = LootType.Regular;
|
||||||
|
}
|
||||||
|
|
||||||
|
Amount += dropped.Amount;
|
||||||
|
dropped.Delete();
|
||||||
|
|
||||||
|
if (playSound && from != null)
|
||||||
|
{
|
||||||
|
var soundID = GetDropSound();
|
||||||
|
|
||||||
|
if (soundID == -1)
|
||||||
|
{
|
||||||
|
soundID = 0x42;
|
||||||
|
}
|
||||||
|
|
||||||
|
from.SendSound(soundID, GetWorldLocation());
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool OnDragDrop(Mobile from, Item dropped)
|
public virtual bool OnDragDrop(Mobile from, Item dropped)
|
||||||
|
|
|
||||||
|
|
@ -49,17 +49,9 @@ public abstract partial class Food : Item
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool CanStackWith(Item dropped)
|
public override bool CanStackWith(Item dropped) =>
|
||||||
{
|
(dropped is not Food food || Poison == food.Poison && Poisoner == food.Poisoner) &&
|
||||||
if (dropped is Food food)
|
base.CanStackWith(dropped);
|
||||||
{
|
|
||||||
if (Poison != food.Poison || Poisoner != food.Poisoner)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return base.CanStackWith(dropped);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public virtual bool Eat(Mobile from)
|
public virtual bool Eat(Mobile from)
|
||||||
|
|
|
||||||
|
|
@ -54,10 +54,8 @@ public abstract partial class BaseOre : Item
|
||||||
};
|
};
|
||||||
|
|
||||||
public override bool CanStackWith(Item dropped) =>
|
public override bool CanStackWith(Item dropped) =>
|
||||||
dropped.Stackable && Stackable && dropped.Hue == Hue &&
|
base.CanStackWith(dropped) &&
|
||||||
dropped.GetType() == GetType() && dropped.ItemID == ItemID &&
|
(dropped as BaseOre)?._resource == _resource;
|
||||||
(dropped as BaseOre)?._resource == _resource && dropped.Name == Name &&
|
|
||||||
dropped.Amount + Amount <= 60000 && dropped != this;
|
|
||||||
|
|
||||||
public override void AddNameProperty(IPropertyList list)
|
public override void AddNameProperty(IPropertyList list)
|
||||||
{
|
{
|
||||||
|
|
@ -444,4 +442,4 @@ public partial class ValoriteOre : BaseOre
|
||||||
}
|
}
|
||||||
|
|
||||||
public override BaseIngot GetIngot() => new ValoriteIngot();
|
public override BaseIngot GetIngot() => new ValoriteIngot();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue