Files
Genesis_Unity/Assets/02_Scripts/UI/QuickSlot/QuickSlotController.cs

42 lines
1.0 KiB
C#

using UnityEngine;
public class QuickSlotController : MonoBehaviour
{
private QuickSlot[] _slots;
private void Awake()
{
_slots = GetComponentsInChildren<QuickSlot>(true);
}
private void Start()
{
foreach (var slot in _slots)
{
if (string.IsNullOrEmpty(slot.SlotName)) continue;
QuickSlot captured = slot;
GameManager.Instance.Level.BindSlotAction(captured.SlotName, (state) => captured.Execute(state));
}
}
// 외부(스킬창/SkillModule 등)에서 슬롯에 등록할 때 호출
public void RegisterEntry(string slotName, UseableEntry entry)
{
foreach (var slot in _slots)
{
if (slot.SlotName == slotName)
{
slot.SetEntry(entry);
return;
}
}
}
public QuickSlot GetSlot(string slotName)
{
foreach (var slot in _slots)
if (slot.SlotName == slotName) return slot;
return null;
}
}