Example #1
0
        public bool ProcessEvent(Event postedEvent)
        {
            bool   result    = false;
            string eventName = postedEvent._eventName;

            if (eventName == null)
            {
                return(false);
            }
            if (!_listeners.ContainsKey(eventName))
            {
                DebugLog.Print(DebugLevel.Warning, "Event \"", eventName, "\" triggered has no listeners!");
                postedEvent.eventStatus = EventStatus.Failed_No_Listeners;
            }
            else
            {
                if (_eventSequencer != null)
                {
                    _eventSequencer.ProcessEvent(postedEvent);
                }
                List <IEventListener> list = _listeners[eventName];
                int count = list.Count;
                for (int i = 0; i < count; i++)
                {
                    IEventListener eventListener = list[i];
                    if (IsNullOrDestroyed(eventListener))
                    {
                        continue;
                    }
                    if (eventListener.GetEventListeners(eventName, eventListeners))
                    {
                        Event @event = ApplyOverrideEventActions(eventListeners, postedEvent, overrideEvent);
                        if (@event != null)
                        {
                            postedEvent.eventStatus = eventListener.Process(@event);
                        }
                    }
                    else
                    {
                        postedEvent.eventStatus = eventListener.Process(postedEvent);
                    }
                    if (Application.isEditor && postedEvent.EventAction == EventAction.PlaySound)
                    {
                        AddActiveEvent(postedEvent, eventListener as Component);
                    }
                }
                result = ((postedEvent.eventStatus == EventStatus.Handled || postedEvent.eventStatus == EventStatus.Handled_Virtualized) ? true : false);
            }
            LogEvent(postedEvent);
            return(result);
        }
Example #2
0
        private bool ProcessEventID(Event postedEvent)
        {
            bool result  = false;
            int  eventID = postedEvent._eventID;

            if (!_listenersHashed.ContainsKey(eventID))
            {
                DebugLog.Print("Event \"" + eventID + "\" triggered has no listeners!", DebugLevel.Warning);
                postedEvent.eventStatus = EventStatus.Failed_No_Listeners;
            }
            else
            {
                if (_eventSequencer != null)
                {
                    _eventSequencer.ProcessEvent(postedEvent);
                }
                List <IEventListener> list = _listenersHashed[eventID];
                int count = list.Count;
                for (int i = 0; i < count; i++)
                {
                    IEventListener eventListener = list[i];
                    if (IsNullOrDestroyed(eventListener))
                    {
                        continue;
                    }
                    if (eventListener.GetEventListeners(eventID, eventListeners))
                    {
                        Event @event = ApplyOverrideEventActions(eventListeners, postedEvent, overrideEvent);
                        if (@event != null)
                        {
                            postedEvent.eventStatus = eventListener.Process(@event);
                        }
                    }
                    else
                    {
                        postedEvent.eventStatus = eventListener.Process(postedEvent);
                    }
                }
                result = ((postedEvent.eventStatus == EventStatus.Handled) ? true : false);
            }
            LogEvent(postedEvent);
            return(result);
        }