using Godot; namespace ColdMint.scripts.inventory; public interface IItem { /// /// The position of the item in the container /// 物品在容器内的位置 /// public int Index { get; set; } /// /// ID of current item /// 当前物品的ID /// string Id { get; set; } /// /// ShowSelf /// 显示自身 /// void ShowSelf(); /// /// QueueFreeSelf /// 销毁自身 /// void QueueFreeSelf(); /// /// HideSelf /// 隐藏自身 /// void HideSelf(); /// /// 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; } /// /// Quantity /// 当前的数量 /// int Quantity { get; set; } /// /// MaxItemQuantity /// 最大物品数量 /// int MaxQuantity { get; } /// /// Check or not /// 是否选中 /// bool IsSelect { get; set; } /// /// The container in which the item is located /// 物品所在的物品容器 /// IItemContainer? ItemContainer { get; set; } /// /// Its own container of items /// 自身的物品容器 /// /// /// Returns a non-null value if the item itself can hold other items /// 物品本身可容纳其他物品,则返回非空值 /// public IItemContainer? SelfItemContainer { get; set; } /// /// Calculate how many items can be merged with other items /// 计算当前物品可与其他物品合并多少个 /// /// /// ///The amount yet to be allocated(This method doesn't actually change the number of iitems, so you need to allocate an int variable to keep track of how many items remain unallocated.) ///尚未分配的数量(在此方法并不会实际改变IItem的数量,故您需要分配一个int型变量记录还有多少个物品尚未分配) /// /// ///Number of mergable numbers. 0 indicates that the number cannot be merged. Greater than 0 indicates that the number can be merged. ///可合并的数量,0为不能合并,大于0可合并。 /// int MergeableItemCount(IItem other, int unallocatedQuantity); /// /// Create a new item instance /// 创建新的物品实例 /// /// ///Quantity (pass in a value less than 0 to create an instance using all the quantities of built-in items) ///数量(传入小于0的值,使用内置物品的所有数量创建实例) /// /// ///Newly created item ///新创建的物品 /// IItem? CreateItem(int number); /// /// 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); }