Full IUpdatable & IUpdateRequest integration with padishar's simulation.
Full IUpdatable & IUpdateRequest integration with padishar's simulation.

--- a/KerbalEngineer/Editor/BuildAdvanced.cs
+++ b/KerbalEngineer/Editor/BuildAdvanced.cs
@@ -182,17 +182,17 @@
                 }

 

                 // Configure the simulation parameters based on the selected reference body.

-                SimulationManager.Instance.Gravity = CelestialBodies.Instance.SelectedBodyInfo.Gravity;

+                SimManager.Gravity = CelestialBodies.Instance.SelectedBodyInfo.Gravity;

                 if (this.useAtmosphericDetails)

                 {

-                    SimulationManager.Instance.Atmosphere = CelestialBodies.Instance.SelectedBodyInfo.Atmosphere * 0.01d;

+                    SimManager.Atmosphere = CelestialBodies.Instance.SelectedBodyInfo.Atmosphere * 0.01d;

                 }

                 else

                 {

-                    SimulationManager.Instance.Atmosphere = 0;

-                }

-

-                SimulationManager.Instance.TryStartSimulation();

+                    SimManager.Atmosphere = 0;

+                }

+

+                SimManager.TryStartSimulation();

             }

             catch

             {

@@ -209,7 +209,7 @@
                     return;

                 }

 

-                SimulationManager.Instance.RequestSimulation();

+                SimManager.RequestSimulation();

 

                 // Change the window title based on whether in compact mode or not.

                 string title;

@@ -223,7 +223,7 @@
                 }

 

                 // Reset the window size when the staging or something else has changed.

-                int stageCount = SimulationManager.Instance.Stages.Count(stage => this.showAllStages || stage.deltaV > 0);

+                int stageCount = SimManager.Stages.Count(stage => this.showAllStages || stage.deltaV > 0);

                 if (this.hasChanged || stageCount != this.numberOfStages)

                 {

                     this.hasChanged = false;

@@ -359,7 +359,7 @@
         {

             GUILayout.BeginVertical(GUILayout.Width(30.0f));

             GUILayout.Label(string.Empty, this.titleStyle);

-            foreach (var stage in SimulationManager.Instance.Stages)

+            foreach (var stage in SimManager.Stages)

             {

                 if (this.showAllStages || stage.deltaV > 0)

                 {

@@ -376,7 +376,7 @@
         {

             GUILayout.BeginVertical(GUILayout.Width(50.0f));

             GUILayout.Label("PARTS", this.titleStyle);

-            foreach (var stage in SimulationManager.Instance.Stages)

+            foreach (var stage in SimManager.Stages)

             {

                 if (this.showAllStages || stage.deltaV > 0)

                 {

@@ -393,7 +393,7 @@
         {

             GUILayout.BeginVertical(GUILayout.Width(100.0f));

             GUILayout.Label("COST", this.titleStyle);

-            foreach (var stage in SimulationManager.Instance.Stages)

+            foreach (var stage in SimManager.Stages)

             {

                 if (this.showAllStages || stage.deltaV > 0)

                 {

@@ -410,7 +410,7 @@
         {

             GUILayout.BeginVertical(GUILayout.Width(100.0f));

             GUILayout.Label("MASS", this.titleStyle);

-            foreach (var stage in SimulationManager.Instance.Stages)

+            foreach (var stage in SimManager.Stages)

             {

                 if (this.showAllStages || stage.deltaV > 0)

                 {

@@ -427,7 +427,7 @@
         {

             GUILayout.BeginVertical(GUILayout.Width(50.0f));

             GUILayout.Label("ISP", this.titleStyle);

-            foreach (var stage in SimulationManager.Instance.Stages)

+            foreach (var stage in SimManager.Stages)

             {

                 if (this.showAllStages || stage.deltaV > 0)

                 {

@@ -444,7 +444,7 @@
         {

             GUILayout.BeginVertical(GUILayout.Width(75.0f));

             GUILayout.Label("THRUST", this.titleStyle);

-            foreach (var stage in SimulationManager.Instance.Stages)

+            foreach (var stage in SimManager.Stages)

             {

                 if (this.showAllStages || stage.deltaV > 0)

                 {

@@ -461,7 +461,7 @@
         {

             GUILayout.BeginVertical(GUILayout.Width(50.0f));

             GUILayout.Label("TWR", this.titleStyle);

-            foreach (var stage in SimulationManager.Instance.Stages)

+            foreach (var stage in SimManager.Stages)

             {

                 if (this.showAllStages || stage.deltaV > 0)

                 {

@@ -478,7 +478,7 @@
         {

             GUILayout.BeginVertical(GUILayout.Width(100.0f));

             GUILayout.Label("DELTA-V", this.titleStyle);

-            foreach (var stage in SimulationManager.Instance.Stages)

+            foreach (var stage in SimManager.Stages)

             {

                 if (this.showAllStages || stage.deltaV > 0)

                 {

@@ -495,7 +495,7 @@
         {

             GUILayout.BeginVertical(GUILayout.Width(75.0f));

             GUILayout.Label("BURN", this.titleStyle);

-            foreach (var stage in SimulationManager.Instance.Stages)

+            foreach (var stage in SimManager.Stages)

             {

                 if (this.showAllStages || stage.deltaV > 0)

                 {


--- a/KerbalEngineer/Editor/BuildOverlay.cs
+++ b/KerbalEngineer/Editor/BuildOverlay.cs
@@ -146,18 +146,18 @@
                 }

 

                 // Configure the simulation parameters based on the selected reference body.

-                SimulationManager.Instance.Gravity = CelestialBodies.Instance.SelectedBodyInfo.Gravity;

+                SimManager.Gravity = CelestialBodies.Instance.SelectedBodyInfo.Gravity;

 

                 if (BuildAdvanced.Instance.UseAtmosphericDetails)

                 {

-                    SimulationManager.Instance.Atmosphere = CelestialBodies.Instance.SelectedBodyInfo.Atmosphere * 0.01d;

+                    SimManager.Atmosphere = CelestialBodies.Instance.SelectedBodyInfo.Atmosphere * 0.01d;

                 }

                 else

                 {

-                    SimulationManager.Instance.Atmosphere = 0;

-                }

-

-                SimulationManager.Instance.TryStartSimulation();

+                    SimManager.Atmosphere = 0;

+                }

+

+                SimManager.TryStartSimulation();

             }

             catch

             {

@@ -174,7 +174,7 @@
                     return;

                 }

 

-                SimulationManager.Instance.RequestSimulation();

+                SimManager.RequestSimulation();

 

                 this.windowPosition = GUILayout.Window(this.windowId, this.windowPosition, this.Window, string.Empty, this.windowStyle);

 

@@ -237,7 +237,7 @@
 

             // Titles

             GUILayout.BeginVertical(GUILayout.Width(75.0f));

-            GUILayout.Label("Parts:", this.titleStyle);

+            //GUILayout.Label("Parts:", this.titleStyle);

             GUILayout.Label("Delta-V:", this.titleStyle);

             GUILayout.Label("TWR:", this.titleStyle);

             GUILayout.EndVertical();

@@ -245,8 +245,8 @@
             // Details

             GUILayout.BeginVertical(GUILayout.Width(100.0f));

             //GUILayout.Label(SimulationManager.Instance.LastStage.partCount.ToString("N0"), this.infoStyle);

-            GUILayout.Label(SimulationManager.Instance.LastStage.totalDeltaV.ToString("N0") + " m/s", this.infoStyle);

-            GUILayout.Label(SimulationManager.Instance.LastStage.thrustToWeight.ToString("F2"), this.infoStyle);

+            GUILayout.Label(SimManager.LastStage.totalDeltaV.ToString("N0") + " m/s", this.infoStyle);

+            GUILayout.Label(SimManager.LastStage.thrustToWeight.ToString("F2"), this.infoStyle);

             GUILayout.EndVertical();

 

             GUILayout.EndHorizontal();


--- a/KerbalEngineer/Flight/Readouts/Vessel/DeltaVStaged.cs
+++ b/KerbalEngineer/Flight/Readouts/Vessel/DeltaVStaged.cs
@@ -25,14 +25,14 @@
 

         public override void Update()

         {

-            SimulationManager.Instance.RequestSimulation();

+            SimManager.RequestUpdate();

         }

 

         public override void Draw()

         {

             var newNumberOfStages = 0;

 

-            foreach (var stage in SimulationManager.Instance.Stages)

+            foreach (var stage in SimManager.Stages)

             {

                 if (stage.deltaV > 0 || stage.number == Staging.CurrentStage)

                 {

@@ -50,7 +50,7 @@
 

         public override void Reset()

         {

-            FlightEngineerCore.Instance.AddUpdatable(SimulationManager.Instance);

+            FlightEngineerCore.Instance.AddUpdatable(SimManager.Instance);

         }

     }

 }

--- a/KerbalEngineer/Flight/Readouts/Vessel/DeltaVTotal.cs
+++ b/KerbalEngineer/Flight/Readouts/Vessel/DeltaVTotal.cs
@@ -21,17 +21,17 @@
 

         public override void Update()

         {

-            SimulationManager.Instance.RequestSimulation();

+            SimManager.RequestUpdate();

         }

 

         public override void Draw()

         {

-            this.DrawLine(SimulationManager.Instance.LastStage.totalDeltaV.ToString("N0") + "m/s");

+            this.DrawLine(SimManager.LastStage.totalDeltaV.ToString("N0") + "m/s");

         }

 

         public override void Reset()

         {

-            FlightEngineerCore.Instance.AddUpdatable(SimulationManager.Instance);

+            FlightEngineerCore.Instance.AddUpdatable(SimManager.Instance);

         }

     }

 }

--- a/KerbalEngineer/Flight/Readouts/Vessel/Mass.cs
+++ b/KerbalEngineer/Flight/Readouts/Vessel/Mass.cs
@@ -21,17 +21,17 @@
 

         public override void Update()

         {

-            SimulationManager.Instance.RequestSimulation();

+            SimManager.RequestUpdate();

         }

 

         public override void Draw()

         {

-            this.DrawLine(SimulationManager.Instance.LastStage.mass.ToMass(false) + " / " + SimulationManager.Instance.LastStage.totalMass.ToMass());

+            this.DrawLine(SimManager.LastStage.mass.ToMass(false) + " / " + SimManager.LastStage.totalMass.ToMass());

         }

 

         public override void Reset()

         {

-            FlightEngineerCore.Instance.AddUpdatable(SimulationManager.Instance);

+            FlightEngineerCore.Instance.AddUpdatable(SimManager.Instance);

         }

     }

 }

--- a/KerbalEngineer/Flight/Readouts/Vessel/SpecificImpulse.cs
+++ b/KerbalEngineer/Flight/Readouts/Vessel/SpecificImpulse.cs
@@ -20,17 +20,17 @@
 

         public override void Update()

         {

-            SimulationManager.Instance.RequestSimulation();

+            SimManager.RequestUpdate();

         }

 

         public override void Draw()

         {

-            this.DrawLine(SimulationManager.Instance.LastStage.isp.ToString("F1") + "s");

+            this.DrawLine(SimManager.LastStage.isp.ToString("F1") + "s");

         }

 

         public override void Reset()

         {

-            FlightEngineerCore.Instance.AddUpdatable(SimulationManager.Instance);

+            FlightEngineerCore.Instance.AddUpdatable(SimManager.Instance);

         }

     }

 }

--- a/KerbalEngineer/Flight/Readouts/Vessel/Thrust.cs
+++ b/KerbalEngineer/Flight/Readouts/Vessel/Thrust.cs
@@ -21,17 +21,17 @@
 

         public override void Update()

         {

-            SimulationManager.Instance.RequestSimulation();

+            SimManager.RequestUpdate();

         }

 

         public override void Draw()

         {

-            this.DrawLine(SimulationManager.Instance.LastStage.actualThrust.ToForce(false) + " / " + SimulationManager.Instance.LastStage.thrust.ToForce());

+            this.DrawLine(SimManager.LastStage.actualThrust.ToForce(false) + " / " + SimManager.LastStage.thrust.ToForce());

         }

 

         public override void Reset()

         {

-            FlightEngineerCore.Instance.AddUpdatable(SimulationManager.Instance);

+            FlightEngineerCore.Instance.AddUpdatable(SimManager.Instance);

         }

     }

 }

--- a/KerbalEngineer/Flight/Readouts/Vessel/ThrustToWeight.cs
+++ b/KerbalEngineer/Flight/Readouts/Vessel/ThrustToWeight.cs
@@ -24,19 +24,19 @@
 

         public override void Update()

         {

-            SimulationManager.Instance.RequestSimulation();

+            SimManager.RequestUpdate();

         }

 

         public override void Draw()

         {

-            this.actual = (SimulationManager.Instance.LastStage.actualThrust / (SimulationManager.Instance.LastStage.totalMass * FlightGlobals.getGeeForceAtPosition(FlightGlobals.ship_position).magnitude)).ToString("F2");

-            this.total = (SimulationManager.Instance.LastStage.thrust / (SimulationManager.Instance.LastStage.totalMass * FlightGlobals.getGeeForceAtPosition(FlightGlobals.ship_position).magnitude)).ToString("F2");

+            this.actual = (SimManager.LastStage.actualThrust / (SimManager.LastStage.totalMass * FlightGlobals.getGeeForceAtPosition(FlightGlobals.ship_position).magnitude)).ToString("F2");

+            this.total = (SimManager.LastStage.thrust / (SimManager.LastStage.totalMass * FlightGlobals.getGeeForceAtPosition(FlightGlobals.ship_position).magnitude)).ToString("F2");

             this.DrawLine("TWR", this.actual + " / " + this.total);

         }

 

         public override void Reset()

         {

-            FlightEngineerCore.Instance.AddUpdatable(SimulationManager.Instance);

+            FlightEngineerCore.Instance.AddUpdatable(SimManager.Instance);

         }

     }

 }

--- a/KerbalEngineer/KerbalEngineer.csproj
+++ b/KerbalEngineer/KerbalEngineer.csproj
@@ -121,7 +121,6 @@
     <Compile Include="Simulation\PartSim.cs" />

     <Compile Include="Simulation\ResourceContainer.cs" />

     <Compile Include="Simulation\SimManager.cs" />

-    <Compile Include="Simulation\SimulationManager.cs" />

     <Compile Include="Simulation\Simulation.cs" />

     <Compile Include="Simulation\Stage.cs" />

     <Compile Include="TapeDriveAnimator.cs" />


--- a/KerbalEngineer/Simulation/SimManager.cs
+++ b/KerbalEngineer/Simulation/SimManager.cs
@@ -1,211 +1,258 @@
-using System;

+#region

+

+using System;

 using System.Collections.Generic;

+using System.ComponentModel.Design.Serialization;

 using System.Diagnostics;

 using System.Linq;

+using System.Reflection;

 using System.Threading;

 

+using KerbalEngineer.Flight;

+

 using UnityEngine;

 

-namespace KerbalEngineer.Simulation
-{
-    public class SimManager
-    {
-        public const double RESOURCE_MIN = 0.0001;
-        
-        private static bool bRequested = false;
-        private static bool bRunning = false;
-        private static Stopwatch timer = new Stopwatch();
-        private static long delayBetweenSims = 0;
-
-        public static Stage[] Stages { get; private set; }
-        public static Stage LastStage { get; private set; }
-        public static String failMessage { get; private set; }
-
-        public static long minSimTime = 150;
-        public static double Gravity { get; set; }
-        public static double Atmosphere { get; set; }
-
-        // Support for RealFuels using reflection to check localCorrectThrust without dependency
-        private static bool hasCheckedForRealFuels = false;
-        private static bool hasInstalledRealFuels = false;
-
-        private static Type RF_ModuleEngineConfigs_Type = null;
-        private static Type RF_ModuleHybridEngine_Type = null;
-
-        private static System.Reflection.FieldInfo RF_ModuleEngineConfigs_locaCorrectThrust = null;
-        private static System.Reflection.FieldInfo RF_ModuleHybridEngine_locaCorrectThrust = null;
-
-        private static void GetRealFuelsTypes()
-        {
-			hasCheckedForRealFuels = true;
-
-			foreach (AssemblyLoader.LoadedAssembly assembly in AssemblyLoader.loadedAssemblies)
-            {
-                MonoBehaviour.print("Assembly:" + assembly.assembly.ToString());
-
-                if (assembly.assembly.ToString().Split(',')[0] == "RealFuels")
-                {
-                    MonoBehaviour.print("Found RealFuels mod");
-
-                    RF_ModuleEngineConfigs_Type = assembly.assembly.GetType("RealFuels.ModuleEngineConfigs");
-                    if (RF_ModuleEngineConfigs_Type == null)
-                    {
-                        MonoBehaviour.print("Failed to find ModuleEngineConfigs type");
-                        break;
-                    }
-
-                    RF_ModuleEngineConfigs_locaCorrectThrust = RF_ModuleEngineConfigs_Type.GetField("localCorrectThrust");
-                    if (RF_ModuleEngineConfigs_locaCorrectThrust == null)
-                    {
-                        MonoBehaviour.print("Failed to find ModuleEngineConfigs.localCorrectThrust field");
-                        break;
-                    }
-
-                    RF_ModuleHybridEngine_Type = assembly.assembly.GetType("RealFuels.ModuleHybridEngine");
-                    if (RF_ModuleHybridEngine_Type == null)
-                    {
-                        MonoBehaviour.print("Failed to find ModuleHybridEngine type");
-                        break;
-                    }
-                    
-                    RF_ModuleHybridEngine_locaCorrectThrust = RF_ModuleHybridEngine_Type.GetField("localCorrectThrust");
-                    if (RF_ModuleHybridEngine_locaCorrectThrust == null)
-                    {
-                        MonoBehaviour.print("Failed to find ModuleHybridEngine.localCorrectThrust field");
-                        break;
-                    }
-                    
-					hasInstalledRealFuels = true;
-					break;
-				}
-
-			}
-
-		}
-
-        public static bool DoesEngineUseCorrectedThrust(Part theEngine)
-        {
-            if (!hasInstalledRealFuels /*|| HighLogic.LoadedSceneIsFlight*/)
-                return false;
-
-            // Look for either of the Real Fuels engine modules and call the relevant method to find out
-            PartModule modEngineConfigs = theEngine.Modules["ModuleEngineConfigs"];
-            if (modEngineConfigs != null)
-            {
-                // Check the localCorrectThrust
-                if ((bool)RF_ModuleEngineConfigs_locaCorrectThrust.GetValue(modEngineConfigs))
-                    return true;
-            }
-
-            PartModule modHybridEngine = theEngine.Modules["ModuleHybridEngine"];
-            if (modHybridEngine != null)
-            {
-                // Check the localCorrectThrust
-                if ((bool)RF_ModuleHybridEngine_locaCorrectThrust.GetValue(modHybridEngine))
-                    return true;
-            }
-
-            return false;
-        }
-
-
-        public static void RequestSimulation()
-        {
-            if (!hasCheckedForRealFuels)
-                GetRealFuelsTypes();
-
-            bRequested = true;
-            if (!timer.IsRunning)
-                timer.Start();
-        }
-
-        public static void TryStartSimulation()
-        {
-            if (bRequested && !bRunning && (HighLogic.LoadedSceneIsEditor || FlightGlobals.ActiveVessel != null) && timer.ElapsedMilliseconds > delayBetweenSims)
-            {
-                bRequested = false;
-                timer.Reset();
-                StartSimulation();
-            }
-        }
-
-        public static bool ResultsReady()
-        {
-            return !bRunning;
-        }
-
-        private static void ClearResults()
-        {
-            failMessage = "";
-            Stages = null;
-            LastStage = null;
-        }
-
-        private static void StartSimulation()
-        {
-            try
-            {
-                bRunning = true;
-                ClearResults();
-                timer.Start();
-
-                List<Part> parts = HighLogic.LoadedSceneIsEditor ? EditorLogic.SortedShipList : FlightGlobals.ActiveVessel.Parts;
-
-                // Create the Simulation object in this thread
-                Simulation sim = new Simulation();
-
-                // This call doesn't ever fail at the moment but we'll check and return a sensible error for display
-                if (sim.PrepareSimulation(parts, Gravity, Atmosphere))
-                {
-                    ThreadPool.QueueUserWorkItem(RunSimulation, sim);
-                }
-                else
-                {
-                    failMessage = "PrepareSimulation failed";
-                    bRunning = false;
-                }
-            }
-            catch (Exception e)
-            {
-                MonoBehaviour.print("Exception in StartSimulation: " + e);
-                failMessage = e.ToString();
-                bRunning = false;
-            }
-        }
-
-        private static void RunSimulation(object simObject)
-        {
-            try
-            {
-                Stages = (simObject as Simulation).RunSimulation();
-                if (Stages != null)
-                {
+#endregion

+

+namespace KerbalEngineer.Simulation

+{

+    public class SimManager : IUpdatable, IUpdateRequest

+    {

+        #region Instance

+

+        private static readonly SimManager instance = new SimManager();

+

+        public static SimManager Instance

+        {

+            get { return instance; }

+        }

+

+        #endregion

+

+        public const double RESOURCE_MIN = 0.0001;

+

+        private static bool bRequested;

+        private static bool bRunning;

+        private static readonly Stopwatch timer = new Stopwatch();

+        private static long delayBetweenSims;

+

+        public static long minSimTime = 150;

+

+        // Support for RealFuels using reflection to check localCorrectThrust without dependency

+        private static bool hasCheckedForRealFuels;

+        private static bool hasInstalledRealFuels;

+

+        private static Type RF_ModuleEngineConfigs_Type;

+        private static Type RF_ModuleHybridEngine_Type;

+

+        private static FieldInfo RF_ModuleEngineConfigs_locaCorrectThrust;

+        private static FieldInfo RF_ModuleHybridEngine_locaCorrectThrust;

+        public static Stage[] Stages { get; private set; }

+        public static Stage LastStage { get; private set; }

+        public static String failMessage { get; private set; }

+        public static double Gravity { get; set; }

+        public static double Atmosphere { get; set; }

+

+        #region IUpdatable Members

+

+        public void Update()

+        {

+            TryStartSimulation();

+        }

+

+        #endregion

+

+        #region IUpdateRequest Members

+

+        public bool UpdateRequested { get; set; }

+

+        #endregion

+

+        public static void RequestUpdate()

+        {

+            instance.UpdateRequested = true;

+            RequestSimulation();

+        }

+

+        private static void GetRealFuelsTypes()

+        {

+            hasCheckedForRealFuels = true;

+

+            foreach (AssemblyLoader.LoadedAssembly assembly in AssemblyLoader.loadedAssemblies)

+            {

+                MonoBehaviour.print("Assembly:" + assembly.assembly);

+

+                if (assembly.assembly.ToString().Split(',')[0] == "RealFuels")

+                {

+                    MonoBehaviour.print("Found RealFuels mod");

+

+                    RF_ModuleEngineConfigs_Type = assembly.assembly.GetType("RealFuels.ModuleEngineConfigs");

+                    if (RF_ModuleEngineConfigs_Type == null)

+                    {

+                        MonoBehaviour.print("Failed to find ModuleEngineConfigs type");

+                        break;

+                    }

+

+                    RF_ModuleEngineConfigs_locaCorrectThrust = RF_ModuleEngineConfigs_Type.GetField("localCorrectThrust");

+                    if (RF_ModuleEngineConfigs_locaCorrectThrust == null)

+                    {

+                        MonoBehaviour.print("Failed to find ModuleEngineConfigs.localCorrectThrust field");

+                        break;

+                    }

+

+                    RF_ModuleHybridEngine_Type = assembly.assembly.GetType("RealFuels.ModuleHybridEngine");

+                    if (RF_ModuleHybridEngine_Type == null)

+                    {

+                        MonoBehaviour.print("Failed to find ModuleHybridEngine type");

+                        break;

+                    }

+

+                    RF_ModuleHybridEngine_locaCorrectThrust = RF_ModuleHybridEngine_Type.GetField("localCorrectThrust");

+                    if (RF_ModuleHybridEngine_locaCorrectThrust == null)

+                    {

+                        MonoBehaviour.print("Failed to find ModuleHybridEngine.localCorrectThrust field");

+                        break;

+                    }

+

+                    hasInstalledRealFuels = true;

+                    break;

+                }

+            }

+        }

+

+        public static bool DoesEngineUseCorrectedThrust(Part theEngine)

+        {

+            if (!hasInstalledRealFuels /*|| HighLogic.LoadedSceneIsFlight*/)

+            {

+                return false;

+            }

+

+            // Look for either of the Real Fuels engine modules and call the relevant method to find out

+            PartModule modEngineConfigs = theEngine.Modules["ModuleEngineConfigs"];

+            if (modEngineConfigs != null)

+            {

+                // Check the localCorrectThrust

+                if ((bool)RF_ModuleEngineConfigs_locaCorrectThrust.GetValue(modEngineConfigs))

+                {

+                    return true;

+                }

+            }

+

+            PartModule modHybridEngine = theEngine.Modules["ModuleHybridEngine"];

+            if (modHybridEngine != null)

+            {

+                // Check the localCorrectThrust

+                if ((bool)RF_ModuleHybridEngine_locaCorrectThrust.GetValue(modHybridEngine))

+                {

+                    return true;

+                }

+            }

+

+            return false;

+        }

+

+        public static void RequestSimulation()

+        {

+            if (!hasCheckedForRealFuels)

+            {

+                GetRealFuelsTypes();

+            }

+

+            bRequested = true;

+            if (!timer.IsRunning)

+            {

+                timer.Start();

+            }

+        }

+

+        public static void TryStartSimulation()

+        {

+            if (bRequested && !bRunning && (HighLogic.LoadedSceneIsEditor || FlightGlobals.ActiveVessel != null) && timer.ElapsedMilliseconds > delayBetweenSims)

+            {

+                bRequested = false;

+                timer.Reset();

+                StartSimulation();

+            }

+        }

+

+        public static bool ResultsReady()

+        {

+            return !bRunning;

+        }

+

+        private static void ClearResults()

+        {

+            failMessage = "";

+            Stages = null;

+            LastStage = null;

+        }

+

+        private static void StartSimulation()

+        {

+            try

+            {

+                bRunning = true;

+                ClearResults();

+                timer.Start();

+

+                List<Part> parts = HighLogic.LoadedSceneIsEditor ? EditorLogic.SortedShipList : FlightGlobals.ActiveVessel.Parts;

+

+                // Create the Simulation object in this thread

+                Simulation sim = new Simulation();

+

+                // This call doesn't ever fail at the moment but we'll check and return a sensible error for display

+                if (sim.PrepareSimulation(parts, Gravity, Atmosphere))

+                {

+                    ThreadPool.QueueUserWorkItem(RunSimulation, sim);

+                }

+                else

+                {

+                    failMessage = "PrepareSimulation failed";

+                    bRunning = false;

+                }

+            }

+            catch (Exception e)

+            {

+                MonoBehaviour.print("Exception in StartSimulation: " + e);

+                failMessage = e.ToString();

+                bRunning = false;

+            }

+        }

+

+        private static void RunSimulation(object simObject)

+        {

+            try

+            {

+                Stages = (simObject as Simulation).RunSimulation();

+                if (Stages != null)

+                {

 #if LOG
                     foreach (Stage stage in Stages)
                         stage.Dump();
-#endif
-                    LastStage = Stages.Last();
-                }
-            }
-            catch (Exception e)
-            {
-                MonoBehaviour.print("Exception in RunSimulation: " + e);
-                Stages = null;
-                LastStage = null;
-                failMessage = e.ToString();
-            }
-
-            timer.Stop();
-            MonoBehaviour.print("Total simulation time: " + timer.ElapsedMilliseconds + "ms");
-            delayBetweenSims = minSimTime - timer.ElapsedMilliseconds;
-            if (delayBetweenSims < 0)
-                delayBetweenSims = 0;
-
-            timer.Reset();
-            timer.Start();
-
-            bRunning = false;
-        }
-    }
+#endif

+                    LastStage = Stages.Last();

+                }

+            }

+            catch (Exception e)

+            {

+                MonoBehaviour.print("Exception in RunSimulation: " + e);

+                Stages = null;

+                LastStage = null;

+                failMessage = e.ToString();

+            }

+

+            timer.Stop();

+            MonoBehaviour.print("Total simulation time: " + timer.ElapsedMilliseconds + "ms");

+            delayBetweenSims = minSimTime - timer.ElapsedMilliseconds;

+            if (delayBetweenSims < 0)

+            {

+                delayBetweenSims = 0;

+            }

+

+            timer.Reset();

+            timer.Start();

+

+            bRunning = false;

+        }

+    }

 }
-

--- a/KerbalEngineer/Simulation/SimulationManager.cs
+++ /dev/null
@@ -1,80 +1,1 @@
-// Project:	KerbalEngineer

-// Author:	CYBUTEK

-// License:	Attribution-NonCommercial-ShareAlike 3.0 Unported

-

-#region Using Directives

-

-using System;

-

-using KerbalEngineer.Flight;

-

-#endregion

-

-namespace KerbalEngineer.Simulation

-{

-    public class SimulationManager : IUpdatable

-    {

-        #region Instance

-

-        private static readonly SimulationManager instance = new SimulationManager();

-

-        /// <summary>

-        ///     Gets the current instance of the simulation manager.

-        /// </summary>

-        public static SimulationManager Instance

-        {

-            get { return instance; }

-        }

-

-        #endregion

-

-        #region Properties

-

-        public Stage[] Stages

-        {

-            get { return SimManager.Stages; }

-        }

-

-        public Stage LastStage

-        {

-            get { return SimManager.LastStage; }

-        }

-

-        public double Gravity

-        {

-            get { return SimManager.Gravity; }

-            set { SimManager.Atmosphere = value; }

-        }

-

-        public double Atmosphere

-        {

-            get { return SimManager.Atmosphere; }

-            set { SimManager.Atmosphere = value; }

-        }

-

-        #endregion

-

-        #region IUpdatable Members

-

-        public void Update()

-        {

-            this.TryStartSimulation();

-        }

-

-        #endregion

-

-        #region Methods

-

-        public void RequestSimulation()

-        {

-            SimManager.RequestSimulation();

-        }

-

-        public void TryStartSimulation()

-        {

-            SimManager.TryStartSimulation();

-        }

-

-        #endregion

-    }

-}
+

 Binary files a/Output/KerbalEngineer/KerbalEngineer.dll and b/Output/KerbalEngineer/KerbalEngineer.dll differ