Added IntakeAir supply/demand 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;
+using KerbalEngineer.Flight.Sections;
 
 #endregion
 
@@ -27,37 +27,36 @@
 {
     public class IntakeAirSupply : ReadoutModule
     {
+        #region Fields
+
         private double supply;
+
+        #endregion
+
+        #region Constructors
 
         public IntakeAirSupply()
         {
             this.Name = "Intake Air (Supply)";
             this.Category = ReadoutCategory.GetCategory("Vessel");
-            this.HelpString = string.Empty;
-            this.IsDefault = true;
+            this.HelpString = "Displays the available Intake Air.";
+            this.IsDefault = false;
+        }
+
+        #endregion
+
+        #region Methods: public
+
+        public override void Draw(SectionModule section)
+        {
+            this.DrawLine(this.supply.ToString("F4"), section.IsHud);
         }
 
         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;
-                        }
-                    }
-                }
-            }
+            this.supply = IntakeAirDemandSupply.GetSupply();
         }
 
-        public override void Draw()
-        {
-            this.DrawLine(this.supply.ToString("F3"));
-        }
+        #endregion
     }
 }