/// <summary> /// Scene Shutdown. /// The Game Engine, Rendering Panel, Scene Manager, Text Renderer, /// and other game engine dependent components /// are shutdown here. /// </summary> /// <param name="immediately">True if shutdown should be performed immediately, /// due to initialization failure or critical error. False if the user /// should prompted to shutdown safely.</param> public void Shutdown(bool immediately) { this.ShutdownExtra(immediately); this.mStopWatch.Stop(); if (this.mScene != null) { this.mScene.Shutdown(); this.mScene.Dispose(); this.mScene = null; } if (this.mTextRenderer != null) { this.mTextRenderer.Dispose(); this.mTextRenderer = null; } App.PreShutdown(); GameObjectFactory.Shutdown(); App.Shutdown(); }
/// <summary> /// Scene Initialization. /// The Game Engine, Rendering Panel, Scene Manager, Text Renderer, /// and other game engine dependent components /// are initialized here. /// </summary> /// <param name="splash">A splash form for displaying initialization messages.</param> /// <returns>True if all components were successfully initialized, /// False otherwise</returns> public bool Init(ISplashForm splash) { if (this.mRenderingPanel == null) { this.mRenderingPanel = new RenderPanelEx(); //return false; } if (splash != null) { splash.Message = "Initializing Game Engine..."; } string overrideUserDataPath = null; string installedGameUserDataDir = App.GetInstalledGameUserDataDir(); SharedInitialization.AddGimexSupport(); if (!string.IsNullOrEmpty(installedGameUserDataDir)) { string folderPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); overrideUserDataPath = Path.Combine(folderPath, installedGameUserDataDir); } this.mStopWatch.Start(); float startTime = this.mStopWatch.GetElapsedMilliSecs() / 1000f; if (!App.InitApp("", "", this.mRenderingPanel.Width, this.mRenderingPanel.Height, IntPtr.Zero, 0, this.mRenderingPanel.Handle, true, null, overrideUserDataPath)) //if (!App.InitApp("", "", this.mRenderPanel.Width, this.mRenderPanel.Height, IntPtr.Zero, 0, this.mRenderPanel.Handle, true, null, App.StartupServices.ServicesFull, null, overrideUserDataPath, true)) { //throw new Exception("Failed to initialise CSHost"); return(false); } float endTime = this.mStopWatch.GetElapsedMilliSecs() / 1000f; this.mAppInitTime = endTime - startTime; App.StartProcessMessages(); this.mRenderingPanel.AttachToNativeCanvas(); this.mRenderingPanel.Resize += new EventHandler(RenderPanel_Resize); GameObjectFactory.Init(); SharedInitialization.RegisterResourceFactories(); if (splash != null) { splash.Message = "Initializing Scene..."; } this.mScene = new SceneManager(); if (!this.mScene.Init()) { return(false); } CameraTuning.InitializeTuningData(); this.InitializeScene(); ScriptCoreManager.Initialize(); if (splash != null) { splash.Message = "Reticulating Splines..."; } startTime = this.mStopWatch.GetElapsedMilliSecs() / 1000f; this.mSceneInitTime = startTime - endTime; this.mStopWatch.Stop(); this.mStopWatch.Reset(); this.mStopWatch.Start(); this.mTimeAtLastFrame = 0f; this.mTextRenderer = new Sims3.CSHost.Renderer.TextRenderer(); this.mGraphicsInitialized = true; return(this.InitExtra()); }