예제 #1
0
        private void Load()
        {
            this.UiTypes = new Dictionary <int, IUIFactory>();

            Type[] types = DllHelper.GetHotfixTypes();

            foreach (Type type in types)
            {
                object[] attrs = type.GetCustomAttributes(typeof(UIFactoryAttribute), false);
                if (attrs.Length == 0)
                {
                    continue;
                }

                UIFactoryAttribute attribute = attrs[0] as UIFactoryAttribute;
                if (this.UiTypes.ContainsKey(attribute.Type))
                {
                    throw new GameException($"已经存在同类UI Factory: {attribute.Type}");
                }

                IUIFactory iuiFactory = new IUIFactoryMethod(type);

                this.UiTypes.Add(attribute.Type, iuiFactory);
            }
        }
예제 #2
0
        private void Load()
        {
            this.handlers    = new Dictionary <ushort, List <IInstanceMethod> >();
            this.opcodeTypes = new DoubleMap <ushort, Type>();

            Type[] monoTypes = DllHelper.GetMonoTypes();
            foreach (Type monoType in monoTypes)
            {
                object[] attrs = monoType.GetCustomAttributes(typeof(MessageAttribute), false);
                if (attrs.Length == 0)
                {
                    continue;
                }

                MessageAttribute messageAttribute = attrs[0] as MessageAttribute;
                if (messageAttribute == null)
                {
                    continue;
                }

                this.opcodeTypes.Add(messageAttribute.Opcode, monoType);
            }

#if ILRuntime
            Type[] types = DllHelper.GetHotfixTypes();
#else
            Type[] types = DllHelper.GetMonoTypes();
#endif
            foreach (Type type in types)
            {
                object[] attrs = type.GetCustomAttributes(typeof(MessageHandlerAttribute), false);
                if (attrs.Length == 0)
                {
                    continue;
                }
                MessageHandlerAttribute messageHandlerAttribute = (MessageHandlerAttribute)attrs[0];
#if ILRuntime
                IInstanceMethod method = new ILInstanceMethod(type, "Handle");
#else
                IInstanceMethod method = new MonoInstanceMethod(type, "Handle");
#endif
                if (!this.handlers.ContainsKey(messageHandlerAttribute.Opcode))
                {
                    this.handlers.Add(messageHandlerAttribute.Opcode, new List <IInstanceMethod>());
                }
                this.handlers[messageHandlerAttribute.Opcode].Add(method);
            }
        }
예제 #3
0
        public void Load()
        {
            handlers = new Dictionary <Opcode, List <IMessageMethod> >();

            Type[] types = DllHelper.GetMonoTypes();

            foreach (Type type in types)
            {
                object[] attrs = type.GetCustomAttributes(typeof(MessageHandlerAttribute), false);
                if (attrs.Length == 0)
                {
                    continue;
                }
                MessageHandlerAttribute messageHandlerAttribute = (MessageHandlerAttribute)attrs[0];
                IMHandler iMHandler = (IMHandler)Activator.CreateInstance(type);
                if (!this.handlers.ContainsKey((Opcode)messageHandlerAttribute.Opcode))
                {
                    this.handlers.Add((Opcode)messageHandlerAttribute.Opcode, new List <IMessageMethod>());
                }
                this.handlers[(Opcode)messageHandlerAttribute.Opcode].Add(new IMessageMonoMethod(iMHandler));
            }

            // hotfix dll
            Type[] hotfixTypes = DllHelper.GetHotfixTypes();
            foreach (Type type in hotfixTypes)
            {
                object[] attrs = type.GetCustomAttributes(typeof(MessageHandlerAttribute), false);
                if (attrs.Length == 0)
                {
                    continue;
                }
                MessageHandlerAttribute messageHandlerAttribute = (MessageHandlerAttribute)attrs[0];
#if ILRuntime
                IMessageMethod iMessageMethod = new IMessageILMethod(type, "Handle");
#else
                IMHandler      iMHandler      = (IMHandler)Activator.CreateInstance(type);
                IMessageMethod iMessageMethod = new IMessageMonoMethod(iMHandler);
#endif
                if (!this.handlers.ContainsKey((Opcode)messageHandlerAttribute.Opcode))
                {
                    this.handlers.Add((Opcode)messageHandlerAttribute.Opcode, new List <IMessageMethod>());
                }
                this.handlers[(Opcode)messageHandlerAttribute.Opcode].Add(iMessageMethod);
            }
        }
예제 #4
0
        public void Load()
        {
            this.allEvents = new Dictionary <EventIdType, List <IEventMethod> >();

            Type[] types = DllHelper.GetMonoTypes();
            foreach (Type type in types)
            {
                object[] attrs = type.GetCustomAttributes(typeof(EventAttribute), false);

                foreach (object attr in attrs)
                {
                    EventAttribute aEventAttribute = (EventAttribute)attr;
                    object         obj             = Activator.CreateInstance(type);
                    if (!this.allEvents.ContainsKey((EventIdType)aEventAttribute.Type))
                    {
                        this.allEvents.Add((EventIdType)aEventAttribute.Type, new List <IEventMethod>());
                    }
                    this.allEvents[(EventIdType)aEventAttribute.Type].Add(new IEventMonoMethod(obj));
                }
            }

            // hotfix dll
            Type[] hotfixTypes = DllHelper.GetHotfixTypes();
            foreach (Type type in hotfixTypes)
            {
                object[] attrs = type.GetCustomAttributes(typeof(EventAttribute), false);
                foreach (object attr in attrs)
                {
                    EventAttribute aEventAttribute = (EventAttribute)attr;
#if ILRuntime
                    IEventMethod method = new IEventILMethod(type, "Run");
#else
                    object       obj    = Activator.CreateInstance(type);
                    IEventMethod method = new IEventMonoMethod(obj);
#endif
                    if (!allEvents.ContainsKey((EventIdType)aEventAttribute.Type))
                    {
                        allEvents.Add((EventIdType)aEventAttribute.Type, new List <IEventMethod>());
                    }
                    allEvents[(EventIdType)aEventAttribute.Type].Add(method);
                }
            }
        }
예제 #5
0
        private void Load()
        {
            this.allEvents = new Dictionary <int, List <IInstanceMethod> >();

            Type[] types = DllHelper.GetHotfixTypes();
            foreach (Type type in types)
            {
                object[] attrs = type.GetCustomAttributes(typeof(EventAttribute), false);

                foreach (object attr in attrs)
                {
                    EventAttribute  aEventAttribute = (EventAttribute)attr;
                    IInstanceMethod method          = new ILInstanceMethod(type, "Run");
                    if (!this.allEvents.ContainsKey(aEventAttribute.Type))
                    {
                        this.allEvents.Add(aEventAttribute.Type, new List <IInstanceMethod>());
                    }
                    this.allEvents[aEventAttribute.Type].Add(method);
                }
            }
        }
예제 #6
0
        private void Load()
        {
            allEvents = new Dictionary <int, List <IInstanceMethod> >();

            Type[] types = DllHelper.GetHotfixTypes();
            foreach (Type type in types)
            {
                object[] attrs = type.GetCustomAttributes(typeof(CrossEventAttribute), false);
                foreach (object attr in attrs)
                {
                    CrossEventAttribute aEventAttribute = (CrossEventAttribute)attr;
#if ILRuntime
                    IInstanceMethod method = new ILInstanceMethod(type, "Run");
#else
                    IInstanceMethod method = new MonoInstanceMethod(type, "Run");
#endif
                    if (!allEvents.ContainsKey(aEventAttribute.Type))
                    {
                        allEvents.Add(aEventAttribute.Type, new List <IInstanceMethod>());
                    }
                    allEvents[aEventAttribute.Type].Add(method);
                }
            }
        }
예제 #7
0
        private void Register()
        {
            Type[] types = DllHelper.GetMonoTypes();
            foreach (Type type in types)
            {
                object[] attrs = type.GetCustomAttributes(typeof(ObjectEventAttribute), false);

                if (attrs.Length == 0)
                {
                    continue;
                }

                object        obj          = Activator.CreateInstance(type);
                IObjectSystem objectSystem = obj as IObjectSystem;
                if (objectSystem == null)
                {
                    Log.Error($"组件事件没有继承IObjectEvent: {type.Name}");
                    continue;
                }
                this.disposerEvents[objectSystem.Type()] = objectSystem;
            }


            this.allEvents.Clear();
            foreach (Type type in types)
            {
                object[] attrs = type.GetCustomAttributes(typeof(EventAttribute), false);

                foreach (object attr in attrs)
                {
                    EventAttribute aEventAttribute = (EventAttribute)attr;
                    object         obj             = Activator.CreateInstance(type);
                    if (!this.allEvents.ContainsKey((EventIdType)aEventAttribute.Type))
                    {
                        this.allEvents.Add((EventIdType)aEventAttribute.Type, new List <IEventMethod>());
                    }
                    this.allEvents[(EventIdType)aEventAttribute.Type].Add(new IEventMonoMethod(obj));
                }
            }

            // hotfix dll
            Type[] hotfixTypes = DllHelper.GetHotfixTypes();
            foreach (Type type in hotfixTypes)
            {
                object[] attrs = type.GetCustomAttributes(typeof(EventAttribute), false);
                foreach (object attr in attrs)
                {
                    EventAttribute aEventAttribute = (EventAttribute)attr;
#if ILRuntime
                    IEventMethod method = new IEventILMethod(type, "Run");
#else
                    object       obj    = Activator.CreateInstance(type);
                    IEventMethod method = new IEventMonoMethod(obj);
#endif
                    if (!allEvents.ContainsKey((EventIdType)aEventAttribute.Type))
                    {
                        allEvents.Add((EventIdType)aEventAttribute.Type, new List <IEventMethod>());
                    }
                    allEvents[(EventIdType)aEventAttribute.Type].Add(method);
                }
            }
        }