public bool QueueEvent(SEGameEvent evt) { if (!delegates.ContainsKey(evt.GetType())) { Debug.LogWarning("EventManager: QueueEvent failed due to no listeners for event: " + evt.GetType()); return(false); } mEventQueue.Enqueue(evt); return(true); }
public void TriggerEvent(SEGameEvent seGameEvent) { EventDelegate del; if (delegates.TryGetValue(seGameEvent.GetType(), out del)) { del.Invoke(seGameEvent); // remove listeners which should only be called once foreach (EventDelegate k in delegates[seGameEvent.GetType()].GetInvocationList()) { if (onceLookups.ContainsKey(k)) { delegates[seGameEvent.GetType()] -= k; if (delegates[seGameEvent.GetType()] == null) { delegates.Remove(seGameEvent.GetType()); } delegateLookup.Remove(onceLookups[k]); onceLookups.Remove(k); } } } else { Debug.LogWarning("Event: " + seGameEvent.GetType() + " has no listeners"); } }