using ColdMint.scripts.item.itemStacks; using Godot; namespace ColdMint.scripts.item; public interface IItem { /// /// ID of current item /// 当前项目的ID /// string Id { get; } /// /// Icon of current item /// 当前项目的图标 /// Texture2D Icon { get; } /// /// Display name of current item /// 显示当前Item的名称 /// string Name { get; } /// /// Description of current item, which may show in inventory /// 当前项目的描述 /// string? Description { get; } /// /// /// Whether the current item can be put into item containers like packsack.
/// This attribute is usually set to false for items of the backpack class to avoid pack nesting. ///
/// 当前物品是否可以放入背包类的容器中。一般将背包类物品的该属性设为false来避免背包嵌套。 ///
bool CanPutInPack { get; } /// /// Execute when current item is used
e.g. when player clicks left mouse button with current item in hand
/// 当前项被使用时执行
e.g. 当玩家用鼠标左键点击当前物品时
///
/// Owner of current item, if any /// Target position, such as the position of the cursor when used by the player void Use(Node2D? owner, Vector2 targetGlobalPosition); /// /// Execute when current item be removed from game. /// 当前物品从游戏中移除时执行。 /// void Destroy(); /// /// Return true if this item can be stacked with the given item in one stack /// 若该物品是否能与给定物品堆叠在同一个物品堆上,返回true /// /// /// /// ! Note in the implementation: the correspondence of this predicate must be an equivalence relation over the full set of stackable items /// (i.e., be able to derive a division into the full set of stackable items).
/// Or if the item is not stackable, make it always return false. ///
/// /// !实现时注意:该谓词的对应关系必须是在全部可堆叠的物品集合上的等价关系(即能导出一个对可堆叠物品全集的划分)。
/// 或如果该物品不可堆叠,令其永远返回false。
///
/// /// If it is necessary to implement special stacking relationships (e.g. containers that can be stacked to hold items), /// customize the special type, implement the special stacking determination in it by overriding , /// and override the method so that it returns an instance of that custom ItemStack. /// /// /// 如果有必要实现特殊的堆叠关系(如可以用堆叠来收纳物品的容器),请自定义特殊的类型,在其中重写以实现特殊的堆叠判定, /// 并重写方法使其返回该自定义ItemStack实例。 /// ///
bool CanStackWith(IItem item); /// /// If this item need a special stack type, return the special item stack instance that contains the item. If else, just leave this null. /// 如果该项目需要特殊的物品堆类型,重写此方法来返回包含该物品的特殊物品堆实例。否则,保留原本的null返回值。 /// /// IItemStack? SpecialStack() => null; }