Files
zeling_v2/Assets/Scripts/Equipment/ToolCatalogSO.cs
2026-05-12 15:34:08 +08:00

26 lines
847 B
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 UnityEngine;
namespace BaseGames.Equipment
{
/// <summary>
/// 工具目录 SO。
/// 全局唯一资产Assets/Data/Equipment/ToolCatalog.asset
/// 通过 toolId 查找 ToolSO 引用。
/// 由 ToolSlotManager 在 OnLoad 时查询以恢复槽位工具引用。
/// </summary>
[CreateAssetMenu(menuName = "Equipment/ToolCatalog")]
public class ToolCatalogSO : ScriptableObject
{
[SerializeField] private ToolSO[] _tools;
/// <summary>按 toolId 查找工具,找不到返回 null。</summary>
public ToolSO Find(string toolId)
{
if (_tools == null || string.IsNullOrEmpty(toolId)) return null;
foreach (var tool in _tools)
if (tool != null && tool.toolId == toolId) return tool;
return null;
}
}
}