Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.03 KB | None | 0 0
  1. //Dispose method of my Application Core
  2.  
  3.         #region Dispose
  4.         /// <summary>
  5.         ///
  6.         /// </summary>
  7.         public virtual void Dispose()
  8.         {
  9.             if (this.mIsDisposed)
  10.                 return;
  11.  
  12.             //Disposing Cohesion Managers and Components
  13.             this.mRegisteredLocationStructures.Clear();
  14.  
  15.             Log cohesionLog = LogManager.Instance.GetLog(LOGFILE);
  16.             cohesionLog.MessageLogged -= LogConsole.Instance.MessageLogged;
  17.  
  18.             this.CleanUpScene();
  19.  
  20.             //Dispose all Managers, using inverse priority order
  21.             if (this.mManagers != null)
  22.             {
  23.                 for (int i = this.mManagers.Count - 1; i >= 0; i--)
  24.                     this.mManagers[this.mManagers.Keys[i]].Dispose();
  25.  
  26.                 this.mManagers.Clear();
  27.                 this.mManagers = null;
  28.             }
  29.  
  30.             //Disposing Axiom Engine
  31.             if (Root.Instance != null)
  32.             {
  33.                 // remove event handlers
  34.                 Root.Instance.FrameStarted          -= this.OnFrameStartedDo;
  35.                 Root.Instance.FrameEnded            -= this.OnFrameEndedDo;
  36.                 Root.Instance.FrameRenderingQueued  -= this.OnFrameRenderingQueuedDo;
  37.             }
  38.  
  39.             this.Platform.ShutDown();
  40.  
  41.             if (Root.Instance != null)
  42.                 Root.Instance.RenderSystem.DetachRenderTarget(this.RenderWindow);
  43.  
  44. #if !( XBOX || XBOX360 )
  45.             WindowEventMonitor.Instance.UnregisterListener(this.RenderWindow, this.mWindowListener);
  46.             this.mWindowListener = null;
  47. #endif
  48.  
  49.             if (this.RenderWindow != null)
  50.             {
  51.                 if (!this.RenderWindow.IsDisposed)
  52.                     this.RenderWindow.Dispose();
  53.  
  54.                 this.RenderWindow = null;
  55.             }
  56.  
  57.             if (Root.Instance!= null)
  58.                 Root.Instance.Dispose();
  59.  
  60.             this.mIsDisposed = true;
  61.         }
  62.         #endregion
  63.  
  64. //Here it is the CleanUpScene method implementation
  65.  
  66.         #region CleanUpScene (private)
  67.         /// <summary>
  68.         ///
  69.         /// </summary>
  70.         internal void CleanUpScene()
  71.         {
  72.             if (this.SceneManager == null)
  73.                 return;
  74.  
  75.             this.SceneManager.RemoveAllBillboardSets();
  76.             CameraManager.Instance.RemoveAllCameras();
  77.             this.SceneManager.RemoveAllEntities();
  78.             this.SceneManager.RemoveAllLights();
  79.             this.SceneManager.RemoveAllRibonTrails();
  80.             //this.SceneManager.DestroyAllAnimations(); task accomplished by ClearScene
  81.             this.SceneManager.DestroyAllAnimationStates();
  82.             //this.SceneManager.DestroyAllMovableObjects(); task accomplished by ClearScene
  83.             //this.SceneManager.DestroyAllOverlays(); //not done 'cause it will remove overlays of debugpanel that cannot be removed XD
  84.             this.SceneManager.DestroyAllStaticGeometry();
  85.             this.SceneManager.ClearScene();
  86.         }
  87.         #endregion CleanUpScene (private)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement