diff --git a/Assets/_DDD/_Scripts/GameData/DataSo.cs b/Assets/_DDD/_Scripts/GameData/DataSo.cs index 3fcd346bc..bff309916 100644 --- a/Assets/_DDD/_Scripts/GameData/DataSo.cs +++ b/Assets/_DDD/_Scripts/GameData/DataSo.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using UnityEngine; @@ -9,6 +10,8 @@ public class DataSo : ScriptableObject where T : IId { [FormerlySerializedAs("Datas")] [SerializeField] protected List _datas = new(); + private static readonly char[] _defaultSeparators = { ',', '|' }; + private void OnEnable() { Initialize(); @@ -42,5 +45,51 @@ public List GetDataList() } public int GetDataCount() => _datas.Count; + + public static List ParseDelimitedList(string input, List buffer = null, char[] separators = null, + bool distinct = false, bool toLower = false) + { + separators ??= _defaultSeparators; + + if (string.IsNullOrWhiteSpace(input)) + { + if (buffer == null) return new List(0); + buffer.Clear(); + return buffer; + } + + IEnumerable query = input + .Split(separators, StringSplitOptions.RemoveEmptyEntries) + .Select(s => s.Trim()) + .Where(s => !string.IsNullOrWhiteSpace(s)); + + // 소문자 정규화가 필요하면 먼저 적용 + if (toLower) + { + query = query.Select(s => s.ToLowerInvariant()); + } + + // Distinct + if (distinct) + { + query = query.Distinct(StringComparer.Ordinal); + } + + if (buffer == null) return query.ToList(); + + buffer.Clear(); + buffer.AddRange(query); + + return buffer; + } + + /// + /// 결과 리스트(target)에 직접 채워 넣습니다. (할당 최소화) + /// + public static void ParseDelimitedListInPlace(string input, List target, char[] separators = null, + bool distinct = false, bool toLower = false) + { + ParseDelimitedList(input, target, separators, distinct, toLower); + } } } \ No newline at end of file diff --git a/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/Classes/CustomerData.cs b/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/Classes/CustomerData.cs index 374627ced..a79054176 100644 --- a/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/Classes/CustomerData.cs +++ b/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/Classes/CustomerData.cs @@ -1,5 +1,8 @@ // using System; +using System.Collections.Generic; +using System.Linq; +using Sirenix.OdinInspector; using UnityEngine; namespace DDD @@ -31,5 +34,6 @@ public class CustomerData : IId [Tooltip("선호 맛들")] public string FavoriteTastes; + [ReadOnly] public List ValidFavoriteTastes = new(); } } diff --git a/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/Classes/CustomerDataSo.cs b/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/Classes/CustomerDataSo.cs index 996b9f9b6..ae0f0fb50 100644 --- a/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/Classes/CustomerDataSo.cs +++ b/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/Classes/CustomerDataSo.cs @@ -4,5 +4,16 @@ namespace DDD { [CreateAssetMenu(fileName = "CustomerDataSo", menuName = "GoogleSheet/CustomerDataSo")] - public class CustomerDataSo : DataSo { } + public class CustomerDataSo : DataSo + { + protected override void Initialize() + { + base.Initialize(); + + foreach (var customerData in _datas) + { + ParseDelimitedListInPlace(customerData.FavoriteTastes, customerData.ValidFavoriteTastes); + } + } + } } \ No newline at end of file diff --git a/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/Classes/CustomerPoolData.cs b/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/Classes/CustomerPoolData.cs index 881eb7199..090f2624f 100644 --- a/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/Classes/CustomerPoolData.cs +++ b/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/Classes/CustomerPoolData.cs @@ -1,5 +1,7 @@ // using System; +using System.Collections.Generic; +using Sirenix.OdinInspector; using UnityEngine; namespace DDD @@ -19,6 +21,7 @@ public class CustomerPoolData : IId /// 등장 손님들 [Tooltip("등장 손님들")] public string Customers; - + + [ReadOnly] public List ValidCustomers = new(); } } diff --git a/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/Classes/CustomerPoolDataSo.cs b/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/Classes/CustomerPoolDataSo.cs index 485d52178..076134084 100644 --- a/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/Classes/CustomerPoolDataSo.cs +++ b/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/Classes/CustomerPoolDataSo.cs @@ -4,5 +4,16 @@ namespace DDD { [CreateAssetMenu(fileName = "CustomerPoolDataSo", menuName = "GoogleSheet/CustomerPoolDataSo")] - public class CustomerPoolDataSo : DataSo { } + public class CustomerPoolDataSo : DataSo + { + protected override void Initialize() + { + base.Initialize(); + + foreach (var customerPoolData in _datas) + { + ParseDelimitedListInPlace(customerPoolData.Customers, customerPoolData.ValidCustomers); + } + } + } } \ No newline at end of file