using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class ObserverNotification { private Dictionary<string, object> data = new Dictionary<string, object>(); public NotificationType NotificationType { get; private set; } //Set a Notification type public ObserverNotification(NotificationType type) => NotificationType = type; //Class Builder with method chaining public ObserverNotification AddData(string key, object value) { data[key] = value; return this; } // Check if key exists public bool ContainsKey(string key) => data.ContainsKey(key); //Get Data public T GetData<T>(string key) { if (data.TryGetValue(key, out object value)) { return (T)value; } throw new ArgumentException($"Key '{key}' not found"); } public bool TryGetData<T>(string key, out T value) { value = default; if (data.ContainsKey(key) && data[key] is T) { value = (T)data[key]; return true; } return false; } } public enum NotificationType { UI, WorldUI, Dialogue, Sound, PathRequest, Destroy }