Inheritance: AEventAttribute
        public void Load()
        {
            this.allEvents = new Dictionary <EventIdType, List <object> >();
            Assembly[] assemblies = Object.ObjectManager.GetAssemblies();
            foreach (Assembly assembly in assemblies)
            {
                Type[] types = assembly.GetTypes();
                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(aEventAttribute.Type))
                        {
                            this.allEvents.Add(aEventAttribute.Type, new List <object>());
                        }
                        this.allEvents[aEventAttribute.Type].Add(obj);
                    }
                }
            }
        }
Exemple #2
0
        public void Add(DLLType dllType, Assembly assembly)
        {
            this.assemblies[dllType] = assembly;

            this.disposerEvents.Clear();

            Type[] types = DllHelper.GetMonoTypes();
            foreach (Type type in types)
            {
                object[] attrs = type.GetCustomAttributes(typeof(ObjectSystemAttribute), 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;
            }


            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 <object>());
                    }
                    this.allEvents[(EventIdType)aEventAttribute.Type].Add(obj);
                }
            }

            this.Load();
        }
        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);
                }
            }
        }
        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);
                }
            }
        }
        public void Load()
        {
            this.allEvents = new Dictionary <EventIdType, List <object> >();

            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 <object>());
                    }
                    this.allEvents[(EventIdType)aEventAttribute.Type].Add(obj);
                }
            }
        }
Exemple #6
0
        private void Register()
        {
            Type[] types = DllHelper.GetMonoTypes();
            foreach (Type type in types)
            {
                object[] attrs = type.GetCustomAttributes(typeof(ObjectSystemAttribute), 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);
                    IEvent         iEvent          = obj as IEvent;
                    if (iEvent == null)
                    {
                        Log.Error($"{obj.GetType().Name} 没有继承IEvent");
                    }
                    this.RegisterEvent(aEventAttribute.Type, iEvent);
                }
            }
        }
Exemple #7
0
        public void Add(DLLType dllType, Assembly assembly)
        {
            this.assemblies[dllType] = assembly;

            this.awakeEvents.Clear();
            this.lateUpdateEvents.Clear();
            this.updateEvents.Clear();
            this.startEvents.Clear();
            this.loadEvents.Clear();

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

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

                object obj = Activator.CreateInstance(type);

                AAwakeSystem objectSystem = obj as AAwakeSystem;
                if (objectSystem != null)
                {
                    this.awakeEvents.Add(objectSystem.Type(), objectSystem);
                }

                AUpdateSystem aUpdateSystem = obj as AUpdateSystem;
                if (aUpdateSystem != null)
                {
                    this.updateEvents.Add(aUpdateSystem.Type(), aUpdateSystem);
                }

                ALateUpdateSystem aLateUpdateSystem = obj as ALateUpdateSystem;
                if (aLateUpdateSystem != null)
                {
                    this.lateUpdateEvents.Add(aLateUpdateSystem.Type(), aLateUpdateSystem);
                }

                AStartSystem aStartSystem = obj as AStartSystem;
                if (aStartSystem != null)
                {
                    this.startEvents.Add(aStartSystem.Type(), aStartSystem);
                }

                ALoadSystem aLoadSystem = obj as ALoadSystem;
                if (aLoadSystem != null)
                {
                    this.loadEvents.Add(aLoadSystem.Type(), aLoadSystem);
                }
            }


            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 <object>());
                    }
                    this.allEvents[(EventIdType)aEventAttribute.Type].Add(obj);
                }
            }

            this.Load();
        }
Exemple #8
0
        public void Add(DLLType dllType, Assembly assembly)
        {
            this.assemblies[dllType] = assembly;

            this.awakeEvents.Clear();
            this.lateUpdateEvents.Clear();
            this.updateEvents.Clear();
            this.startEvents.Clear();
            this.loadEvents.Clear();

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

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

                object obj = Activator.CreateInstance(type);

                AAwakeSystem objectSystem = obj as AAwakeSystem;
                if (objectSystem != null)
                {
                    this.awakeEvents.Add(objectSystem.Type(), objectSystem);
                }

                AUpdateSystem aUpdateSystem = obj as AUpdateSystem;
                if (aUpdateSystem != null)
                {
                    this.updateEvents.Add(aUpdateSystem.Type(), aUpdateSystem);
                }

                ALateUpdateSystem aLateUpdateSystem = obj as ALateUpdateSystem;
                if (aLateUpdateSystem != null)
                {
                    this.lateUpdateEvents.Add(aLateUpdateSystem.Type(), aLateUpdateSystem);
                }

                AStartSystem aStartSystem = obj as AStartSystem;
                if (aStartSystem != null)
                {
                    this.startEvents.Add(aStartSystem.Type(), aStartSystem);
                }

                ALoadSystem aLoadSystem = obj as ALoadSystem;
                if (aLoadSystem != null)
                {
                    this.loadEvents.Add(aLoadSystem.Type(), aLoadSystem);
                }
            }

            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);
                    IEvent         iEvent          = obj as IEvent;
                    if (iEvent == null)
                    {
                        Log.Error($"{obj.GetType().Name} 没有继承IEvent");
                    }
                    this.RegisterEvent(aEventAttribute.Type, iEvent);
                }
            }
        }
Exemple #9
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);
                }
            }
        }
Exemple #10
0
        public void Add(Assembly assembly)
        {
            this.assemblies = assembly;
            this.types.Clear();
            foreach (Type type in assemblies.GetTypes())
            {
                if (type.IsAbstract)
                {
                    continue;
                }

                object[] objects = type.GetCustomAttributes(typeof(BaseAttribute), true);
                if (objects.Length == 0)
                {
                    continue;
                }
                //UnityEngine.Debug.Log(" Obo type1 "+objects[0].ToString());
                BaseAttribute baseAttribute = (BaseAttribute)objects[0];

                //UnityEngine.Debug.Log(" type1 "+baseAttribute.AttributeType.ToString());

                //Debug.Log(" Assembly sub type "+type);
                this.types.Add(baseAttribute.AttributeType, type);
            }

            this.awakeSystems.Clear();
            this.lateUpdateSystems.Clear();
            this.updateSystems.Clear();
            this.startSystems.Clear();
//			this.loadSystems.Clear();
            this.changeSystems.Clear();
            this.destroySystems.Clear();
            this.deserializeSystems.Clear();

            foreach (Type type in this.GetTypes(typeof(ObjectSystemAttribute)))
            {
                object obj = Activator.CreateInstance(type);

                switch (obj)
                {
                case IAwakeSystem objectSystem:
                    this.awakeSystems.Add(objectSystem.Type(), objectSystem);
                    break;

                case IUpdateSystem updateSystem:
                    this.updateSystems.Add(updateSystem.Type(), updateSystem);
                    break;

                case ILateUpdateSystem lateUpdateSystem:
                    this.lateUpdateSystems.Add(lateUpdateSystem.Type(), lateUpdateSystem);
                    break;

                case IStartSystem startSystem:
                    this.startSystems.Add(startSystem.Type(), startSystem);
                    break;

                case IDestroySystem destroySystem:
                    this.destroySystems.Add(destroySystem.Type(), destroySystem);
                    break;

//					case ILoadSystem loadSystem:
//						this.loadSystems.Add(loadSystem.Type(), loadSystem);
//						break;
                case IChangeSystem changeSystem:
                    this.changeSystems.Add(changeSystem.Type(), changeSystem);
                    break;

                case IDeserializeSystem deserializeSystem:
                    this.deserializeSystems.Add(deserializeSystem.Type(), deserializeSystem);
                    break;
                }
            }

            this.allEvents.Clear();
            if (this.types.ContainsKey(typeof(EventAttribute)))
            {
                foreach (Type type in types[typeof(EventAttribute)])
                {
                    UnityEngine.Debug.Log(" type " + type.FullName);
                    object[] attrs = type.GetCustomAttributes(typeof(EventAttribute), false);

                    foreach (object attr in attrs)
                    {
                        EventAttribute aEventAttribute = (EventAttribute)attr;

                        //Debug.Log(" ==event Name "+aEventAttribute.ToString());
                        object obj    = Activator.CreateInstance(type);
                        IEvent iEvent = obj as IEvent;
                        if (iEvent == null)
                        {
                            Log.LogError($"{obj.GetType().Name} 没有继承IEvent");
                        }
                        this.RegisterEvent(aEventAttribute.Type, iEvent);
                    }
                }
            }

            this.Load();
        }