26 lines
847 B
C#
26 lines
847 B
C#
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;
|
||
}
|
||
}
|
||
}
|