예제 #1
0
    /// <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.");
        }
    }
예제 #2
0
    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);
    }