52 lines
2.0 KiB
C#
52 lines
2.0 KiB
C#
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
using BaseGames.Localization;
|
||
|
||
namespace BaseGames.Inventory
|
||
{
|
||
/// <summary>
|
||
/// 道具数据 SO(背包系统)。
|
||
/// 资产路径建议: Assets/_Game/Data/Inventory/Items/Item_{Name}.asset
|
||
/// 命名/本地化约定与 <see cref="BaseGames.Equipment.CharmSO"/> 保持一致(Items 表)。
|
||
/// </summary>
|
||
[CreateAssetMenu(menuName = "BaseGames/Inventory/Item")]
|
||
public class ItemSO : ScriptableObject, ILocalizableAsset
|
||
{
|
||
[Header("Identity")]
|
||
[Tooltip("全局唯一 ID,如 \"Item_AncientKey\"。与拾取广播的 itemId 对应。")]
|
||
public string itemId;
|
||
[Tooltip("本地化 Key(Items 表)。")]
|
||
public string displayNameKey;
|
||
[TextArea(2, 4)]
|
||
public string descriptionKey;
|
||
|
||
[Header("Classification")]
|
||
public ItemCategory category;
|
||
|
||
[Header("Visual")]
|
||
public Sprite icon;
|
||
|
||
[Header("Stacking")]
|
||
[Tooltip("可叠加(消耗品等)。false 时同 ID 只记 1 份。")]
|
||
public bool stackable;
|
||
[Tooltip("叠加上限(stackable=true 时生效,<=0 表示不限)。")]
|
||
public int maxStack = 99;
|
||
|
||
[Header("Map Reveal")]
|
||
[Tooltip("category=MapShard 时,拾取后揭示的区域 ID(对应 MapManager 区域)。")]
|
||
public string revealRegionId;
|
||
|
||
[Header("Lore")]
|
||
[Tooltip("是否唯一(剧情关键 / 一次性)。")]
|
||
public bool isUnique;
|
||
|
||
public IEnumerable<LocalizationKeyRef> GetLocalizationKeys()
|
||
{
|
||
if (!string.IsNullOrEmpty(displayNameKey))
|
||
yield return new LocalizationKeyRef(displayNameKey, LocalizationTable.Items, nameof(displayNameKey));
|
||
if (!string.IsNullOrEmpty(descriptionKey))
|
||
yield return new LocalizationKeyRef(descriptionKey, LocalizationTable.Items, nameof(descriptionKey));
|
||
}
|
||
}
|
||
}
|