using System.Collections.Generic; using System.Linq; using UnityEngine; namespace DDD { public class DataSo : ScriptableObject where T : IId { [SerializeField] protected List Datas = new(); public T GetDataById(string id) => Datas.FirstOrDefault(x => x.Id == id); public bool ContainsData(string id) => Datas.Any(x => x.Id == id); public bool TryGetDataById(string id, out T data) { data = Datas.FirstOrDefault(x => x.Id == id); return data != null; } public void SetDataList(List newList) { Datas = newList; } public List GetDataList() { return Datas; } public int GetDataCount() => Datas.Count; } }