using System.Collections.Generic;
using UnityEngine;
namespace Colosseum.Skills
{
///
/// 플레이어가 슬롯별로 사용할 스킬/젬 조합 프리셋입니다.
///
[CreateAssetMenu(fileName = "NewPlayerLoadoutPreset", menuName = "Colosseum/Player Loadout Preset")]
public class PlayerLoadoutPreset : ScriptableObject
{
private const int DefaultSlotCount = 7;
[Header("기본 정보")]
[SerializeField] private string presetName;
[TextArea(2, 4)]
[SerializeField] private string description;
[Header("슬롯 구성")]
[SerializeField] private SkillLoadoutEntry[] slots = new SkillLoadoutEntry[DefaultSlotCount];
public string PresetName => presetName;
public string Description => description;
public IReadOnlyList Slots => slots;
private void OnValidate()
{
EnsureSlotCapacity();
}
public void EnsureSlotCapacity(int slotCount = DefaultSlotCount)
{
slotCount = Mathf.Max(0, slotCount);
if (slots != null && slots.Length == slotCount)
{
EnsureGemSlots();
return;
}
SkillLoadoutEntry[] resized = new SkillLoadoutEntry[slotCount];
if (slots != null)
{
int copyCount = Mathf.Min(slots.Length, resized.Length);
for (int i = 0; i < copyCount; i++)
{
resized[i] = slots[i];
}
}
slots = resized;
EnsureGemSlots();
}
private void EnsureGemSlots()
{
if (slots == null)
return;
for (int i = 0; i < slots.Length; i++)
{
if (slots[i] == null)
slots[i] = new SkillLoadoutEntry();
slots[i].EnsureGemSlotCapacity();
}
}
}
}