Moved from Math.Pow to direct multiplication throughout.
[VOID.git] / VOID_VesselInfo.cs
blob:a/VOID_VesselInfo.cs -> blob:b/VOID_VesselInfo.cs
--- a/VOID_VesselInfo.cs
+++ b/VOID_VesselInfo.cs
@@ -48,8 +48,6 @@
 
 		public override void ModuleWindow(int _)
 		{
-			base.ModuleWindow (_);
-
 			if ((TimeWarp.WarpMode == TimeWarp.Modes.LOW) || (TimeWarp.CurrentRate <= TimeWarp.MaxPhysicsRate))
 			{
 				SimManager.RequestSimulation();
@@ -59,7 +57,7 @@
 
 			GUILayout.Label(
 				vessel.vesselName,
-				VOID_Core.Instance.LabelStyles["center_bold"],
+				core.LabelStyles["center_bold"],
 				GUILayout.ExpandWidth(true));
 
 			VOID_Data.geeForce.DoGUIHorizontal ("F2");
@@ -68,7 +66,9 @@
 
 			VOID_Data.totalMass.DoGUIHorizontal ("F3");
 
-			VOID_Data.resourceMass.DoGUIHorizontal ("F3");
+			VOID_Data.stageResourceMass.DoGUIHorizontal("F2");
+
+			VOID_Data.resourceMass.DoGUIHorizontal("F2");
 
 			VOID_Data.stageDeltaV.DoGUIHorizontal (3, false);
 
@@ -94,13 +94,13 @@
 	{
 		public static readonly VOID_DoubleValue geeForce = new VOID_DoubleValue(
 			"G-force",
-			new Func<double>(() => VOID_Core.Instance.vessel.geeForce),
+			new Func<double>(() => core.vessel.geeForce),
 			"gees"
 		);
 
 		public static readonly VOID_IntValue partCount = new VOID_IntValue(
 			"Parts",
-			new Func<int>(() => VOID_Core.Instance.vessel.Parts.Count),
+			new Func<int>(() => core.vessel.Parts.Count),
 			""
 		);
 
@@ -108,12 +108,12 @@
 			"Total Mass",
 			delegate()
 		{
-			if (SimManager.Stages == null || SimManager.LastStage == null)
+			if (core.Stages == null || core.LastStage == null)
 			{
 				return double.NaN;
 			}
 
-			return SimManager.LastStage.totalMass;
+			return core.LastStage.totalMass;
 		},
 			"tons"
 		);
@@ -122,23 +122,48 @@
 			"Resource Mass",
 			delegate()
 			{
-				if (SimManager.Stages == null || SimManager.LastStage == null)
+				if (core.Stages == null || core.LastStage == null)
 				{
 					return double.NaN;
 				}
 
-				return SimManager.LastStage.totalBaseMass;
+				return core.LastStage.totalMass - core.LastStage.totalBaseMass;
 			},
 			"tons"
+		);
+
+		public static readonly VOID_DoubleValue stageResourceMass = new VOID_DoubleValue(
+			"Resource Mass (Stage)",
+			delegate()
+			{
+				if (core.LastStage == null)
+				{
+					return double.NaN;
+				}
+
+				return core.LastStage.mass - core.LastStage.baseMass;
+			},
+			"tons"
+		);
+
+		public static readonly VOID_StrValue comboResourceMass = new VOID_StrValue(
+			"Resource Mass (curr / total)",
+			delegate()
+		{
+			return string.Format("{0} / {1}",
+				stageResourceMass.ValueUnitString("F3"),
+				resourceMass.ValueUnitString("F3")
+			);
+		}
 		);
 
 		public static readonly VOID_DoubleValue stageDeltaV = new VOID_DoubleValue(
 			"DeltaV (Current Stage)",
 			delegate()
 			{
-				if (SimManager.Stages == null || SimManager.LastStage == null)
-					return double.NaN;
-				return SimManager.LastStage.deltaV;
+			if (core.Stages == null || core.LastStage == null)
+					return double.NaN;
+				return core.LastStage.deltaV;
 			},
 			"m/s"
 		);
@@ -147,16 +172,16 @@
 			"DeltaV (Total)",
 			delegate()
 			{
-				if (SimManager.Stages == null || SimManager.LastStage == null)
-					return double.NaN;
-				return SimManager.LastStage.totalDeltaV;
+			if (core.Stages == null || core.LastStage == null)
+					return double.NaN;
+				return core.LastStage.totalDeltaV;
 			},
 			"m/s"
 		);
 
 		public static readonly VOID_FloatValue mainThrottle = new VOID_FloatValue(
 			"Throttle",
-			new Func<float>(() => VOID_Core.Instance.vessel.ctrlState.mainThrottle * 100f),
+			new Func<float>(() => core.vessel.ctrlState.mainThrottle * 100f),
 			"%"
 		);
 
@@ -164,11 +189,11 @@
 			"Thrust (curr/max)",
 			delegate()
 			{
-				if (SimManager.Stages == null || SimManager.LastStage == null)
+				if (core.Stages == null || core.LastStage == null)
 					return "N/A";
 
-				double currThrust = SimManager.LastStage.actualThrust;
-				double maxThrust = SimManager.LastStage.thrust;
+				double currThrust = core.LastStage.actualThrust;
+				double maxThrust = core.LastStage.thrust;
 
 				return string.Format(
 					"{0} / {1}",
@@ -182,12 +207,12 @@
 			"T:W Ratio",
 			delegate()
 		{
-			if (SimManager.LastStage == null)
+			if (core.LastStage == null)
 			{
 				return double.NaN;
 			}
 
-			return SimManager.LastStage.actualThrustToWeight;
+			return core.LastStage.actualThrustToWeight;
 		},
 			""
 		);
@@ -196,12 +221,12 @@
 			"T:W Ratio",
 			delegate()
 		{
-			if (SimManager.LastStage == null)
+			if (core.LastStage == null)
 			{
 				return double.NaN;
 			}
 
-			return SimManager.LastStage.maxThrustToWeight;
+			return core.LastStage.thrustToWeight;
 		},
 			""
 		);
@@ -210,7 +235,7 @@
 			"T:W (curr/max)",
 			delegate()
 			{
-				if (SimManager.Stages == null || SimManager.LastStage == null)
+				if (core.Stages == null || core.LastStage == null)
 					return "N/A";
 
 				return string.Format(
@@ -225,13 +250,13 @@
 			"Max T:W @ surface",
 			delegate()
 			{
-			if (SimManager.Stages == null || SimManager.LastStage == null)
-					return double.NaN;
-
-				double maxThrust = SimManager.LastStage.thrust;
-				double mass = SimManager.LastStage.totalMass;
-				double gravity = (VOID_Core.Constant_G * VOID_Core.Instance.vessel.mainBody.Mass) /
-				(VOID_Core.Instance.vessel.mainBody.Radius * VOID_Core.Instance.vessel.mainBody.Radius);
+			if (core.Stages == null || core.LastStage == null)
+					return double.NaN;
+
+				double maxThrust = core.LastStage.thrust;
+				double mass = core.LastStage.totalMass;
+				double gravity = (VOID_Core.Constant_G * core.vessel.mainBody.Mass) /
+				(core.vessel.mainBody.Radius * core.vessel.mainBody.Radius);
 				double weight = mass * gravity;
 
 				return maxThrust / weight;
@@ -249,7 +274,7 @@
 				currentAmount = 0d;
 				currentRequirement = 0d;
 
-				foreach (Part part in VOID_Core.Instance.vessel.Parts)
+				foreach (Part part in core.vessel.Parts)
 				{
 					if (part.enabled)
 					{