34 lines
859 B
C#
34 lines
859 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)
|
|
{
|
|
foreach (var t in dice)
|
|
{
|
|
if (t != null && t.Id == id)
|
|
return t;
|
|
}
|
|
|
|
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
|
|
}
|
|
}
|