Files
2026-06-05 18:41:33 +08:00

52 lines
2.0 KiB
C#
Raw Permalink 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 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("本地化 KeyItems 表)。")]
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));
}
}
}