using System.Collections.Generic;
namespace BaseGames.Inventory
{
///
/// 背包管理服务接口。UI 层(ItemInventoryPanel)通过此接口读取道具状态,
/// 与 具体实现解耦,便于独立测试和跨场景复用。
/// 设计对照 。
///
public interface IInventoryService
{
/// 当前持有的全部道具条目(只读视图,含数量)。
IReadOnlyList Items { get; }
/// 持有道具种类数(不含数量)。
int DistinctCount { get; }
/// 查询指定道具的持有数量;未持有返回 0。
int GetCount(string itemId);
/// 是否持有指定道具(数量 ≥ 1)。
bool Has(string itemId);
///
/// 增加道具。stackable 道具按 amount 叠加(受 maxStack 限制);
/// 非 stackable 恒为 1。返回实际新增数量(0 表示已满或道具无效)。
///
int AddItem(string itemId, int amount = 1);
/// 移除道具(如消耗品使用 / 剧情消耗)。返回实际移除数量。
int RemoveItem(string itemId, int amount = 1);
/// 清除某道具的"新获得"未读标记(玩家查看背包后调用)。
void MarkSeen(string itemId);
/// 道具集合变化(增删 / 数量变更)时触发;UI 据此刷新。
event System.Action OnInventoryChanged;
}
/// 背包条目:道具数据 + 当前数量 + 未读标记。
public readonly struct InventoryEntry
{
public readonly ItemSO Item;
public readonly int Count;
public readonly bool IsNew;
public InventoryEntry(ItemSO item, int count, bool isNew)
{
Item = item;
Count = count;
IsNew = isNew;
}
}
}