internal static void Shutdown() { if (instance != null) { instance.Free(); instance = null; } }
internal static bool Init() { instance = new EntityTypes(); bool ok = instance.Setup(); if (!ok) { Shutdown(); } return(ok); }
private void _Shutdown() { WorldDestroy(); EntityTypes.Shutdown(); LogicSystemClasses.Shutdown(); }
private bool _Startup() { #region 缺省 Entity.tickDelta = 20; #endregion TextBlock textBlock = null; if (VirtualFile.Exists("Base/Constants/EntitySystem.config")) { textBlock = TextBlockUtils.LoadFromVirtualFile("Base/Constants/EntitySystem.config"); if (textBlock != null) { } } if (JxEngineApp.Instance != null) { Entity.tickDelta = JxEngineApp.Instance.LoopInterval; } CreateEntityClassAssembly(typeof(EntitySystemWorld).Assembly); CreateEntityClassAssembly(Assembly.GetExecutingAssembly()); /* * Assembly item = AssemblyUtils.LoadAssemblyByRealFileName("MapSystem.dll", false); * entityClassAssemblies.Add(item); * //*/ ComponentManager.ComponentInfo[] componentsByType = ComponentManager.Instance.GetComponentsByType(ComponentManager.ComponentTypeFlags.EntityClasses, true); for (int i = 0; i < componentsByType.Length; i++) { ComponentManager.ComponentInfo componentInfo = componentsByType[i]; ComponentManager.ComponentInfo.PathInfo[] allEntryPointsForThisPlatform = componentInfo.GetAllEntryPointsForThisPlatform(); LongOperationNotifier.Notify("初始化组件({0}/{1}): {2}, 入口数: {3}", i + 1, componentsByType.Length, componentInfo.FullName, allEntryPointsForThisPlatform.Length); for (int j = 0; j < allEntryPointsForThisPlatform.Length; j++) { ComponentManager.ComponentInfo.PathInfo pathInfo = allEntryPointsForThisPlatform[j]; Assembly assembly = AssemblyUtils.LoadAssemblyByRealFileName(pathInfo.Path, false); CreateEntityClassAssembly(assembly); } } if (textBlock != null) { TextBlock logicSystemBlock = textBlock.FindChild("logicSystem"); if (logicSystemBlock != null) { TextBlock logicSystemClassAssembliesBlock = logicSystemBlock.FindChild("systemClassesAssemblies"); if (logicSystemClassAssembliesBlock != null) { foreach (TextBlock current in logicSystemClassAssembliesBlock.Children) { string assemblyFileName = current.GetAttribute("file"); logicSystemSystemClassesAssemblies.Add(assemblyFileName); } } } } LogicSystemClasses.Init(); if (!EntityTypes.Init()) { return(false); } if (textBlock != null) { string defaultWorldType = textBlock.GetAttribute("defaultWorldType"); if (!string.IsNullOrEmpty(defaultWorldType)) { this.defaultWorldType = EntityTypes.Instance.GetByName(defaultWorldType) as WorldType; if (this.defaultWorldType == null) { this.defaultWorldType = EntityTypes.Instance.GetByName(typeof(DefaultWorld).Name) as WorldType; } } if (this.defaultWorldType == null) { Log.Fatal("EntitySystemWorld: Init: World type \"{0}\" is not defined or it is not a WorldType (Base\\Constants\\EntitySystem.config: \"defaultWorldType\" attribute).", defaultWorldType); return(false); } } Log.Info(">> 默认WorldType: {0}", defaultWorldType); return(true); }