VOID_Core, VOID_EditorCore: Added new toggle to disable engineering calcs.
[VOID.git] / VOID_EditorCore.cs
blob:a/VOID_EditorCore.cs -> blob:b/VOID_EditorCore.cs
--- a/VOID_EditorCore.cs
+++ b/VOID_EditorCore.cs
@@ -26,7 +26,7 @@
 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-using Engineer.VesselSimulator;
+using KerbalEngineer.VesselSimulator;
 using KSP;
 using System;
 using System.Collections.Generic;
@@ -69,8 +69,17 @@
 			if (_initialized)
 			{
 				_instance.StopGUI();
+				_instance.Dispose();
 				_instance = null;
 				_initialized = false;
+			}
+		}
+
+		protected override ApplicationLauncher.AppScenes appIconVisibleScenes
+		{
+			get
+			{
+				return ApplicationLauncher.AppScenes.VAB | ApplicationLauncher.AppScenes.SPH;
 			}
 		}
 
@@ -79,7 +88,7 @@
 			this._Name = "VOID Editor Core";
 		}
 
-		public new void OnGUI() {}
+		public override void OnGUI() {}
 
 		public override void DrawGUI()
 		{
@@ -90,7 +99,7 @@
 
 			Rect _iconPos = Tools.DockToWindow (this.VOIDIconPos, this.mainWindowPos);
 
-			_iconPos = Tools.ClampRectToScreen (_iconPos, (int)_iconPos.width, (int)_iconPos.height);
+			_iconPos = Tools.ClampRectToEditorPad (_iconPos);
 
 			if (_iconPos != this.VOIDIconPos)
 			{
@@ -100,11 +109,13 @@
 			base.DrawGUI();
 		}
 
-		public new void Update()
+		public override void Update()
 		{
+			this.LoadBeforeUpdate();
+
 			foreach (IVOID_EditorModule module in this.Modules)
 			{
-				if (EditorLogic.startPod == null)
+				if (EditorLogic.RootPart == null)
 				{
 					module.StopGUI();
 					continue;
@@ -119,7 +130,7 @@
 				}
 			}
 
-			if (EditorLogic.startPod == null || !HighLogic.LoadedSceneIsEditor)
+			if (EditorLogic.RootPart == null || !HighLogic.LoadedSceneIsEditor)
 			{
 				this.StopGUI();
 				return;
@@ -131,14 +142,14 @@
 
 			if (EditorLogic.SortedShipList.Count > 0 && this.vesselSimActive)
 			{
-				SimManager.Gravity = VOID_Data.KerbinGee;
-				SimManager.TryStartSimulation();
+				Tools.PostDebugMessage(this, "Updating SimManager.");
+				this.UpdateSimManager();
 			}
 
 			this.CheckAndSave ();
 		}
 
-		public new void FixedUpdate() {}
+		public override void FixedUpdate() {}
 	}
 }