protected override bool OnCreate() { if (!base.OnCreate()) { return(false); } LongOperationNotifier.Setup(); Log.Info(">> 初始化 EntitySystemWorld..."); if (!EntitySystemWorld.Init(new EntitySystemWorld())) { Log.Info(">> EntitySystemWorld 初始化失败!"); return(false); } WorldType worldType = EntitySystemWorld.Instance.DefaultWorldType; if (!EntitySystemWorld.Instance.WorldCreate(WorldSimulationTypes.Editor, worldType)) { Log.Info(">> 创建世界失败, WorldType: {0}", worldType); return(false); } instance = this; DesignerInterface.Init(new DesignerInterfaceImpl()); EntityWorld.Setup(); if (MainForm.Instance != null) { /* * if (MainForm.Instance.ResourcesForm != null) * { * MainForm.Instance.ResourcesForm.ResourceChange += new ResourcesForm.ResourceChangeDelegate(this.OnResourceChange); * MainForm.Instance.ResourcesForm.IsResourceEditModeActive += new ResourcesForm.IsResourceEditModeActiveDelegate(this.OnIsResourceEditMode); * MainForm.Instance.ResourcesForm.ResourceBeginEditMode += new ResourcesForm.ResourceBeginEditModeDelegate(this.OnResourceBeginEditMode); * MainForm.Instance.ResourcesForm.ResourceRename += new ResourcesForm.ResourceRenameDelegate(this.OnResourceRename); * } * //*/ if (MainForm.Instance.PropertiesForm != null) { MainForm.Instance.PropertiesForm.ReadOnly = true; } } ResourceUtils.OnUITypeEditorEditValue += ResourceUtils_OnUITypeEditorEditValue; AddonManager.PreInit(); InitResourceTypeManager(); UndoSystem.Init(64); //EntitySystemWorld.Instance.Simulation = true; return(true); }
protected override bool OnCreate() { Log.Info(">> 初始化 EntitySystemWorld..."); if (!EntitySystemWorld.Init(new EntitySystemWorld())) { Log.Info(">> EntitySystemWorld 初始化失败!"); return(false); } /* * WorldType worldType = EntitySystemWorld.Instance.DefaultWorldType; * if ( !EntitySystemWorld.Instance.WorldCreate(WorldSimulationTypes.Editor, worldType) ) * { * Log.Info(">> 创建世界失败, WorldType: {0}", worldType); * return false; * } * //*/ EntitySystemWorld.Instance.Simulation = true; return(true); }
protected override bool OnCreate() { if (!base.OnCreate()) { return(false); } RendererWorld.Instance.DefaultCamera.Visible = false; ControlsWorld.Init(); if (!EntitySystemWorld.Init(new EntitySystemWorld())) { return(false); } if (automaticTicks) { CreateTickTimer(); } return(true); }
protected override bool OnCreate() { instance = this; ChangeToBetterDefaultSettings(); if (!base.OnCreate()) { return(false); } SoundVolume = soundVolume; MusicVolume = musicVolume; controlManager = new ScreenControlManager(ScreenGuiRenderer); if (!ControlsWorld.Init()) { return(false); } _ShowSystemCursor = _ShowSystemCursor; _DrawFPS = _DrawFPS; MaterialScheme = materialScheme; Log.Handlers.InfoHandler += Log_Handlers_InfoHandler; Log.Handlers.WarningHandler += Log_Handlers_WarningHandler; Log.Handlers.ErrorHandler += Log_Handlers_ErrorHandler; Log.Handlers.FatalHandler += Log_Handlers_FatalHandler; //Camera Camera camera = RendererWorld.Instance.DefaultCamera; camera.NearClipDistance = .1f; camera.FarClipDistance = 1000.0f; camera.FixedUp = Vec3.ZAxis; camera.Fov = 90; camera.Position = new Vec3(-10, -10, 10); camera.LookAt(new Vec3(0, 0, 0)); EControl programLoadingWindow = ControlDeclarationManager.Instance.CreateControl( "Gui\\ProgramLoadingWindow.gui"); if (programLoadingWindow != null) { controlManager.Controls.Add(programLoadingWindow); } //Subcribe to callbacks during engine loading. We will render scene from callback. LongOperationCallbackManager.Subscribe(LongOperationCallbackManager_LoadingCallback, programLoadingWindow); if (!HighLevelMaterialManager.Instance.LoadAllMaterials()) { LongOperationCallbackManager.Unsubscribe(); return(true); } RenderScene(); //Game controls GameControlsManager.Init(); //EntitySystem if (!EntitySystemWorld.Init(new EntitySystemWorld())) { LongOperationCallbackManager.Unsubscribe(); return(true); } LongOperationCallbackManager.Unsubscribe(); //close loading window. if (programLoadingWindow != null) { programLoadingWindow.SetShouldDetach(); } string mapName = ""; if (autorunMapName != "" && autorunMapName.Length > 2) { mapName = autorunMapName; if (!mapName.Contains("\\") && !mapName.Contains("/")) { mapName = "Maps/" + mapName + "/Map.map"; } } if (!WebPlayerMode) { string[] commandLineArgs = Environment.GetCommandLineArgs(); if (commandLineArgs.Length > 1) { string name = commandLineArgs[1]; if (name[0] == '\"' && name[name.Length - 1] == '\"') { name = name.Substring(1, name.Length - 2); } name = name.Replace('/', '\\'); string dataDirectory = VirtualFileSystem.ResourceDirectoryPath; dataDirectory = dataDirectory.Replace('/', '\\'); if (name.Length > dataDirectory.Length) { if (string.Compare(name.Substring(0, dataDirectory.Length), dataDirectory, true) == 0) { name = name.Substring(dataDirectory.Length + 1); } } mapName = name; } } if (mapName != "") { if (!ServerOrSingle_MapLoad(mapName, EntitySystemWorld.Instance.DefaultWorldType, false)) { //Error foreach (EControl control in controlManager.Controls) { if (control is MessageBoxWindow && !control.IsShouldDetach()) { return(true); } } GameMusic.MusicPlay("Sounds\\Music\\MainMenu.ogg", true); controlManager.Controls.Add(new EngineLogoWindow()); } } else { GameMusic.MusicPlay("Sounds\\Music\\MainMenu.ogg", true); controlManager.Controls.Add(new EngineLogoWindow()); } //showDebugInformation console command if (EngineConsole.Instance != null) { EngineConsole.Instance.AddCommand("showDebugInformationWindow", ConsoleCommand_ShowDebugInformationWindow); } //example of custom input device //ExampleCustomInputDevice.InitDevice(); return(true); }