using System; using Godot; namespace ColdMint.scripts.item; public interface IItemStack { /// /// ID of items inside current stack /// string Id { get; } /// /// Max number of current stack /// int MaxQuantity { get; } /// /// Quantity of current stack /// int Quantity { get; } /// /// Icon of current item /// Texture2D Icon { get; } /// /// Display name of current item /// string Name { get; } /// /// Description of current item, which may show in inventory /// string? Description { get; } /// /// Removes the specified number of items from current item stack /// 在当前物品堆移除指定数量的物品 /// /// /// /// The remaining number, if the number of items in the current item stack is less than the specified number. Otherwise,0 /// 若物品槽内物品少于指定的数量,返回相差的数量。否则返回0 /// public int RemoveItem(int number); /// /// Create a new ItemStack with the given item as the first item /// public static IItemStack FromItem(IItem_New item) => ItemTypeManager.MaxStackQuantityOf(item.Id) switch { 1 => new SingleItemStack(item), > 1 => throw new NotImplementedException(), var other => throw new ArgumentException($"item {item} of type '{item.Id}' has unexpected max stack quantity {other}") }; }