2024-06-12 17:18:55 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
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>
|
|
|
|
|
/// <remarks>
|
|
|
|
|
///<para>Item containers can store items. Things like backpacks and Hotbars are containers with visual pages.</para>
|
|
|
|
|
///<para>物品容器可以储存物品。像背包和hotbar是具有可视化页面的容器。</para>
|
|
|
|
|
/// </remarks>
|
2024-09-22 08:51:42 +00:00
|
|
|
|
public interface IItemContainer : IEnumerable<IItem>
|
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-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-06-19 16:02:32 +00:00
|
|
|
|
public bool SupportSelect { get; set; }
|
2024-09-22 08:51:42 +00:00
|
|
|
|
|
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-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
|
|
|
|
}
|