public static void Dispatch <T, U, V>(EventID eventId, T obj1, U obj2, V obj3) { BaseEvents baseEvents; if (Instance.eventDictionary.TryGetValue(eventId, out baseEvents)) { baseEvents.isLock = true; GenericEvents3 <T, U, V> impEvents = baseEvents as GenericEvents3 <T, U, V>; int count = impEvents.eventList.Count; for (int i = 0; i < count; ++i) { EventFun3 <T, U, V> dlgt = impEvents.eventList[i]; dlgt(obj1, obj2, obj3); } if (impEvents.deleteRequests.Count > 0) { for (int i = 0; i < impEvents.deleteRequests.Count; ++i) { impEvents.eventList.Remove(impEvents.deleteRequests[i]); } impEvents.deleteRequests.Clear(); } baseEvents.isLock = false; } }
public static void AddListener <T, U, V>(EventID eventId, EventFun3 <T, U, V> listener) { BaseEvents baseEvents = null; if (!Instance.eventDictionary.TryGetValue(eventId, out baseEvents)) { baseEvents = new GenericEvents3 <T, U, V>(); Instance.eventDictionary.Add(eventId, baseEvents); } ((GenericEvents3 <T, U, V>)baseEvents).eventList.Add(listener); }
public static void RemoveListener <T, U, V>(EventID eventId, EventFun3 <T, U, V> listener) { BaseEvents baseEvents; if (Instance.eventDictionary.TryGetValue(eventId, out baseEvents)) { GenericEvents3 <T, U, V> impEvents = baseEvents as GenericEvents3 <T, U, V>; if (!impEvents.isLock) { impEvents.eventList.Remove(listener); } else { impEvents.deleteRequests.Add(listener); } } }