예제 #1
0
        public void FireGlobalEvent(EventInfoBase eventInfo)
        {
            System.Type trueEventInfoClass = eventInfo.GetType();

            if ((globalEventListeners == null || !globalEventListeners.ContainsKey(trueEventInfoClass)) &&
                (unityEventListeners == null || !unityEventListeners.ContainsKey(trueEventInfoClass)))
            {
                // No one is listening, we are done.
                return;
            }

            StartCoroutine(FireEventRoutine(eventInfo, trueEventInfoClass));
        }
        private IEnumerator FireUnityEvents(EventInfoBase eventInfo)
        {
            System.Type trueEventInfoClass = eventInfo.GetType();

            if (unityEventListeners == null)
            {
                yield break;
            }

            foreach (Dictionary <System.Type, List <UnityEventEventInfo> > eventListeners in unityEventListeners.Values)
            {
                if (!eventListeners.ContainsKey(trueEventInfoClass) || eventListeners[trueEventInfoClass] == null)
                {
                    // No one is listening, we are done.
                    continue;
                }

                foreach (UnityEventEventInfo el in eventListeners[trueEventInfoClass])
                {
                    el.Invoke(eventInfo);
                }
            }
            yield return(null);
        }
        private IEnumerator Fire(EventInfoBase eventInfo)
        {
            System.Type trueEventInfoClass = eventInfo.GetType();

            if (instanceEventListeners == null)
            {
                yield break;
            }

            foreach (Dictionary <System.Type, List <LocalEventListener> > eventListeners in instanceEventListeners.Values)
            {
                if (!eventListeners.ContainsKey(trueEventInfoClass) || eventListeners[trueEventInfoClass] == null)
                {
                    // No one is listening, we are done.
                    continue;
                }

                foreach (LocalEventListener el in eventListeners[trueEventInfoClass])
                {
                    el(eventInfo);
                }
            }
            yield return(null);
        }