예제 #1
0
파일: ECSCenter.cs 프로젝트: ALunGame/LCECS
        //注册系统
        private void RegSystems()
        {
            List <Type> systemTypes        = LCReflect.GetClassByType <BaseSystem>();
            List <Type> updateSystems      = new List <Type>();
            List <Type> fixedUpdateSystems = new List <Type>();

            //分组
            for (int i = 0; i < systemTypes.Count; i++)
            {
                Type            type = systemTypes[i];
                SystemAttribute attr = LCReflect.GetTypeAttr <SystemAttribute>(type);
                if (attr == null)
                {
                    //ECSLocate.ECSLog.Log("该系统没有设置系统特性>>>>>>", type.Name);
                    updateSystems.Add(type);
                }
                else
                {
                    if (attr.InFixedUpdate)
                    {
                        fixedUpdateSystems.Add(type);
                    }
                    else
                    {
                        updateSystems.Add(type);
                    }
                }
            }

            //排序
            updateSystems.Sort(SystemSortFunc);
            fixedUpdateSystems.Sort(SystemSortFunc);

            //注册
            for (int i = 0; i < updateSystems.Count; i++)
            {
                Type       type   = updateSystems[i];
                BaseSystem system = LCReflect.CreateInstanceByType <BaseSystem>(type.FullName);
                system.Init();

                ECSLocate.ECS.RegUpdateSystem(system);
            }
            for (int i = 0; i < fixedUpdateSystems.Count; i++)
            {
                Type       type   = fixedUpdateSystems[i];
                BaseSystem system = LCReflect.CreateInstanceByType <BaseSystem>(type.FullName);
                system.Init();

                ECSLocate.ECS.RegFixedUpdateSystem(system);
            }
        }
예제 #2
0
 //注册系统
 private void RegSystems()
 {
     foreach (var item in systemSortAsset.GetSystemSorts(SystemType.Update))
     {
         Type systemType = ReflectionHelper.GetType(item.typeFullName);
         if (systemType == null)
         {
             LCECS.ECSLocate.Log.LogError("系统创建失败>>>", systemType, item.typeFullName);
             continue;
         }
         object     systemObj = ReflectionHelper.CreateInstance(systemType);
         BaseSystem system    = systemObj as BaseSystem;
         system.Init();
         ECSLocate.ECS.RegUpdateSystem(system);
     }
     foreach (var item in systemSortAsset.GetSystemSorts(SystemType.FixedUpdate))
     {
         Type       systemType = ReflectionHelper.GetType(item.typeFullName);
         BaseSystem system     = ReflectionHelper.CreateInstance(systemType) as BaseSystem;
         system.Init();
         ECSLocate.ECS.RegFixedUpdateSystem(system);
     }
 }
예제 #3
0
파일: Tempest.cs 프로젝트: antjowie/Tempest
        public void Awake()
        {
            ModLogger = this.Logger;

            using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Tempest.tempest_assets"))
            {
                MainAssets = AssetBundle.LoadFromStream(stream);
            }

            //ModLogger.LogInfo("----------------------ASSETS--------------------");
            //foreach (var asset in MainAssets.GetAllAssetNames())
            //{
            //    ModLogger.LogMessage(asset);
            //}

            if (Helpers.InDebugMode())
            {
                ModLogger.LogWarning("Tempest has been compiled in debug mode!");
            }

            ModLogger.LogInfo("----------------------SYSTEMS--------------------");
            var SystemTypes = Assembly.GetExecutingAssembly().GetTypes().Where(type => !type.IsAbstract && type.IsSubclassOf(typeof(BaseSystem)));

            foreach (var systemType in SystemTypes)
            {
                BaseSystem system = (BaseSystem)System.Activator.CreateInstance(systemType);

                if (!Helpers.InDebugMode() && system.StripFromRelease)
                {
                    ModLogger.LogWarning("System: " + systemType.Name + " stripped from release!");
                    continue;
                }

                system.Init(this);
                ModLogger.LogInfo("System: " + systemType.Name + " initialized!");
            }

            ModLogger.LogInfo("----------------------ITEMS--------------------");
            var ItemTypes = Assembly.GetExecutingAssembly().GetTypes().Where(type => !type.IsAbstract && type.IsSubclassOf(typeof(BaseItem)));

            foreach (var itemType in ItemTypes)
            {
                BaseItem item = (BaseItem)System.Activator.CreateInstance(itemType);
                if (ValidateItem(item, Items))
                {
                    item.Init(Config);
                    CustomItems.Add(item.ItemDef.name, item.ItemDef);
                    ModLogger.LogInfo("Item: " + item.ItemName + " initialized!");
                }
                else
                {
                    ModLogger.LogWarning("Item: " + item.ItemName + " disabled!");
                }
            }

            ModLogger.LogInfo("----------------------EQUIPMENT--------------------");
            var EquipmetTypes = Assembly.GetExecutingAssembly().GetTypes().Where(type => !type.IsAbstract && type.IsSubclassOf(typeof(BaseEquipment)));

            foreach (var EquipmetType in EquipmetTypes)
            {
                BaseEquipment equipment = (BaseEquipment)System.Activator.CreateInstance(EquipmetType);
                equipment.Init(Config);

                ModLogger.LogInfo("Equpment: " + equipment.EquipmentName + " initialized!");
            }

            ModLogger.LogInfo("----------------------TEMPEST DONE--------------------");
        }