多轮审查和修复
This commit is contained in:
25
Assets/Scripts/Equipment/ToolCatalogSO.cs
Normal file
25
Assets/Scripts/Equipment/ToolCatalogSO.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user