Exemplo n.º 1
0
 protected EventTable GetEventTable()
 {
     if (mEventTable == null)
     {
         mEventTable = new EventTable();
     }
     return(mEventTable);
 }
Exemplo n.º 2
0
 public override void Release()
 {
     if (mEventTable != null)
     {
         mEventTable.Clear();
         mEventTable = null;
     }
     base.Release();
 }
Exemplo n.º 3
0
        private EventTable GetPreListenEventTable(string target)
        {
            EventTable table = null;

            if (!mPreListenerEventsMap.ContainsKey(target))
            {
                table = new EventTable();
                mPreListenerEventsMap.Add(target, table);
            }
            else
            {
                table = mPreListenerEventsMap[target];
            }
            return(table);
        }
Exemplo n.º 4
0
        public ModuleEvent Event(string target, string type)
        {
            ModuleEvent   moduleEvent = null;
            BaseBizModule module      = GetModule(target);

            if (module != null)
            {
                moduleEvent = module.Event(type);
            }
            else
            {
                EventTable table = GetPreListenEventTable(target);
                moduleEvent = table.GetEvent(type);
            }
            return(moduleEvent);
        }
Exemplo n.º 5
0
        public BaseBizModule CreateModule(string name, object args = null)
        {
            if (mModulesMap.ContainsKey(name))
            {
                return(null);
            }

            BaseBizModule module = null;
            Type          type   = Type.GetType(mDomain + "." + name);

            if (type != null)
            {
                module = Activator.CreateInstance(type) as BaseBizModule;
            }
            else
            {
                module = new LuaModule(name);
            }
            mModulesMap.Add(name, module);

            //
            if (mPreListenerEventsMap.ContainsKey(name))
            {
                EventTable eventTable = mPreListenerEventsMap[name];
                mPreListenerEventsMap.Remove(name);
                module.SetEventTable(eventTable);
            }
            module.Create(args);

            //
            if (mMessageCacheMap.ContainsKey(name))
            {
                List <MessageObject> list = mMessageCacheMap[name];
                foreach (var messageObject in list)
                {
                    module.HandleMessage(messageObject.msg, messageObject.args);
                }
                mMessageCacheMap.Remove(name);
            }
            return(module);
        }
Exemplo n.º 6
0
 internal void SetEventTable(EventTable eventTable)
 {
     mEventTable = eventTable;
 }