Added IntakeAir Usage readout.
[VesselSimulator.git] / KerbalEngineer / Flight / Readouts / Vessel / IntakeAirDemandSupply.cs
blob:a/KerbalEngineer/Flight/Readouts/Vessel/IntakeAirDemandSupply.cs -> blob:b/KerbalEngineer/Flight/Readouts/Vessel/IntakeAirDemandSupply.cs
--- a/KerbalEngineer/Flight/Readouts/Vessel/IntakeAirDemandSupply.cs
+++ b/KerbalEngineer/Flight/Readouts/Vessel/IntakeAirDemandSupply.cs
@@ -21,6 +21,8 @@
 
 using System.Linq;
 
+using KerbalEngineer.Flight.Sections;
+
 #endregion
 
 namespace KerbalEngineer.Flight.Readouts.Vessel
@@ -41,7 +43,7 @@
             this.Name = "Intake Air (D/S)";
             this.Category = ReadoutCategory.GetCategory("Vessel");
             this.HelpString = string.Empty;
-            this.IsDefault = true;
+            this.IsDefault = false;
         }
 
         #endregion
@@ -53,20 +55,11 @@
             var demand = 0.0;
             foreach (var part in FlightGlobals.ActiveVessel.Parts)
             {
-                if (part.Modules.Contains("ModuleEngines"))
+                for (int i = 0; i < part.Modules.Count; i++)
                 {
-                    var engine = part.Modules["ModuleEngines"] as ModuleEngines;
-                    if (engine.isOperational)
-                    {
-                        demand += engine.propellants
-                            .Where(p => p.name == "IntakeAir")
-                            .Sum(p => p.currentRequirement);
-                    }
-                }
-                if (part.Modules.Contains("ModuleEnginesFX"))
-                {
-                    var engine = part.Modules["ModuleEngines"] as ModuleEnginesFX;
-                    if (engine.isOperational)
+                    PartModule partmod = part.Modules[i];
+                    var engine = partmod as ModuleEngines;
+                    if (engine != null && engine.isOperational)
                     {
                         demand += engine.propellants
                             .Where(p => p.name == "IntakeAir")
@@ -84,9 +77,9 @@
                 .Sum(p => p.Resources["IntakeAir"].amount);
         }
 
-        public override void Draw()
+        public override void Draw(SectionModule section)
         {
-            this.DrawLine(this.demand.ToString("F4") + " / " + this.supply.ToString("F4"));
+            this.DrawLine(this.demand.ToString("F4") + " / " + this.supply.ToString("F4"), section.IsHud);
         }
 
         public override void Update()