2025-07-15 04:01:35 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
namespace DDD
|
|
|
|
{
|
|
|
|
public class DataSo<T> : ScriptableObject where T : IId
|
|
|
|
{
|
|
|
|
[SerializeField]
|
|
|
|
protected List<T> Datas = new();
|
|
|
|
|
|
|
|
public T GetDataById(string id) => Datas.FirstOrDefault(x => x.Id == id);
|
2025-07-25 07:58:53 +00:00
|
|
|
|
2025-08-06 02:45:08 +00:00
|
|
|
public bool ContainsData(string id) => Datas.Any(x => x.Id == id);
|
|
|
|
|
2025-07-25 07:58:53 +00:00
|
|
|
public bool TryGetDataById(string id, out T data)
|
|
|
|
{
|
|
|
|
data = Datas.FirstOrDefault(x => x.Id == id);
|
|
|
|
return data != null;
|
|
|
|
}
|
2025-07-15 04:01:35 +00:00
|
|
|
|
|
|
|
public void SetDataList(List<T> newList)
|
|
|
|
{
|
|
|
|
Datas = newList;
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<T> GetDataList()
|
|
|
|
{
|
|
|
|
return Datas;
|
|
|
|
}
|
2025-07-21 10:51:11 +00:00
|
|
|
|
|
|
|
public int GetDataCount() => Datas.Count;
|
2025-07-15 04:01:35 +00:00
|
|
|
}
|
|
|
|
}
|