using System; using System.Collections.Generic; using UnityEngine; namespace UnityAtoms { [Serializable] public abstract class ScriptableObjectList : ScriptableObject { [SerializeField] private List list = new List(); protected abstract GameEvent _Added { get; } protected abstract GameEvent _Removed { get; } [SerializeField] public VoidEvent Cleared; public int Count { get { return list.Count; } } public void Add(T item) { if (!list.Contains(item)) { list.Add(item); if (null != _Added) { _Added.Raise(item); } } } public void Remove(T item) { if (list.Contains(item)) { list.Remove(item); if (null != _Removed) { _Removed.Raise(item); } } } public void Clear() { list.Clear(); if (null != Cleared) { Cleared.Raise(); } } public T Get(int i) { return list[i]; } public List List { get { return list; } set { list = value; } } public T this[int index] { get { return list[index]; } set { list[index] = value; } } } }