Fixed issues with IntakeAir readouts.
[VesselSimulator.git] / KerbalEngineer / Flight / Readouts / Vessel / IntakeAirSupply.cs
blob:a/KerbalEngineer/Flight/Readouts/Vessel/IntakeAirSupply.cs -> blob:b/KerbalEngineer/Flight/Readouts/Vessel/IntakeAirSupply.cs
--- a/KerbalEngineer/Flight/Readouts/Vessel/IntakeAirSupply.cs
+++ b/KerbalEngineer/Flight/Readouts/Vessel/IntakeAirSupply.cs
@@ -19,7 +19,7 @@
 
 #region Using Directives
 
-using System.Linq;
+
 
 #endregion
 
@@ -27,7 +27,13 @@
 {
     public class IntakeAirSupply : ReadoutModule
     {
+        #region Fields
+
         private double supply;
+
+        #endregion
+
+        #region Constructors
 
         public IntakeAirSupply()
         {
@@ -37,27 +43,20 @@
             this.IsDefault = true;
         }
 
-        public override void Update()
-        {
-            foreach (var part in FlightGlobals.ActiveVessel.Parts.Where(part => part.Modules.Contains("ModuleEngines") && (part.Modules["ModuleEngines"] as ModuleEngines).propellants.Exists(prop => prop.name == "IntakeAir")))
-            {
-                if (part.inverseStage == Staging.CurrentStage)
-                {
-                    var engine = (part.Modules["ModuleEngines"] as ModuleEngines);
-                    foreach (var propellant in engine.propellants)
-                    {
-                        if (propellant.name == "IntakeAir")
-                        {
-                            this.supply = propellant.currentAmount;
-                        }
-                    }
-                }
-            }
-        }
+        #endregion
+
+        #region Methods: public
 
         public override void Draw()
         {
-            this.DrawLine(this.supply.ToString("F3"));
+            this.DrawLine(this.supply.ToString("F4"));
         }
+
+        public override void Update()
+        {
+            this.supply = IntakeAirSupplyDemand.GetSupply();
+        }
+
+        #endregion
     }
 }