using System; using System.Collections.Generic; using ColdMint.scripts.map.events; using Godot; namespace ColdMint.scripts.inventory; /// /// item container /// 物品容器 /// /// ///Item containers can store items. Things like backpacks and Hotbars are containers with visual pages. ///物品容器可以储存物品。像背包和hotbar是具有可视化页面的容器。 /// public interface IItemContainer : IEnumerable { /// /// This event is triggered when the selected item slot changes /// 当选中的物品槽改变时,触发此事件 /// Action? SelectedItemSlotChangeEvent { get; set; } /// /// Can the specified item be added to the container? /// 指定的物品是否可添加到容器内? /// /// /// bool CanAddItem(IItem item); /// /// Implement methods for adding items /// 实现添加物品的方法 /// /// /// bool AddItem(IItem item); /// /// Whether this item container supports checking /// 此物品容器是否支持选中 /// public bool SupportSelect { get; set; } /// /// Gets the selected location /// 获取选中的位置 /// /// int GetSelectIndex(); /// /// Gets the currently selected node /// 获取当前选中的节点 /// /// ItemSlotNode? GetSelectItemSlotNode(); /// /// Removes an item from the inventory at the currently selected location /// 移除当前选中位置物品栏内的物品 /// /// /// Quantity to be removed, inputs below zero represent all items /// 要删除的数量,小于0的输入代表全部物品 /// /// /// The remaining number, if the number of items in the current item stack is less than the specified number. Otherwise,0 /// 若物品槽内物品少于指定的数量,返回相差的数量。否则返回0 /// int RemoveItemFromItemSlotBySelectIndex(int number); /// /// Gets the number of item slots /// 获取物品槽的数量 /// /// int GetItemSlotCount(); /// /// Gets the item slot for the specified location /// 获取指定位置的物品槽 /// /// /// ItemSlotNode? GetItemSlotNode(int index); /// /// Gets the item slot for the specified location, equals to /// 获取指定位置的物品槽,等同于 /// /// /// ItemSlotNode? this[int index] => GetItemSlotNode(index); /// /// Removes an item from the item slot in the specified location /// 在指定位置的物品槽内移除物品 /// /// /// /// Quantity to be removed, inputs below zero represent all items /// 要删除的数量,小于0的输入代表全部物品 /// /// /// The remaining number, if the number of items in the current item stack is less than the specified number. Otherwise,0 /// 若物品槽内物品少于指定的数量,返回相差的数量。否则返回0 /// int RemoveItemFromItemSlot(int itemSlotIndex, int number); /// /// Based on the given item, match the item slots where it can be added to /// 根据给定的物品,匹配可放置它的物品槽 /// /// /// /// Return null if there is no slot to place the item in /// 若没有槽可放置此物品,则返回null /// ItemSlotNode? Match(IItem item); /// /// AddItemSlot /// 添加物品槽 /// /// ItemSlotNode? AddItemSlot(Node rootNode); /// /// SelectTheNextItemSlot /// 选择下一个物品槽 /// void SelectTheNextItemSlot(); /// /// SelectThePreviousItemSlot /// 选择上一个物品槽 /// void SelectThePreviousItemSlot(); /// /// 选择物品槽 /// SelectItemSlot /// /// void SelectItemSlot(int newSelectIndex); }