public bool QueueEvent(iEvent @event) { if (!_delegates.ContainsKey(@event.GetType())) { // If there are no listeners assigned to the event trying to be queued, // do not queue the event. return(false); } _eventQueue.Enqueue(@event); return(true); }
/// <summary> /// Processes the events queued up. /// </summary> /// <param name="@event"></param> private void ProcessEvent(iEvent @event) { EventDelegate @delegate; // Double check that there are actually listeners / delegates for this event if (_delegates.TryGetValue(@event.GetType(), out @delegate)) { // If there was one, it's now stored in delegate and we can invoke the delegate // associated with this event we pass in. @delegate.Invoke(@event); } else { // There were no listeners. Debug.LogWarning("Event : " + @event.GetType() + " was found to have no listeners."); } }
void Update() { // Used to keep track of the time between processing events float timer = 0.0f; while (_eventQueue.Count > 0) { iEvent @event = _eventQueue.Dequeue() as iEvent; if (timer > queueWaitTime && waitTime) { Debug.Log("EventManager tried to dequeue " + @event.ToString() + " stopped after : " + timer.ToString() + " seconds."); return; } // Inform all the listeners / delegates that the event has been // queued. ProcessEvent(@event); //Check time timer += Time.deltaTime; } }
public void SetEvent(iEvent ev) { evt = ev; }
public void SetEvent(iEvent ev) { evts.Add(ev); }