Пример #1
0
        /**
         * 先添加的会先收到消息
         */
        public void dispatchEvent(EventId eid, object data = null)
        {
            if (!allListeners.ContainsKey(eid))
            {
                Tools.LogWarn("can't find event:" + eid.ToString());
                return;
            }
            var listeners = allListeners[eid];

            var e = new GameEvent(data);

            var node = listeners.First;

            while (node != null)
            {
                var listener = node.Value;
                if (listener.bStop())
                {
                    var next = node.Next;
                    listeners.Remove(node);
                    node = next;
                    continue;
                }

                listener.onEvent(e);
                if (e.bStop())
                {
                    break;
                }

                node = node.Next;
            }
        }