//Inserts the event into the current queue. public bool QueueEvent(GameEventBase evt) { if (!delegates.ContainsKey(evt.GetType())) { //Debug.LogWarning("EventManager: QueueEvent failed due to no listeners for event: " + evt.GetType()); return(false); } m_eventQueue.Enqueue(evt); return(true); }
public void TriggerEvent(GameEventBase e) { EventDelegate del; if (delegates.TryGetValue(e.GetType(), out del)) { del.Invoke(e); // remove listeners which should only be called once foreach (EventDelegate k in delegates[e.GetType()].GetInvocationList()) { if (onceLookups.ContainsKey(k)) { delegates[e.GetType()] -= k; if (delegates[e.GetType()] == null) { delegates.Remove(e.GetType()); } delegateLookup.Remove(onceLookups[k]); onceLookups.Remove(k); } } } else { Debug.LogWarning("Event: " + e.GetType() + " has no listeners"); } }
private static SodaEventBase GetOnRaiseWithParameterEvent(GameEventBase gameEventBaseTarget) { var flags = System.Reflection.BindingFlags.GetField | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public; var field = gameEventBaseTarget.GetType().GetField("onRaiseWithParameter", flags); if (field != null) { return((SodaEventBase)field.GetValue(gameEventBaseTarget)); } return(null); }