Added HUD sections to the Flight Engineer.
[VesselSimulator.git] / KerbalEngineer / Flight / Readouts / Vessel / SimulationProcessor.cs
blob:a/KerbalEngineer/Flight/Readouts/Vessel/SimulationProcessor.cs -> blob:b/KerbalEngineer/Flight/Readouts/Vessel/SimulationProcessor.cs
--- a/KerbalEngineer/Flight/Readouts/Vessel/SimulationProcessor.cs
+++ b/KerbalEngineer/Flight/Readouts/Vessel/SimulationProcessor.cs
@@ -19,14 +19,19 @@
 
 #region Using Directives
 
-using System;
 
-using KerbalEngineer.VesselSimulator;
 
 #endregion
 
 namespace KerbalEngineer.Flight.Readouts.Vessel
 {
+    #region Using Directives
+
+    using System;
+    using VesselSimulator;
+
+    #endregion
+
     public class SimulationProcessor : IUpdatable, IUpdateRequest
     {
         #region Instance
@@ -34,6 +39,15 @@
         #region Fields
 
         private static readonly SimulationProcessor instance = new SimulationProcessor();
+
+        #endregion
+
+        #region Constructors
+
+        static SimulationProcessor()
+        {
+            SimManager.OnReady += GetStageInfo;
+        }
 
         #endregion
 
@@ -72,7 +86,13 @@
 
         #endregion
 
-        #region Methods: public
+        #region Methods
+
+        private static void GetStageInfo()
+        {
+            Stages = SimManager.Stages;
+            LastStage = SimManager.LastStage;
+        }
 
         public static void RequestUpdate()
         {
@@ -82,14 +102,12 @@
         public void Update()
         {
             SimManager.RequestSimulation();
+            SimManager.TryStartSimulation();
 
             if (!SimManager.ResultsReady())
             {
                 return;
             }
-
-            Stages = SimManager.Stages;
-            LastStage = SimManager.LastStage;
 
             if (Stages != null && LastStage != null)
             {
@@ -101,11 +119,8 @@
                 SimManager.Gravity = FlightGlobals.ActiveVessel.mainBody.gravParameter /
                                      Math.Pow(FlightGlobals.ActiveVessel.mainBody.Radius +
                                               FlightGlobals.ActiveVessel.mainBody.GetAltitude(FlightGlobals.ActiveVessel.CoM), 2);
-                SimManager.Velocity = FlightGlobals.ActiveVessel.srfSpeed;
+                SimManager.Mach = FlightGlobals.ActiveVessel.mach;
             }
-            // Cybutek: We should be allowing this to be set too but not sure where you want to put the control
-            //SimManager.vectoredThrust = vectoredThrust; 
-            SimManager.TryStartSimulation();
         }
 
         #endregion