namespace Ashwild.Inventory { /// /// A container-agnostic snapshot of what a slot holds: the item, how many, and the remaining uses /// of this concrete instance (-1 when the item does not track uses). It is the common currency /// between every container — the player's inventory, a chest, or a stack in flight over the network — /// so the transfer rules can be written once without knowing where a slot lives. /// /// Carrying is what keeps a half-worn tool half-worn when it changes slot: writing /// a slot back without it silently repairs the item to full. /// public struct SlotContent { public ItemData Item; public int Quantity; public int Uses; /// /// True when this snapshot holds nothing — no item, or a quantity that ran out. /// public bool IsEmpty => Item == null || Quantity <= 0; /// /// The empty snapshot, used to clear a slot. /// public static SlotContent Empty => new SlotContent { Item = null, Quantity = 0, Uses = -1 }; /// /// Builds a snapshot, normalising the uses of an item that does not track them to -1. /// public static SlotContent Of(ItemData item, int quantity, int uses) { if (item == null || quantity <= 0) return Empty; return new SlotContent { Item = item, Quantity = quantity, Uses = item.HasUses ? uses : -1 }; } } }