Traveller/scripts/inventory/IItem.cs
Cold-Mint c1c3fce58a
Allows players to drag items onto the item container for quick storage.
允许玩家将物品拖到物品容器上以便快速入库。
2024-09-29 23:30:42 +08:00

106 lines
3.9 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Godot;
namespace ColdMint.scripts.inventory;
public interface IItem
{
/// <summary>
/// <para>The position of the item in the container</para>
/// <para>物品在容器内的位置</para>
/// </summary>
public int Index { get; set; }
/// <summary>
/// <para>ID of current item</para>
/// <para>当前物品的ID</para>
/// </summary>
string Id { get; set; }
/// <summary>
/// <para>Icon of current item</para>
/// <para>当前项目的图标</para>
/// </summary>
Texture2D Icon { get; }
/// <summary>
/// <para>Display name of current item</para>
/// <para>显示当前Item的名称</para>
/// </summary>
string Name { get; }
/// <summary>
/// <para>Description of current item, which may show in inventory</para>
/// <para>当前项目的描述</para>
/// </summary>
string? Description { get; }
/// <summary>
/// <para>Quantity</para>
/// <para>当前的数量</para>
/// </summary>
int Quantity { get; set; }
/// <summary>
/// <para>MaxItemQuantity</para>
/// <para>最大物品数量</para>
/// </summary>
int MaxQuantity { get; }
/// <summary>
/// <para>Check or not</para>
/// <para>是否选中</para>
/// </summary>
bool IsSelect { get; set; }
/// <summary>
/// <para>The container in which the item is located</para>
/// <para>物品所在的物品容器</para>
/// </summary>
IItemContainer? ItemContainer { get; set; }
/// <summary>
/// <para>Its own container of items</para>
/// <para>自身的物品容器</para>
/// </summary>
/// <remarks>
/// <para>Returns a non-null value if the item itself can hold other items</para>
/// <para>物品本身可容纳其他物品,则返回非空值</para>
/// </remarks>
public IItemContainer? SelfItemContainer { get; set; }
/// <summary>
/// <para>Calculate how many items can be merged with other items</para>
/// <para>计算当前物品可与其他物品合并多少个</para>
/// </summary>
/// <param name="other"></param>
/// <param name="unallocatedQuantity">
///<para>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.)</para>
///<para>尚未分配的数量在此方法并不会实际改变IItem的数量故您需要分配一个int型变量记录还有多少个物品尚未分配</para>
/// </param>
/// <returns>
///<para>Number of mergable numbers. 0 indicates that the number cannot be merged. Greater than 0 indicates that the number can be merged.</para>
///<para>可合并的数量0为不能合并大于0可合并。</para>
/// </returns>
int MergeableItemCount(IItem other, int unallocatedQuantity);
/// <summary>
/// <para>Create a new item instance</para>
/// <para>创建新的物品实例</para>
/// </summary>
/// <param name="number">
///<para>Quantity (pass in a value less than 0 to create an instance using all the quantities of built-in items)</para>
///<para>数量传入小于0的值使用内置物品的所有数量创建实例</para>
/// </param>
/// <returns>
///<para>Newly created item</para>
///<para>新创建的物品</para>
/// </returns>
IItem? CreateItem(int number);
/// <summary>
/// <para>Execute when current item is used <br/> e.g. when player clicks left mouse button with current item in hand</para>
/// <para>当前项被使用时执行 <br/> e.g. 当玩家用鼠标左键点击当前物品时</para>
/// </summary>
/// <param name="owner">Owner of current item, if any</param>
/// <param name="targetGlobalPosition">Target position, such as the position of the cursor when used by the player</param>
void Use(Node2D? owner, Vector2 targetGlobalPosition);
}