using System; using System.Collections.Generic; using ObjectEventAction = System.Action; namespace ET { public class EventDispatcher { private Dictionary> _list = new(); public EventDispatcher() { } public ObjectEventAction AddListener(ObjectEventAction action) { List acts; if (_list.TryGetValue(typeof(T), out acts)) { acts.Add(action); } else { _list.Add(typeof(T), new List { action }); } return action; } public void Notfify(CommonAI.Zone.ObjectEvent ev) { List acts; if (_list.TryGetValue(ev.GetType(), out acts)) { foreach (var act in acts) { act.Invoke(ev); } } } } }