Exemple #1
0
        /// <summary>
        /// <para>Looks over the "D3DX9_42.dll" in the user's Rocksmith folder to see if the user has a DLL that will enable CDLC.</para>
        /// <para>The type of CDLC enabling DLL is posted into the DLLType variable.</para>
        /// </summary>
        /// <returns>Can CDLC be played?</returns>
        public static bool ValidCdlcDLL()
        {
            ValidGame = !(File.Exists(Path.Combine(Settings.Settings.RocksmithLocation, "IGG-GAMES.COM.url")) || File.Exists(Path.Combine(Settings.Settings.RocksmithLocation, "SmartSteamEmu.ini")) || File.Exists(Path.Combine(Settings.Settings.RocksmithLocation, "GAMESTORRENT.CO.url")) || File.Exists(Path.Combine(Settings.Settings.RocksmithLocation, "Codex.ini")) || File.Exists(Path.Combine(Settings.Settings.RocksmithLocation, "Skidrow.ini"))) && ValidExe();

            // Does the "D3DX9_42.dll" even exist?
            if (!File.Exists(Settings.Settings.DLL_CDLC))
            {
                DLLType = DLLType.None;
                return(false);
            }

            // Is this the Microsoft "D3DX9_42.dll"?
            try
            {
                X509Certificate2 cert = new X509Certificate2(X509Certificate.CreateFromSignedFile(Settings.Settings.DLL_CDLC));

                if (cert.GetNameInfo(X509NameType.SimpleName, false) == "Microsoft Corporation" || cert.Verify())
                {
                    DLLType = DLLType.Microsoft;
                    return(false); // User is using an ACTUAL D3DX9_42.dll, not a CDLC hack.
                }
            }
            catch { } // We want this function to error out. If it does, that means we have a non-Microsoft DLL.


            // Is the user using the normal, CustomsForge, "D3DX9_42.dll"?
            using (SHA256 sha256 = SHA256.Create())
            {
                FileStream dllStream = File.Open(Settings.Settings.DLL_CDLC, FileMode.Open);
                dllStream.Position = 0;

                byte[] hash = sha256.ComputeHash(dllStream);

                if (hash.SequenceEqual(HASH_D3DX9_CF))
                {
                    DLLType = DLLType.CustomsForge;
                    return(true); // User is using the CustomsForge DLL.
                }
                else if (hash.SequenceEqual(HASH_D3DX9_P7))
                {
                    DLLType   = DLLType.Patch7;
                    ValidGame = false;
                    return(false); // User is using the Patch7 DLL
                }
            }

            // Is the user using a RSMods version of the "D3DX9_42.dll"?
            if (File.GetCreationTime(Settings.Settings.DLL_CDLC) >= new DateTime(2020, 7, 1) && new FileInfo(Settings.Settings.DLL_CDLC).Length >= 300000)
            {
                DLLType = DLLType.RSMods;
                return(true);
            }

            // The user is using a different type of "D3DX9_42.dll". This could be off Google from some random site, or potentially a pirate DLL.
            DLLType = DLLType.Unknown;
            return(false);
        }
 public void Add(DLLType dllType, Assembly assembly)
 {
     types.Clear();
     assemblies[dllType] = assembly;
     foreach (Assembly value in assemblies.Values)
     {
         types.AddRange(value.GetTypes());
     }
     //Load();
 }
Exemple #3
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();
        }
Exemple #4
0
    public void Add(DLLType dllType, Assembly assembly)
    {
        this.assemblies[dllType] = assembly;
        this.types.Clear();//清空

        foreach (Assembly val in this.assemblies.Values)
        {
            foreach (Type type in val.GetTypes())
            {
                object[] objects = type.GetCustomAttributes(typeof(BaseAttribute), false);
                if (objects.Length == 0)
                {
                    continue;
                }

                BaseAttribute baseAttribute = (BaseAttribute)objects[0];
                this.types.Add(baseAttribute.attributeType, type);
            }

            Console.WriteLine("扫描特性成功");
        }
    }
 //在服务器启动时将所有的程序集的类型加载到内存中
 public void Add(DLLType dllType, Assembly assembly)
 {
     //将程序集类型加载到字典中
     this.assemblies[dllType] = assembly;
     //清空types
     this.types.Clear();
     //该循环作用是将所有打了特性的类型都加载到types字典中
     foreach (Assembly value in this.assemblies.Values)
     {
         foreach (Type type in value.GetTypes())
         {
             //找到该类型打了何种特性的标签
             object[] objects = type.GetCustomAttributes(typeof(BaseAttribute), false);
             if (objects.Length == 0)
             {
                 continue;
             }
             //因为每个类型我只会打一个特性,所以只取一个
             BaseAttribute baseAttribute = (BaseAttribute)objects[0];
             this.types.Add(baseAttribute.AttributeType, type);
         }
     }
 }
Exemple #6
0
        public void Add(DLLType dllType, Assembly assembly)
        {
            this.assemblies[dllType] = assembly;
            this.types.Clear();
            foreach (Assembly value in this.assemblies.Values)
            {
                foreach (Type type in value.GetTypes())
                {
                    object[] objects = type.GetCustomAttributes(typeof(BaseAttribute), false);
                    if (objects.Length == 0)
                    {
                        continue;
                    }

                    BaseAttribute baseAttribute = (BaseAttribute)objects[0];
                    this.types.Add(baseAttribute.AttributeType, type);
                }
            }

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

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

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

                object obj = Activator.CreateInstance(type);

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

                IUpdateSystem updateSystem = obj as IUpdateSystem;
                if (updateSystem != null)
                {
                    this.updateSystems.Add(updateSystem.Type(), updateSystem);
                }

                ILateUpdateSystem lateUpdateSystem = obj as ILateUpdateSystem;
                if (lateUpdateSystem != null)
                {
                    this.lateUpdateSystems.Add(lateUpdateSystem.Type(), lateUpdateSystem);
                }

                IStartSystem startSystem = obj as IStartSystem;
                if (startSystem != null)
                {
                    this.startSystems.Add(startSystem.Type(), startSystem);
                }

                IDestroySystem destroySystem = obj as IDestroySystem;
                if (destroySystem != null)
                {
                    this.destroySystems.Add(destroySystem.Type(), destroySystem);
                }

                ILoadSystem loadSystem = obj as ILoadSystem;
                if (loadSystem != null)
                {
                    this.loadSystems.Add(loadSystem.Type(), loadSystem);
                }

                IChangeSystem changeSystem = obj as IChangeSystem;
                if (changeSystem != null)
                {
                    this.changeSystems.Add(changeSystem.Type(), changeSystem);
                }
            }



            this.Load();
        }
Exemple #7
0
        private readonly Queue <long> starts = new Queue <long>(); //这个只需要一个  因为starts只会执行一次

        /// <summary>
        /// 加载程序集
        /// </summary>
        /// <param name="dllType"></param>
        /// <param name="assembly"></param>
        public void Add(DLLType dllType, Assembly assembly)
        {
            this.assemblies[dllType] = assembly;

            this.types.Clear();              //清空

            foreach (Assembly value in this.assemblies.Values)
            {
                foreach (Type type in value.GetTypes())
                {
                    object[] objects = type.GetCustomAttributes(typeof(BaseAttribute), false);                      //有BaseAttribute特性的类
                    if (objects.Length == 0)
                    {
                        continue;
                    }

                    BaseAttribute baseAttribute = (BaseAttribute)objects[0];
                    this.types.Add(baseAttribute.AttributeType, type);                        //把类根据其特性的类型  加入到不同的字典中
                }
            }

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

            foreach (Type type in types[typeof(ObjectSystemAttribute)])                          //遍历有ObjectSystem特性的类
            {
                object[] attrs = type.GetCustomAttributes(typeof(ObjectSystemAttribute), false); //再次检查

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

                object obj = Activator.CreateInstance(type);                      //实例化

                //比如 public class TimerComponentUpdateSystem : UpdateSystem<TimerComponent>
                //     我们写的功能都在  TimerComponent 中  它里面有  start update 等方法 但是不用我们来调用
                //     TimerComponentUpdateSystem 类会自动帮我们调用 其中的 update 方法
                //     updateSystems 字典中会保存  TimerComponent类名 和 TimerComponentUpdateSystem 这个类
                //     当 TimerComponent 这个类生成的时候   updateSystems 字典中检索到了  有这个类名  就会调用TimerComponentUpdateSystem
                //     而 TimerComponentUpdateSystem  的传参是 TimerComponent  他会自动调用 TimerComponent 中的方法

                IAwakeSystem objectSystem = obj as IAwakeSystem;
                if (objectSystem != null)
                {
                    this.awakeSystems.Add(objectSystem.Type(), objectSystem);                      //!!!这里的objectSystem.Type()其实就是需要执行的类的类型 所以他能收集对应的类的方法
                }

                IUpdateSystem updateSystem = obj as IUpdateSystem;
                if (updateSystem != null)
                {
                    this.updateSystems.Add(updateSystem.Type(), updateSystem);
                }

                ILateUpdateSystem lateUpdateSystem = obj as ILateUpdateSystem;
                if (lateUpdateSystem != null)
                {
                    this.lateUpdateSystems.Add(lateUpdateSystem.Type(), lateUpdateSystem);
                }

                IStartSystem startSystem = obj as IStartSystem;
                if (startSystem != null)
                {
                    this.startSystems.Add(startSystem.Type(), startSystem);
                }

                IDestroySystem destroySystem = obj as IDestroySystem;
                if (destroySystem != null)
                {
                    this.destroySystems.Add(destroySystem.Type(), destroySystem);
                }

                ILoadSystem loadSystem = obj as ILoadSystem;
                if (loadSystem != null)
                {
                    this.loadSystems.Add(loadSystem.Type(), loadSystem);
                }

                IChangeSystem changeSystem = obj as IChangeSystem;
                if (changeSystem != null)
                {
                    this.changeSystems.Add(changeSystem.Type(), changeSystem);
                }
            }
            /////////////////////////////////////////////////////////////////////////////////////////

            this.allEvents.Clear(); //清除事件
            //遍历所有的有事件特性的类
            foreach (Type type in types[typeof(EventAttribute)])
            {
                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)                                              //判断类是否继承IEvent接口
                    {
                        Log.Error($"{obj.GetType().Name} 没有继承IEvent");
                    }
                    this.RegisterEvent(aEventAttribute.Type, iEvent);                       //加入字典中
                }
            }

            this.Load();
        }
Exemple #8
0
 public Assembly Get(DLLType dLLType)
 {
     return(assemblies[dLLType]);
 }
Exemple #9
0
 public static Assembly Get(DLLType dllType)
 {
     return(assemblies[dllType]);
 }
Exemple #10
0
 public Assembly Get(DLLType dllType)
 {
     return(this.assemblies[dllType]);
 }
Exemple #11
0
        public void AddDll(DLLType dllType, Assembly assembly)
        {
            this.assemblies[dllType] = assembly;
            this.types.Clear();
            foreach (Assembly value in this.assemblies.Values)
            {
                foreach (Type type in value.GetTypes())
                {
                    object[] objects = type.GetCustomAttributes(typeof(BaseAttribute), false);
                    if (objects.Length == 0)
                    {
                        continue;
                    }

                    BaseAttribute baseAttribute = (BaseAttribute)objects[0];
                    this.types.Add(baseAttribute.AttributeType, type);
                }
            }

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

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

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

                object obj = Activator.CreateInstance(type);

                switch (obj)
                {
                case IAwakeSystem awakeSystem:
                    this.awakeSystems.Add(awakeSystem.Type(), awakeSystem);
                    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;
                }
            }

            this.Load();
        }
Exemple #12
0
 public void Add(DLLType dllType, Assembly assembly)
 {
     this.assemblies[dllType] = assembly;
     this.Register();
 }
Exemple #13
0
 public void  AddDll(DLLType dllType, Assembly assembly)
 {
     _eventSystem.AddDll(dllType, assembly);
 }
Exemple #14
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 #15
0
 public void Add(DLLType dllType, Assembly assembly)
 {
     this.assemblies[dllType] = assembly;
     awakes.Clear();
 }
Exemple #16
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);
                }
            }

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

            this.awakeSystems.Clear();
            this.lateUpdateSystems.Clear();
            this.updateSystems.Clear();
            this.startSystems.Clear();
            this.loadSystems.Clear();
            this.changeSystems.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);

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

                IUpdateSystem updateSystem = obj as IUpdateSystem;
                if (updateSystem != null)
                {
                    this.updateSystems.Add(updateSystem.Type(), updateSystem);
                }

                ILateUpdateSystem lateUpdateSystem = obj as ILateUpdateSystem;
                if (lateUpdateSystem != null)
                {
                    this.lateUpdateSystems.Add(lateUpdateSystem.Type(), lateUpdateSystem);
                }

                IStartSystem startSystem = obj as IStartSystem;
                if (startSystem != null)
                {
                    this.startSystems.Add(startSystem.Type(), startSystem);
                }

                IDestroySystem destroySystem = obj as IDestroySystem;
                if (destroySystem != null)
                {
                    this.destroySystems.Add(destroySystem.Type(), destroySystem);
                }

                ILoadSystem loadSystem = obj as ILoadSystem;
                if (loadSystem != null)
                {
                    this.loadSystems.Add(loadSystem.Type(), loadSystem);
                }

                IChangeSystem changeSystem = obj as IChangeSystem;
                if (changeSystem != null)
                {
                    this.changeSystems.Add(changeSystem.Type(), changeSystem);
                }
            }

            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);
                }
            }

            this.Load();
        }
Exemple #18
0
        public void Add(DLLType dllType, Assembly assembly)
        {
            this.assemblies[dllType] = assembly;
            this.types.Clear();
            foreach (Assembly value in this.assemblies.Values)
            {
                foreach (Type type in value.GetTypes())
                {
                    object[] objects = type.GetCustomAttributes(typeof(BaseAttribute), false);
                    if (objects.Length == 0)
                    {
                        continue;
                    }

                    BaseAttribute baseAttribute = (BaseAttribute)objects[0];
                    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 types[typeof(ObjectSystemAttribute)])
            {
                object[] attrs = type.GetCustomAttributes(typeof(ObjectSystemAttribute), false);

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

                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();
            foreach (Type type in types[typeof(EventAttribute)])
            {
                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);
                }
            }

            this.Load();
        }
        public void Add(DLLType dllType, Assembly assembly)
        {
            //缓存到字典中
            this.assemblies[dllType] = assembly;
            this.types.Clear();            //清空

            //Log.Debug($"assemblies:{this.assemblies.Values.Count}");

            //扫描字典中的所有dll 实际上就只有Unity.Model.dll
            foreach (Assembly value in this.assemblies.Values)
            {
                //遍历每个程序集下的类型
                foreach (Type type in value.GetTypes())
                {
                    //获取定义的特性
                    object[] objects = type.GetCustomAttributes(typeof(BaseAttribute), false);
                    if (objects.Length == 0)
                    {
                        continue;
                    }

                    BaseAttribute baseAttribute = (BaseAttribute)objects[0];
                    //根据特性进行缓存各种事件
                    this.types.Add(baseAttribute.AttributeType, type);
                    //Log.Debug($"{baseAttribute.AttributeType.ToString()}/ {type.ToString()}");
                }
            }

            //清空所有存储事件的字典
            this.awakeSystems.Clear();
            this.lateUpdateSystems.Clear();
            this.updateSystems.Clear();
            this.startSystems.Clear();
            this.loadSystems.Clear();
            this.changeSystems.Clear();
            this.destroySystems.Clear();
            this.deserializeSystems.Clear();

            //遍历ObjectSystemAttribute类型的事件
            foreach (Type type in types[typeof(ObjectSystemAttribute)])
            {
                //从这个类型 获取特性列表 类型是ObjectSystemAttribute 并且非继承的
                object[] attrs = type.GetCustomAttributes(typeof(ObjectSystemAttribute), false);

                if (attrs.Length == 0)
                {
                    continue;
                }
                //创造该类型对应的实例
                object obj = Activator.CreateInstance(type);
                //进行类型的匹配 然后缓存到各自的字典中
                //以下这些都是接口interface,所以只要obj继承了以下某一个分支,那么也会满足以下该分支的条件判断
                //说白话就是将继承自IAwakeSystem、IUpdateSystem...并且加了ObjectSystemAttribute特性的这些类,都缓存到各自的字典里去
                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);
                    Log.Debug($"{loadSystem.Type()}.....................");
                    break;

                case IChangeSystem changeSystem:
                    this.changeSystems.Add(changeSystem.Type(), changeSystem);
                    break;

                case IDeserializeSystem deserializeSystem:
                    this.deserializeSystems.Add(deserializeSystem.Type(), deserializeSystem);
                    break;
                }
            }
            //allEvents是存储所有继承自IEvent的类
            //先清除再缓存
            this.allEvents.Clear();
            //找到EventAttribute的class
            foreach (Type type in types[typeof(EventAttribute)])
            {
                object[] attrs = type.GetCustomAttributes(typeof(EventAttribute), false);

                foreach (object attr in attrs)
                {
                    EventAttribute aEventAttribute = (EventAttribute)attr;
                    //创建class的实例
                    object obj = Activator.CreateInstance(type);
                    //所有EventAttribute特性的类 都需要继承自IEvent
                    IEvent iEvent = obj as IEvent;
                    if (iEvent == null)
                    {
                        Log.Error($"{obj.GetType().Name} 没有继承IEvent");
                    }
                    //注册事件,key是特性声明时候标注的字符串,value是class名称,带命名空间
                    //RegisterEvent方法内部是将所有实例缓存到allEvents字典中
                    this.RegisterEvent(aEventAttribute.Type, iEvent);
                }
            }

            //调用所有缓存的Load事件
            this.Load();
        }