Files
YachtDice/Assets/Scripts/Dice/DiceCatalog.cs
T
2026-03-02 05:43:11 +07:00

33 lines
889 B
C#

using System.Collections.Generic;
using UnityEngine;
namespace YachtDice.Dice
{
[CreateAssetMenu(fileName = "DiceCatalog", menuName = "YachtDice/Dice/Catalog")]
public class DiceCatalog : ScriptableObject
{
[SerializeField] private List<DiceDefinition> dice = new();
public IReadOnlyList<DiceDefinition> All => dice;
public DiceDefinition FindById(string id)
{
for (int i = 0; i < dice.Count; i++)
{
if (dice[i] != null && dice[i].Id == id)
return dice[i];
}
return null;
}
#if UNITY_EDITOR
public static DiceCatalog CreateForTest(List<DiceDefinition> defs)
{
var catalog = CreateInstance<DiceCatalog>();
catalog.dice = defs ?? new List<DiceDefinition>();
return catalog;
}
#endif
}
}