using System.Collections.Generic; using Sirenix.OdinInspector; using SLSUtilities.General; using UnityEngine; namespace Cielonos.MainGame { public partial class InfoTransistor : Singleton { public HashSet flags = new HashSet(); public Dictionary intInfo = new Dictionary(); public Dictionary stringInfo = new Dictionary(); protected override void Awake() { Initialize(true); } } public partial class InfoTransistor { public static void SetInfo(string key) { Instance.flags.Add(key); } public static void SetInfo(string key, T value) { if (typeof(T) == typeof(int)) { Instance.intInfo[key] = (int)(object)value; } else if (typeof(T) == typeof(string)) { Instance.stringInfo[key] = (string)(object)value; } else { Debug.LogError($"Unsupported type {typeof(T)} for InfoTransistor."); } } public static T GetInfo(string key) { if (typeof(T) == typeof(int)) { return Instance.intInfo.TryGetValue(key, out int value) ? (T)(object)value : default; } if (typeof(T) == typeof(string)) { return Instance.stringInfo.TryGetValue(key, out string value) ? (T)(object)value : default; } if(typeof(T) == typeof(bool)) { return (T)(object)Instance.flags.Contains(key); } Debug.LogError($"Unsupported type {typeof(T)} for InfoTransistor."); return default; } } }