protected override void OnDestroy() { MapSystemWorld.MapDestroy(); if (EntitySystemWorld.Instance != null) { EntitySystemWorld.Instance.WorldDestroy(); } Server_DestroyServer("The server has been destroyed"); Client_DisconnectFromServer(); EntitySystemWorld.Shutdown(); GameControlsManager.Shutdown(); ControlsWorld.Shutdown(); controlManager = null; EngineConsole.Shutdown(); instance = null; base.OnDestroy(); }
protected override void OnDestroy() { MultiViewRenderingManager.Shutdown(); MapSystemWorld.MapDestroy(); if (EntitySystemWorld.Instance != null) EntitySystemWorld.Instance.WorldDestroy(); Server_DestroyServer("The server has been destroyed"); Client_DisconnectFromServer(); EntitySystemWorld.Shutdown(); GameControlsManager.Shutdown(); ControlsWorld.Shutdown(); controlManager = null; EngineConsole.Shutdown(); instance = null; base.OnDestroy(); }
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.InvisibleInfoHandler += InvisibleLog_Handlers_InfoHandler; 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(100, 100, 10); camera.LookAt(new Vec3(0, 0, 0)); Control 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); //load materials. if (!HighLevelMaterialManager.Instance.NeedLoadAllMaterialsAtStartup) { //prevent double initialization of materials after startup by means CreateEmptyMaterialsForFasterStartupInitialization = true. ShaderBaseMaterial.CreateEmptyMaterialsForFasterStartupInitialization = true; if (!HighLevelMaterialManager.Instance.LoadAllMaterials()) { LongOperationCallbackManager.Unsubscribe(); return true; } ShaderBaseMaterial.CreateEmptyMaterialsForFasterStartupInitialization = false; } RenderScene(); //Game controls GameControlsManager.Init(); //EntitySystem if (!EntitySystemWorld.Init(new EntitySystemWorld())) { LongOperationCallbackManager.Unsubscribe(); return true; } //load autorun map string mapName = GetAutorunMapName(); bool mapLoadingFailed = false; if (mapName != "") { //hide loading window. LongOperationCallbackManager.Unsubscribe(); if (programLoadingWindow != null) programLoadingWindow.SetShouldDetach(); if (!ServerOrSingle_MapLoad(mapName, EntitySystemWorld.Instance.DefaultWorldType, false)) mapLoadingFailed = true; } //finish initialization of materials and hide loading window. ShaderBaseMaterial.FinishInitializationOfEmptyMaterials(); LongOperationCallbackManager.Unsubscribe(); if (programLoadingWindow != null) programLoadingWindow.SetShouldDetach(); //if no autorun map play music and go to EngineLogoWindow. if (Map.Instance == null && !mapLoadingFailed) { GameMusic.MusicPlay("Sounds\\Music\\MainMenu.ogg", true); controlManager.Controls.Add(new EngineLogoWindow()); } //register "showProfilingTool" console command if (EngineConsole.Instance != null) { EngineConsole.Instance.AddCommand("showProfilingTool", ConsoleCommand_ShowProfilingTool); EngineConsole.Instance.AddCommand("Menu", ConsoleCommand_LoadMainMenu); } //example of custom input device //ExampleCustomInputDevice.InitDevice(); 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); }
private void ProfilingToolButton_Click(object sender) { SetShouldDetach(); GameEngineApp.ShowProfilingTool(true); }
protected override bool OnCreate() { instance = this; ChangeToBetterDefaultSettings(); if( !base.OnCreate() ) return false; SoundVolume = soundVolume; MusicVolume = musicVolume; controlManager = new ScreenControlManager(); if( !ControlsWorld.Init() ) return false; _ShowSystemCursor = _ShowSystemCursor; _DrawFPS = _DrawFPS; MaterialScheme = materialScheme; EControl programLoadingWindow = ControlDeclarationManager.Instance.CreateControl( "Gui\\ProgramLoadingWindow.gui" ); if( programLoadingWindow != null ) controlManager.Controls.Add( programLoadingWindow ); RenderScene(); 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 ) ); if( programLoadingWindow != null ) programLoadingWindow.SetShouldDetach(); //Game controls GameControlsManager.Init(); //EntitySystem if( !EntitySystemWorld.Init( new EntitySystemWorld() ) ) return true;// false; 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\\Bumps.ogg", true ); controlManager.Controls.Add( new EngineLogoWindow() ); } } else { GameMusic.MusicPlay("Sounds\\Music\\Bumps.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; }
protected override void OnDestroy() { MapSystemWorld.MapDestroy(); EntitySystemWorld.Shutdown(); GameControlsManager.Shutdown(); ControlsWorld.Shutdown(); ScreenControlManager.Shutdown(); EngineConsole.Shutdown(); instance = null; base.OnDestroy(); }
protected override bool OnCreate() { instance = this; ChangeToBetterDefaultSettings(); if( !base.OnCreate() ) return false; SoundVolume = soundVolume; MusicVolume = musicVolume; ScreenControlManager.Init(); if( !ControlsWorld.Init() ) return false; _ShowSystemCursor = _ShowSystemCursor; _DrawFPS = _DrawFPS; MaterialScheme = materialScheme; EControl programLoadingWindow = ControlDeclarationManager.Instance.CreateControl( "Gui\\ProgramLoadingWindow.gui" ); if( programLoadingWindow != null ) ScreenControlManager.Instance.Controls.Add( programLoadingWindow ); RenderScene(); EngineConsole.Instance.Texture = TextureManager.Instance.Load( "Utils/Console.png", Texture.Type.Type2D, 0 ); EngineConsole.Instance.Font = FontManager.Instance.LoadFont( "Default", .025f ); EngineConsole.Instance.StaticText = "Version " + EngineVersionInformation.Version; Log.Handlers.InfoHandler += delegate( string text ) { if( EngineConsole.Instance != null ) EngineConsole.Instance.Print( text ); }; Log.Handlers.WarningHandler += delegate( string text, ref bool handled ) { if( EngineConsole.Instance != null ) { handled = true; EngineConsole.Instance.Print( "Warning: " + text, new ColorValue( 1, 0, 0 ) ); EngineConsole.Instance.Active = false; } }; Log.Handlers.ErrorHandler += delegate( string text, ref bool handled ) { if( ScreenControlManager.Instance != null ) { handled = true; //find already created MessageBoxWindow foreach( EControl control in ScreenControlManager.Instance.Controls ) { if( control is MessageBoxWindow ) return; } if( Map.Instance != null ) EntitySystemWorld.Instance.Simulation = false; EngineApp.Instance.MouseRelativeMode = false; ScreenControlManager.Instance.Controls.Add( new MessageBoxWindow( text, "Error", delegate( EButton sender ) { ScreenControlManager.Instance.Controls.Clear(); if( EntitySystemWorld.Instance == null ) { EngineApp.Instance.ShouldExit(); return; } EntitySystemWorld.Instance.Simulation = false; ScreenControlManager.Instance.Controls.Add( new MainMenuWindow() ); } ) ); } }; Log.Handlers.FatalHandler += delegate( string text, ref bool handled ) { if( ScreenControlManager.Instance != null ) { //find already created MessageBoxWindow foreach( EControl control in ScreenControlManager.Instance.Controls ) { if( control is MessageBoxWindow ) { handled = true; return; } } } }; //MotionBlur for a player unit contusion { Compositor compositor = CompositorManager.Instance.GetByName( "MotionBlur" ); if( compositor != null && compositor.IsSupported() ) RendererWorld.Instance.DefaultViewport.AddCompositor( "MotionBlur" ); } //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 ) ); if( programLoadingWindow != null ) programLoadingWindow.SetShouldDetach(); //Game controls GameControlsManager.Init(); //EntitySystem if( !EntitySystemWorld.Init( new EntitySystemWorld() ) ) return true;// false; string mapName = ""; if( autorunMapName != "" && autorunMapName.Length > 2 ) { mapName = autorunMapName; if( !mapName.Contains( "\\" ) && !mapName.Contains( "/" ) ) mapName = "Maps/" + mapName + "/Map.map"; } 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 = Path.GetDirectoryName( VirtualFileSystem. ApplicationExecutablePath ) + "\\" + VirtualFileSystem.ResourceDirectory; 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( !MapLoad( mapName ) ) { //Error foreach( EControl control in ScreenControlManager.Instance.Controls ) { if( control is MessageBoxWindow ) return true; } GameMusic.MusicPlay("Sounds\\Vietheroes\\NewLegend.mp3", true); ScreenControlManager.Instance.Controls.Add( new EngineLogoWindow() ); } } else { GameMusic.MusicPlay("Sounds\\Vietheroes\\NewLegend.mp3", true); ScreenControlManager.Instance.Controls.Add( new EngineLogoWindow() ); } //example of custom input device //ExampleCustomInputDevice.InitDevice(); return true; }