using System; using System.Collections; using System.Collections.Generic; using ColdMint.scripts.item; 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 { /// /// Can the specified item be added to the container? /// 指定的物品是否可添加到容器内? /// /// /// bool CanAddItem(IItem item); /// /// Implement methods for adding items /// 实现添加物品的方法 /// /// /// bool AddItem(IItem item); /// /// Add an stack of items to this container /// 向当前容器中存入一堆物品 /// /// /// /// If the source item stack is empty after the operation is completed /// 操作完成后,源物品堆是否被取空 /// bool AddItemStack(IItemStack itemStack); /// /// Gets the selected location /// 获取选中的位置 /// /// int GetSelectIndex(); /// /// Gets the currently selected node /// 获取当前选中的节点 /// /// ItemSlotNode? GetSelectItemSlotNode(); /// /// If present, remove an item from the slot at the currently selected location and return it. /// 如果存在,移除当前选中位置的槽位中的一个物品并将其返回 /// /// IItem? PickItemFromItemSlotBySelectIndex(); /// /// Remove the specified number of items from the item slot at the currently selected location, and return them as a new item stack /// 取出当前选中位置的物品槽中指定数量的物品,并作为新的物品堆返回 /// /// /// Quantity to be taken out, inputs below zero represent all items /// 要取出的数量,小于0的输入代表全部物品 /// /// IItemStack? PickItemsFromItemSlotBySelectIndex( int value); /// /// 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 /// /// /// Will remove the removed items from the game, if that is not the intent, consider using the /// 会将移除的物品从游戏中删除,如果目的并非如此,请考虑使用 /// int RemoveItemFromItemSlotBySelectIndex(int number); /// /// Gets the number of item slots /// 获取物品槽的数量 /// /// int GetItemSlotCount(); /// /// Gets the item slot for the specified location /// 获取指定位置的物品槽 /// /// /// ItemSlotNode? GetItemSlotNode(int index); /// /// If present, remove an item from the slot in the specified location and return it. /// 如果存在,移除指定位置的槽位中的一个物品并将其返回 /// /// IItem? PickItemFromItemSlot(int itemSlotIndex); /// /// Remove the specified number of items from the item slot in the specified location, and return them as a new item stack /// 取出指定位置的物品槽中指定数量的物品,并作为新的物品堆返回 /// /// /// /// Quantity to be taken out, inputs below zero represent all items /// 要取出的数量,小于0的输入代表全部物品 /// /// IItemStack? PickItemsFromItemSlot(int itemSlotIndex, int value); /// /// 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 /// /// /// Will remove the removed items from the game, if that is not the intent, consider using the /// 会将移除的物品从游戏中删除,如果目的并非如此,请考虑使用 /// 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); /// /// Based on the given item stack, match the item slots where it can be added to /// 根据给定的物品堆,匹配可放置它的物品槽 /// /// /// /// Return null if there is no slot to add the item slot in /// 若没有槽可放置此物品堆,则返回null /// ItemSlotNode? Match(IItemStack stack); /// /// Match the first item slot that has item stack that satisfies the predicate /// 匹配首个拥有满足指定条件的物品堆的物品槽 /// /// /// /// Return null if there is no slot satisfies the predicate /// 若没有满足条件的槽位,返回null /// /// ItemSlotNode? Match(Func predicate); /// /// Match all item slots that has item stack that satisfies the predicate /// 匹配所有拥有满足指定条件的物品堆的物品槽 /// /// /// /// IEnumerable for the item slot matched to, will be empty if there's no slot satisfies the predicate /// 包含匹配到的槽位的IEnumerable,当没有满足条件的槽位时为空 /// /// IEnumerable MatchAll(Func predicate); /// /// AddItemSlot /// 添加物品槽 /// /// /// void AddItemSlot(Node rootNode, int index); /// /// SelectTheNextItemSlot /// 选择下一个物品槽 /// void SelectTheNextItemSlot(); /// /// SelectThePreviousItemSlot /// 选择上一个物品槽 /// void SelectThePreviousItemSlot(); /// /// 选择物品槽 /// SelectItemSlot /// /// void SelectItemSlot(int newSelectIndex); }