2024-06-12 17:18:55 +00:00
using System ;
2024-06-19 16:02:32 +00:00
using ColdMint.scripts.map.events ;
2024-06-11 18:22:04 +00:00
namespace ColdMint.scripts.inventory ;
2024-05-06 10:59:39 +00:00
/// <summary>
/// <para>item container</para>
/// <para>物品容器</para>
/// </summary>
2024-09-27 12:53:04 +00:00
public interface IItemContainer
2024-05-06 10:59:39 +00:00
{
2024-06-19 16:02:32 +00:00
/// <summary>
2024-09-22 08:51:42 +00:00
/// <para>This event is triggered when the selected item changes</para>
/// <para>当选中的物品改变时,触发此事件</para>
2024-06-19 16:02:32 +00:00
/// </summary>
2024-09-22 08:51:42 +00:00
Action < SelectedItemChangeEvent > ? SelectedItemChangeEvent { get ; set ; }
2024-06-19 16:02:32 +00:00
2024-09-23 13:03:39 +00:00
/// <summary>
/// <para>This event is triggered when the item's data changes, such as the number increases, decreases, or new items are added to the container</para>
/// <para>当物品的数据发生改变时,例如数量增加,减少,或者新物品被添加到容器内触发此事件</para>
/// </summary>
Action < ItemDataChangeEvent > ? ItemDataChangeEvent { get ; set ; }
2024-05-06 10:59:39 +00:00
/// <summary>
/// <para>Can the specified item be added to the container?</para>
/// <para>指定的物品是否可添加到容器内?</para>
/// </summary>
/// <param name="item"></param>
/// <returns></returns>
2024-06-12 19:07:55 +00:00
bool CanAddItem ( IItem item ) ;
2024-05-06 10:59:39 +00:00
/// <summary>
/// <para>Implement methods for adding items</para>
/// <para>实现添加物品的方法</para>
/// </summary>
/// <param name="item"></param>
2024-09-22 08:51:42 +00:00
/// <returns>
///<para>How many items were successfully added. The addition failed, and 0 was returned.</para>
///<para>有多少个物品被成功添加了。添加失败, 返回0</para>
/// </returns>
int AddItem ( IItem item ) ;
2024-06-19 16:02:32 +00:00
2024-06-19 14:33:00 +00:00
/// <summary>
/// <para>Whether this item container supports checking</para>
/// <para>此物品容器是否支持选中</para>
/// </summary>
2024-09-29 14:12:54 +00:00
bool SupportSelect { get ; set ; }
/// <summary>
/// <para>Whether this item container supports items that CanContainItems=true, such as backpacks</para>
/// <para>此物品容器是否支持容纳CanContainItems=true的物品, 例如背包</para>
/// </summary>
bool CanContainContainer { get ; set ; }
2024-09-22 08:51:42 +00:00
2024-09-23 15:17:57 +00:00
/// <summary>
/// <para>Gets a placeholder object</para>
/// <para>获取占位符对象</para>
/// </summary>
2024-09-28 14:59:25 +00:00
/// <param name="index">
///<para>index</para>
///<para>占位符代替的索引</para>
/// </param>
2024-09-23 15:17:57 +00:00
/// <returns></returns>
2024-09-28 14:59:25 +00:00
IItem GetPlaceHolderItem ( int index ) ;
2024-06-12 17:18:55 +00:00
2024-06-06 14:43:07 +00:00
/// <summary>
/// <para>Gets the selected location</para>
/// <para>获取选中的位置</para>
/// </summary>
/// <returns></returns>
int GetSelectIndex ( ) ;
2024-05-06 10:59:39 +00:00
/// <summary>
2024-09-22 08:51:42 +00:00
/// <para>Gets the currently selected item</para>
/// <para>获取当前选中的物品</para>
2024-05-06 10:59:39 +00:00
/// </summary>
/// <returns></returns>
2024-09-22 08:51:42 +00:00
IItem ? GetSelectItem ( ) ;
2024-05-06 10:59:39 +00:00
2024-06-06 14:43:07 +00:00
/// <summary>
2024-09-22 08:51:42 +00:00
/// <para>Gets the item in the specified location</para>
/// <para>获取指定位置的物品</para>
2024-06-06 14:43:07 +00:00
/// </summary>
/// <param name="index"></param>
/// <returns></returns>
2024-09-22 08:51:42 +00:00
IItem ? GetItem ( int index ) ;
2024-06-06 14:43:07 +00:00
2024-09-27 15:24:22 +00:00
/// <summary>
/// <para>ReplaceItem</para>
/// <para>替换物品</para>
/// </summary>
/// <remarks>
///<para>Even if the item corresponding to the index is null, it can be successfully replaced.</para>
///<para>即使索引对应的物品为null, 也可以成功的替换。</para>
/// </remarks>
/// <param name="index"></param>
/// <param name="item"></param>
/// <returns></returns>
bool ReplaceItem ( int index , IItem item ) ;
2024-09-29 14:12:54 +00:00
/// <summary>
/// <para>Whether items are replaceable</para>
/// <para>是否可替换物品</para>
/// </summary>
/// <param name="index"></param>
/// <param name="item"></param>
/// <returns></returns>
bool CanReplaceItem ( int index , IItem item ) ;
2024-09-27 15:24:22 +00:00
2024-09-28 14:59:25 +00:00
/// <summary>
/// <para>ClearItem</para>
/// <para>清理物品</para>
/// </summary>
/// <param name="index"></param>
/// <returns></returns>
bool ClearItem ( int index ) ;
2024-09-29 14:12:54 +00:00
2024-06-13 02:43:54 +00:00
/// <summary>
2024-09-22 08:51:42 +00:00
/// <para>Gets the item in the specified location, equivalent to <see cref="GetItem"/></para>
/// <para>获取指定位置的物品,等同于<see cref="GetItem"/></para>
2024-06-13 02:43:54 +00:00
/// </summary>
/// <param name="index"></param>
/// <returns></returns>
2024-09-22 08:51:42 +00:00
IItem ? this [ int index ] = > GetItem ( index ) ;
2024-06-13 02:43:54 +00:00
2024-06-06 14:43:07 +00:00
/// <summary>
2024-09-22 08:51:42 +00:00
/// <para>Removes the item from the currently selected location</para>
/// <para>移除当前选中位置的物品</para>
2024-06-06 14:43:07 +00:00
/// </summary>
2024-06-12 17:18:55 +00:00
/// <param name="number">
/// <para>Quantity to be removed, inputs below zero represent all items</para>
/// <para>要删除的数量, 小于0的输入代表全部物品</para>
/// </param>
/// <returns>
2024-09-22 08:51:42 +00:00
///<para>How many items were actually removed</para>
///<para>实际移除了多少个物品</para>
2024-06-12 17:18:55 +00:00
/// </returns>
2024-09-22 08:51:42 +00:00
int RemoveSelectItem ( int number ) ;
2024-06-06 14:43:07 +00:00
2024-05-06 10:59:39 +00:00
/// <summary>
2024-09-22 08:51:42 +00:00
/// <para>Deduct the number of items in the specified location</para>
/// <para>扣除指定位置的物品数量</para>
2024-05-06 10:59:39 +00:00
/// </summary>
2024-09-22 08:51:42 +00:00
/// <param name="itemIndex"></param>
/// <param name="number">
/// <para>Quantity to be removed, inputs below zero represent all items</para>
/// <para>要删除的数量, 小于0的输入代表全部物品</para>
/// </param>
2024-05-06 10:59:39 +00:00
/// <returns>
2024-09-22 08:51:42 +00:00
///<para>How many items were actually removed</para>
///<para>实际移除了多少个物品</para>
2024-06-12 17:18:55 +00:00
/// </returns>
2024-09-22 08:51:42 +00:00
int RemoveItem ( int itemIndex , int number ) ;
2024-06-12 17:18:55 +00:00
2024-09-22 08:51:42 +00:00
/// <summary>
/// <para>Gets the used capacity of the item container</para>
/// <para>获取物品容器已使用的容量</para>
/// </summary>
/// <returns></returns>
int GetUsedCapacity ( ) ;
2024-06-12 13:33:29 +00:00
/// <summary>
2024-09-22 08:51:42 +00:00
/// <para>Gets the total capacity of the item container</para>
/// <para>获取物品容器的总容量</para>
2024-06-12 13:33:29 +00:00
/// </summary>
2024-09-22 08:51:42 +00:00
/// <returns></returns>
int GetTotalCapacity ( ) ;
2024-06-12 13:33:29 +00:00
/// <summary>
2024-09-22 08:51:42 +00:00
/// <para>Select the next item</para>
/// <para>选择下一个物品</para>
2024-06-12 13:33:29 +00:00
/// </summary>
2024-09-22 08:51:42 +00:00
void SelectNextItem ( ) ;
2024-06-12 13:33:29 +00:00
/// <summary>
2024-09-22 08:51:42 +00:00
/// <para>Select the previous item</para>
/// <para>选择上一个物品</para>
2024-06-12 13:33:29 +00:00
/// </summary>
2024-09-22 08:51:42 +00:00
void SelectPreviousItem ( ) ;
2024-06-12 13:33:29 +00:00
/// <summary>
2024-09-22 08:51:42 +00:00
/// <para>选择物品</para>
/// <para>Select item</para>
2024-06-12 13:33:29 +00:00
/// </summary>
2024-09-22 08:51:42 +00:00
/// <param name="index"></param>
void SelectItem ( int index ) ;
2024-05-06 10:59:39 +00:00
}