VOID_Data: More organizing.
[VOID.git] / VOID_Data.cs
blob:a/VOID_Data.cs -> blob:b/VOID_Data.cs
// VOID // VOID
// //
// VOID_Data.cs // VOID_Data.cs
// //
// Copyright © 2014, toadicus // Copyright © 2014, toadicus
// All rights reserved. // All rights reserved.
// //
// Redistribution and use in source and binary forms, with or without modification, // Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met: // are permitted provided that the following conditions are met:
// //
// 1. Redistributions of source code must retain the above copyright notice, // 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer. // this list of conditions and the following disclaimer.
// //
// 2. Redistributions in binary form must reproduce the above copyright notice, // 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation and/or other // this list of conditions and the following disclaimer in the documentation and/or other
// materials provided with the distribution. // materials provided with the distribution.
// //
// 3. Neither the name of the copyright holder nor the names of its contributors may be used // 3. Neither the name of the copyright holder nor the names of its contributors may be used
// to endorse or promote products derived from this software without specific prior written permission. // to endorse or promote products derived from this software without specific prior written permission.
// //
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   
using Engineer.VesselSimulator; using Engineer.VesselSimulator;
using KSP; using KSP;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using ToadicusTools; using ToadicusTools;
using UnityEngine; using UnityEngine;
   
namespace VOID namespace VOID
{ {
public static class VOID_Data public static class VOID_Data
{ {
#region Constants #region Constants
   
private static double kerbinGee; private static double kerbinGee;
   
public static double KerbinGee public static double KerbinGee
{ {
get get
{ {
if (kerbinGee == default(double)) if (kerbinGee == default(double))
{ {
kerbinGee = core.Kerbin.gravParameter / (core.Kerbin.Radius * core.Kerbin.Radius); kerbinGee = core.Kerbin.gravParameter / (core.Kerbin.Radius * core.Kerbin.Radius);
} }
   
return kerbinGee; return kerbinGee;
} }
} }
   
#endregion #endregion
   
#region Core Data #region Core Data
   
public static VOID_Core core public static VOID_Core core
{ {
get get
{ {
if (HighLogic.LoadedSceneIsEditor) if (HighLogic.LoadedSceneIsEditor)
{ {
return VOID_EditorCore.Instance; return VOID_EditorCore.Instance;
} }
else else
{ {
return VOID_Core.Instance; return VOID_Core.Instance;
} }
} }
} }
   
#endregion #endregion
   
#region Atmosphere #region Atmosphere
   
public static readonly VOID_DoubleValue atmDensity = public static readonly VOID_DoubleValue atmDensity =
new VOID_DoubleValue( new VOID_DoubleValue(
"Atmosphere Density", "Atmosphere Density",
new Func<double>(() => core.vessel.atmDensity * 1000f), new Func<double>(() => core.vessel.atmDensity * 1000f),
"g/m³" "g/m³"
); );
   
public static readonly VOID_FloatValue atmLimit = public static readonly VOID_FloatValue atmLimit =
new VOID_FloatValue( new VOID_FloatValue(
"Atmosphere Limit", "Atmosphere Limit",
new Func<float>(() => core.vessel.mainBody.maxAtmosphereAltitude), new Func<float>(() => core.vessel.mainBody.maxAtmosphereAltitude),
"m" "m"
); );
   
public static readonly VOID_DoubleValue atmPressure = public static readonly VOID_DoubleValue atmPressure =
new VOID_DoubleValue( new VOID_DoubleValue(
"Pressure", "Pressure",
new Func<double>(() => core.vessel.staticPressure), new Func<double>(() => core.vessel.staticPressure),
"atm" "atm"
); );
   
public static readonly VOID_FloatValue temperature = public static readonly VOID_FloatValue temperature =
new VOID_FloatValue( new VOID_FloatValue(
"Temperature", "Temperature",
new Func<float>(() => core.vessel.flightIntegrator.getExternalTemperature()), new Func<float>(() => core.vessel.flightIntegrator.getExternalTemperature()),
"°C" "°C"
); );
   
#endregion #endregion
   
#region Attitude #region Attitude
   
public static readonly VOID_StrValue vesselHeading = public static readonly VOID_StrValue vesselHeading =
new VOID_StrValue( new VOID_StrValue(
"Heading", "Heading",
delegate() delegate()
{ {
double heading = core.vessel.getSurfaceHeading(); double heading = core.vessel.getSurfaceHeading();
string cardinal = VOID_Tools.get_heading_text(heading); string cardinal = VOID_Tools.get_heading_text(heading);
   
return string.Format( return string.Format(
"{0}° {1}", "{0}° {1}",
heading.ToString("F2"), heading.ToString("F2"),
cardinal cardinal
); );
} }
); );
   
public static readonly VOID_DoubleValue vesselPitch = public static readonly VOID_DoubleValue vesselPitch =
new VOID_DoubleValue( new VOID_DoubleValue(
"Pitch", "Pitch",
() => core.vessel.getSurfacePitch(), () => core.vessel.getSurfacePitch(),
"°" "°"
); );
   
#endregion #endregion
   
#region Career #region Career
   
public static readonly VOID_StrValue fundingStatus = public static readonly VOID_StrValue fundingStatus =
new VOID_StrValue( new VOID_StrValue(
string.Intern("Funds"), string.Intern("Funds"),
delegate() delegate()
{ {
if (VOID_CareerStatus.Instance == null) if (VOID_CareerStatus.Instance == null)
{ {
return string.Empty; return string.Empty;
} }
   
return string.Format("{0} ({1})", return string.Format("{0} ({1})",
VOID_CareerStatus.Instance.currentFunds.ToString("#,#.##"), VOID_CareerStatus.Instance.currentFunds.ToString("#,#.##"),
VOID_CareerStatus.formatDelta(VOID_CareerStatus.Instance.lastFundsChange) VOID_CareerStatus.formatDelta(VOID_CareerStatus.Instance.lastFundsChange)
); );
} }
); );
   
public static readonly VOID_StrValue reputationStatus = public static readonly VOID_StrValue reputationStatus =
new VOID_StrValue( new VOID_StrValue(
string.Intern("Reputation"), string.Intern("Reputation"),
delegate() delegate()
{ {
if (VOID_CareerStatus.Instance == null) if (VOID_CareerStatus.Instance == null)
{ {
return string.Empty; return string.Empty;
} }
   
return string.Format("{0} ({1})", return string.Format("{0} ({1})",
VOID_CareerStatus.Instance.currentReputation.ToString("#,#.##"), VOID_CareerStatus.Instance.currentReputation.ToString("#,#.##"),
VOID_CareerStatus.formatDelta(VOID_CareerStatus.Instance.lastRepChange) VOID_CareerStatus.formatDelta(VOID_CareerStatus.Instance.lastRepChange)
); );
} }
); );
   
public static readonly VOID_StrValue scienceStatus = public static readonly VOID_StrValue scienceStatus =
new VOID_StrValue( new VOID_StrValue(
string.Intern("Science"), string.Intern("Science"),
delegate() delegate()
{ {
if (VOID_CareerStatus.Instance == null) if (VOID_CareerStatus.Instance == null)
{ {
return string.Empty; return string.Empty;
} }
   
return string.Format("{0} ({1})", return string.Format("{0} ({1})",
VOID_CareerStatus.Instance.currentScience.ToString("#,#.##"), VOID_CareerStatus.Instance.currentScience.ToString("#,#.##"),
VOID_CareerStatus.formatDelta(VOID_CareerStatus.Instance.lastScienceChange) VOID_CareerStatus.formatDelta(VOID_CareerStatus.Instance.lastScienceChange)
); );
} }
); );
   
#endregion #endregion
   
#region Control #region Control
   
public static readonly VOID_FloatValue mainThrottle = public static readonly VOID_FloatValue mainThrottle =
new VOID_FloatValue( new VOID_FloatValue(
"Throttle", "Throttle",
new Func<float>(() => core.vessel.ctrlState.mainThrottle * 100f), new Func<float>(() => core.vessel.ctrlState.mainThrottle * 100f),
"%" "%"
); );
   
#endregion #endregion
   
#region Engineering #region Engineering
   
public static readonly VOID_IntValue partCount = public static readonly VOID_IntValue partCount =
new VOID_IntValue( new VOID_IntValue(
"Parts", "Parts",
new Func<int>(() => core.vessel.Parts.Count), new Func<int>(() => core.vessel.Parts.Count),
"" ""
); );
   
#region Mass #region Mass
   
public static readonly VOID_StrValue comboResourceMass = public static readonly VOID_StrValue comboResourceMass =
new VOID_StrValue( new VOID_StrValue(
"Resource Mass (curr / total)", "Resource Mass (curr / total)",
delegate() delegate()
{ {
return string.Format("{0} / {1}", return string.Format("{0} / {1}",
stageResourceMass.ValueUnitString("F3"), stageResourceMass.ValueUnitString("F3"),
resourceMass.ValueUnitString("F3") resourceMass.ValueUnitString("F3")
); );
} }
); );
   
public static readonly VOID_DoubleValue resourceMass = public static readonly VOID_DoubleValue resourceMass =
new VOID_DoubleValue( new VOID_DoubleValue(
"Resource Mass", "Resource Mass",
delegate() delegate()
{ {
if (core.Stages == null || core.LastStage == null) if (core.Stages == null || core.LastStage == null)
{ {
return double.NaN; return double.NaN;
} }
   
return core.LastStage.totalMass - core.LastStage.totalBaseMass; return core.LastStage.totalMass - core.LastStage.totalBaseMass;
}, },
"tons" "tons"
); );
   
public static readonly VOID_DoubleValue stageResourceMass = public static readonly VOID_DoubleValue stageResourceMass =
new VOID_DoubleValue( new VOID_DoubleValue(
"Resource Mass (Stage)", "Resource Mass (Stage)",
delegate() delegate()
{ {
if (core.LastStage == null) if (core.LastStage == null)
{ {
return double.NaN; return double.NaN;
} }
   
return core.LastStage.mass - core.LastStage.baseMass; return core.LastStage.mass - core.LastStage.baseMass;
}, },
"tons" "tons"
); );
   
public static readonly VOID_DoubleValue totalMass = public static readonly VOID_DoubleValue totalMass =
new VOID_DoubleValue( new VOID_DoubleValue(
"Total Mass", "Total Mass",
delegate() delegate()
{ {
if (core.Stages == null || core.LastStage == null) if (core.Stages == null || core.LastStage == null)
{ {
return double.NaN; return double.NaN;
} }
   
return core.LastStage.totalMass; return core.LastStage.totalMass;
}, },
"tons" "tons"
); );
   
#endregion #endregion
   
#region DeltaV #region DeltaV
   
public static readonly VOID_DoubleValue stageDeltaV = public static readonly VOID_DoubleValue stageDeltaV =
new VOID_DoubleValue( new VOID_DoubleValue(
"DeltaV (Current Stage)", "DeltaV (Current Stage)",
delegate() delegate()
{ {
if (core.Stages == null || core.LastStage == null) if (core.Stages == null || core.LastStage == null)
return double.NaN; return double.NaN;
return core.LastStage.deltaV; return core.LastStage.deltaV;
}, },
"m/s" "m/s"
); );
   
public static readonly VOID_DoubleValue totalDeltaV = public static readonly VOID_DoubleValue totalDeltaV =
new VOID_DoubleValue( new VOID_DoubleValue(
"DeltaV (Total)", "DeltaV (Total)",
delegate() delegate()
{ {
if (core.Stages == null || core.LastStage == null) if (core.Stages == null || core.LastStage == null)
return double.NaN; return double.NaN;
return core.LastStage.totalDeltaV; return core.LastStage.totalDeltaV;
}, },
"m/s" "m/s"
); );
   
#endregion #endregion
   
#region Propulsion #region Propulsion
   
public static readonly VOID_StrValue currmaxThrustWeight = public static readonly VOID_StrValue currmaxThrustWeight =
new VOID_StrValue( new VOID_StrValue(
"T:W (curr/max)", "T:W (curr/max)",
delegate() delegate()
{ {
if (core.Stages == null || core.LastStage == null) if (core.Stages == null || core.LastStage == null)
return "N/A"; return "N/A";
   
return string.Format( return string.Format(
"{0} / {1}", "{0} / {1}",
(VOID_Data.currThrustWeight.Value).ToString("F2"), (VOID_Data.currThrustWeight.Value).ToString("F2"),
(VOID_Data.maxThrustWeight.Value).ToString("F2") (VOID_Data.maxThrustWeight.Value).ToString("F2")
); );
} }
); );
   
public static readonly VOID_StrValue currmaxThrust = public static readonly VOID_StrValue currmaxThrust =
new VOID_StrValue( new VOID_StrValue(
"Thrust (curr/max)", "Thrust (curr/max)",
delegate() delegate()
{ {
if (core.Stages == null || core.LastStage == null) if (core.Stages == null || core.LastStage == null)
return "N/A"; return "N/A";
   
double currThrust = core.LastStage.actualThrust; double currThrust = core.LastStage.actualThrust;
double maxThrust = core.LastStage.thrust; double maxThrust = core.LastStage.thrust;
   
return string.Format( return string.Format(
"{0} / {1}", "{0} / {1}",
currThrust.ToString("F1"), currThrust.ToString("F1"),
maxThrust.ToString("F1") maxThrust.ToString("F1")
); );
} }
); );
   
public static readonly VOID_DoubleValue stageMassFlow = public static readonly VOID_DoubleValue stageMassFlow =
new VOID_DoubleValue( new VOID_DoubleValue(
"Stage Mass Flow", "Stage Mass Flow",
delegate() delegate()
{ {
if (core.LastStage == null) if (core.LastStage == null)
{ {
return double.NaN; return double.NaN;
} }
   
double stageIsp = core.LastStage.isp; double stageIsp = core.LastStage.isp;
double stageThrust = stageNominalThrust; double stageThrust = stageNominalThrust;
   
Tools.PostDebugMessage(typeof(VOID_Data), "calculating stageMassFlow from:\n" + Tools.PostDebugMessage(typeof(VOID_Data), "calculating stageMassFlow from:\n" +
"\tstageIsp: {0}\n" + "\tstageIsp: {0}\n" +
"\tstageThrust: {1}\n" + "\tstageThrust: {1}\n" +
"\tKerbinGee: {2}\n", "\tKerbinGee: {2}\n",
stageIsp, stageIsp,
stageThrust, stageThrust,
KerbinGee KerbinGee
); );
   
return stageThrust / (stageIsp * KerbinGee); return stageThrust / (stageIsp * KerbinGee);
}, },
"Mg/s" "Mg/s"
); );
   
public static readonly VOID_DoubleValue stageNominalThrust = public static readonly VOID_DoubleValue stageNominalThrust =
new VOID_DoubleValue( new VOID_DoubleValue(
"Nominal Stage Thrust", "Nominal Stage Thrust",
delegate() delegate()
{ {
if (core.LastStage == null) if (core.LastStage == null)
{ {
return double.NaN; return double.NaN;
} }
   
if (core.LastStage.actualThrust == 0d) if (core.LastStage.actualThrust == 0d)
{ {
return core.LastStage.thrust; return core.LastStage.thrust;
} }
else else
{ {
return core.LastStage.actualThrust; return core.LastStage.actualThrust;
} }
}, },
"kN" "kN"
); );
   
#endregion #endregion
   
#region Kinetics #region Kinetics
   
public static readonly VOID_DoubleValue currThrustWeight = public static readonly VOID_DoubleValue currThrustWeight =
new VOID_DoubleValue( new VOID_DoubleValue(
"T:W Ratio", "T:W Ratio",
delegate() delegate()
{ {
if (core.LastStage == null) if (core.LastStage == null)
{ {
return double.NaN; return double.NaN;
} }
   
return core.LastStage.actualThrustToWeight; return core.LastStage.actualThrustToWeight;
}, },
"" ""
); );
   
   
   
public static readonly VOID_DoubleValue maxThrustWeight = public static readonly VOID_DoubleValue maxThrustWeight =
new VOID_DoubleValue( new VOID_DoubleValue(
"T:W Ratio", "T:W Ratio",
delegate() delegate()
{ {
if (core.LastStage == null) if (core.LastStage == null)
{ {
return double.NaN; return double.NaN;
} }
   
return core.LastStage.thrustToWeight; return core.LastStage.thrustToWeight;
}, },
"" ""
); );
   
public static readonly VOID_DoubleValue nominalThrustWeight = public static readonly VOID_DoubleValue nominalThrustWeight =
new VOID_DoubleValue( new VOID_DoubleValue(
"Thrust-to-Weight Ratio", "Thrust-to-Weight Ratio",
delegate() delegate()
{ {
if (HighLogic.LoadedSceneIsEditor || currThrustWeight.Value == 0d) if (HighLogic.LoadedSceneIsEditor || currThrustWeight.Value == 0d)
{ {
return maxThrustWeight.Value; return maxThrustWeight.Value;
} }
   
return currThrustWeight.Value; return currThrustWeight.Value;
}, },
"" ""
); );
   
public static readonly VOID_DoubleValue surfaceThrustWeight = public static readonly VOID_DoubleValue surfaceThrustWeight =
new VOID_DoubleValue( new VOID_DoubleValue(
"Max T:W @ surface", "Max T:W @ surface",
delegate() delegate()
{ {
if (core.Stages == null || core.LastStage == null) if (core.Stages == null || core.LastStage == null)
return double.NaN; return double.NaN;
   
double maxThrust = core.LastStage.thrust; double maxThrust = core.LastStage.thrust;
double mass = core.LastStage.totalMass; double mass = core.LastStage.totalMass;
double gravity = (VOID_Core.Constant_G * core.vessel.mainBody.Mass) / double gravity = (VOID_Core.Constant_G * core.vessel.mainBody.Mass) /
(core.vessel.mainBody.Radius * core.vessel.mainBody.Radius); (core.vessel.mainBody.Radius * core.vessel.mainBody.Radius);
double weight = mass * gravity; double weight = mass * gravity;
   
return maxThrust / weight; return maxThrust / weight;
}, },
"" ""
); );
   
public static readonly VOID_Vector3dValue vesselThrustOffset = public static readonly VOID_Vector3dValue vesselThrustOffset =
new VOID_Vector3dValue( new VOID_Vector3dValue(
"Thrust Offset", "Thrust Offset",
delegate() delegate()
{ {
if (core.vessel == null) if (core.vessel == null)
{ {
return Vector3d.zero; return Vector3d.zero;
} }
   
List<PartModule> engineModules = core.vessel.getModulesOfType<PartModule>(); List<PartModule> engineModules = core.vessel.getModulesOfType<PartModule>();
   
Vector3d thrustPos = Vector3d.zero; Vector3d thrustPos = Vector3d.zero;
Vector3d thrustDir = Vector3d.zero; Vector3d thrustDir = Vector3d.zero;
float thrust = 0; float thrust = 0;
   
foreach (PartModule engine in engineModules) foreach (PartModule engine in engineModules)
{ {
float moduleThrust = 0; float moduleThrust = 0;
   
switch (engine.moduleName) switch (engine.moduleName)
{ {
case "ModuleEngines": case "ModuleEngines":
case "ModuleEnginesFX": case "ModuleEnginesFX":
break; break;
default: default:
continue; continue;
} }
   
if (!engine.isEnabled) if (!engine.isEnabled)
{ {
continue; continue;
} }
   
CenterOfThrustQuery cotQuery = new CenterOfThrustQuery(); CenterOfThrustQuery cotQuery = new CenterOfThrustQuery();
   
if (engine is ModuleEngines) if (engine is ModuleEngines)
{ {
ModuleEngines engineModule = engine as ModuleEngines; ModuleEngines engineModule = engine as ModuleEngines;
   
moduleThrust = engineModule.finalThrust; moduleThrust = engineModule.finalThrust;
   
engineModule.OnCenterOfThrustQuery(cotQuery); engineModule.OnCenterOfThrustQuery(cotQuery);
} }
else // engine is ModuleEnginesFX else // engine is ModuleEnginesFX
{ {
ModuleEnginesFX engineFXModule = engine as ModuleEnginesFX; ModuleEnginesFX engineFXModule = engine as ModuleEnginesFX;
   
moduleThrust = engineFXModule.finalThrust; moduleThrust = engineFXModule.finalThrust;
   
engineFXModule.OnCenterOfThrustQuery(cotQuery); engineFXModule.OnCenterOfThrustQuery(cotQuery);
} }
   
if (moduleThrust != 0d) if (moduleThrust != 0d)
{ {
cotQuery.thrust = moduleThrust; cotQuery.thrust = moduleThrust;
} }
   
thrustPos += cotQuery.pos * cotQuery.thrust; thrustPos += cotQuery.pos * cotQuery.thrust;
thrustDir += cotQuery.dir * cotQuery.thrust; thrustDir += cotQuery.dir * cotQuery.thrust;
thrust += cotQuery.thrust; thrust += cotQuery.thrust;
} }
   
if (thrust != 0) if (thrust != 0)
{ {
thrustPos /= thrust; thrustPos /= thrust;
thrustDir /= thrust; thrustDir /= thrust;
} }
   
Transform vesselTransform = core.vessel.transform; Transform vesselTransform = core.vessel.transform;
   
thrustPos = vesselTransform.InverseTransformPoint(thrustPos); thrustPos = vesselTransform.InverseTransformPoint(thrustPos);
thrustDir = vesselTransform.InverseTransformDirection(thrustDir); thrustDir = vesselTransform.InverseTransformDirection(thrustDir);
   
Vector3d thrustOffset = VectorTools.PointDistanceToLine( Vector3d thrustOffset = VectorTools.PointDistanceToLine(
thrustPos, thrustDir.normalized, core.vessel.findLocalCenterOfMass()); thrustPos, thrustDir.normalized, core.vessel.findLocalCenterOfMass());
   
Tools.PostDebugMessage(typeof(VOID_Data), "vesselThrustOffset:\n" + Tools.PostDebugMessage(typeof(VOID_Data), "vesselThrustOffset:\n" +
"\tthrustPos: {0}\n" + "\tthrustPos: {0}\n" +
"\tthrustDir: {1}\n" + "\tthrustDir: {1}\n" +
"\tthrustOffset: {2}\n" + "\tthrustOffset: {2}\n" +
"\tvessel.CoM: {3}", "\tvessel.CoM: {3}",
thrustPos, thrustPos,
thrustDir.normalized, thrustDir.normalized,
thrustOffset, thrustOffset,
core.vessel.findWorldCenterOfMass() core.vessel.findWorldCenterOfMass()
); );
   
return thrustOffset; return thrustOffset;
}, },
"m" "m"
); );
   
#endregion #endregion
   
#region Air Breathing #region Air Breathing
   
public static readonly VOID_StrValue intakeAirStatus = public static readonly VOID_StrValue intakeAirStatus =
new VOID_StrValue( new VOID_StrValue(
"Intake Air (Curr / Req)", "Intake Air (Curr / Req)",
delegate() delegate()
{ {
double currentAmount; double currentAmount;
double currentRequirement; double currentRequirement;
   
currentAmount = 0d; currentAmount = 0d;
currentRequirement = 0d; currentRequirement = 0d;
   
foreach (Part part in core.vessel.Parts) foreach (Part part in core.vessel.Parts)
{ {
if (part.enabled) if (part.enabled)
{ {
ModuleEngines engineModule; ModuleEngines engineModule;
ModuleEnginesFX enginesFXModule; ModuleEnginesFX enginesFXModule;
List<Propellant> propellantList = null; List<Propellant> propellantList = null;
   
if (part.tryGetFirstModuleOfType<ModuleEngines>(out engineModule)) if (part.tryGetFirstModuleOfType<ModuleEngines>(out engineModule))
{ {
propellantList = engineModule.propellants; propellantList = engineModule.propellants;
} }
else if (part.tryGetFirstModuleOfType<ModuleEnginesFX>(out enginesFXModule)) else if (part.tryGetFirstModuleOfType<ModuleEnginesFX>(out enginesFXModule))
{ {
propellantList = enginesFXModule.propellants; propellantList = enginesFXModule.propellants;
} }
   
if (propellantList != null) if (propellantList != null)
{ {
foreach (Propellant propellant in propellantList) foreach (Propellant propellant in propellantList)
{ {
if (propellant.name == "IntakeAir") if (propellant.name == "IntakeAir")
{ {
currentRequirement += propellant.currentRequirement / TimeWarp.fixedDeltaTime; currentRequirement += propellant.currentRequirement / TimeWarp.fixedDeltaTime;
break; break;
} }
} }
} }
} }
   
ModuleResourceIntake intakeModule; ModuleResourceIntake intakeModule;
   
if (part.enabled && part.tryGetFirstModuleOfType<ModuleResourceIntake>(out intakeModule)) if (part.enabled && part.tryGetFirstModuleOfType<ModuleResourceIntake>(out intakeModule))
{ {
if (intakeModule.resourceName == "IntakeAir") if (intakeModule.resourceName == "IntakeAir")
{ {
currentAmount += intakeModule.airFlow; currentAmount += intakeModule.airFlow;
} }
} }
} }
   
if (currentAmount == 0 && currentRequirement == 0) if (currentAmount == 0 && currentRequirement == 0)
{ {
return "N/A"; return "N/A";
} }
   
return string.Format("{0:F3} / {1:F3}", currentAmount, currentRequirement); return string.Format("{0:F3} / {1:F3}", currentAmount, currentRequirement);
} }
); );
   
#endregion #endregion
   
#region Crew #region Crew
   
public static readonly VOID_IntValue vesselCrewCount = public static readonly VOID_IntValue vesselCrewCount =
new VOID_IntValue( new VOID_IntValue(
"Crew Onboard", "Crew Onboard",
delegate() delegate()
{ {
if (core.vessel != null) if (core.vessel != null)
{ {
return core.vessel.GetCrewCount(); return core.vessel.GetCrewCount();
} }
else else
{ {
return 0; return 0;
} }
}, },
"" ""
); );
   
public static readonly VOID_IntValue vesselCrewCapacity = public static readonly VOID_IntValue vesselCrewCapacity =
new VOID_IntValue( new VOID_IntValue(
"Crew Capacity", "Crew Capacity",
delegate() delegate()
{ {
if (core.vessel != null) if (core.vessel != null)
{ {
return core.vessel.GetCrewCapacity(); return core.vessel.GetCrewCapacity();
} }
else else
{ {
return 0; return 0;
} }
}, },
"" ""
); );
   
#endregion #endregion
   
#endregion #endregion
   
#region Location #region Location
   
public static readonly VOID_DoubleValue downrangeDistance = public static readonly VOID_DoubleValue downrangeDistance =
new VOID_DoubleValue( new VOID_DoubleValue(
"Downrange Distance", "Downrange Distance",
delegate() delegate()
{ {
   
if (core.vessel == null || if (core.vessel == null ||
Planetarium.fetch == null || Planetarium.fetch == null ||
core.vessel.mainBody != Planetarium.fetch.Home) core.vessel.mainBody != Planetarium.fetch.Home)
{ {
return double.NaN; return double.NaN;
} }
   
double vesselLongitude = core.vessel.longitude * Math.PI / 180d; double vesselLongitude = core.vessel.longitude * Math.PI / 180d;
double vesselLatitude = core.vessel.latitude * Math.PI / 180d; double vesselLatitude = core.vessel.latitude * Math.PI / 180d;
   
const double kscLongitude = 285.442323427289 * Math.PI / 180d; const double kscLongitude = 285.442323427289 * Math.PI / 180d;
const double kscLatitude = -0.0972112860655246 * Math.PI / 180d; const double kscLatitude = -0.0972112860655246 * Math.PI / 180d;
   
double diffLon = vesselLongitude - kscLongitude; double diffLon = vesselLongitude - kscLongitude;
double diffLat = vesselLatitude - kscLatitude; double diffLat = vesselLatitude - kscLatitude;
   
double sinHalfDiffLat = Math.Sin(diffLat / 2d); double sinHalfDiffLat = Math.Sin(diffLat / 2d);
double sinHalfDiffLon = Math.Sin(diffLon / 2d); double sinHalfDiffLon = Math.Sin(diffLon / 2d);
   
double cosVesselLon = Math.Cos(vesselLongitude); double cosVesselLon = Math.Cos(vesselLongitude);
double cosKSCLon = Math.Cos(kscLongitude); double cosKSCLon = Math.Cos(kscLongitude);
   
double haversine = double haversine =
sinHalfDiffLat * sinHalfDiffLat + sinHalfDiffLat * sinHalfDiffLat +
cosVesselLon * cosKSCLon * sinHalfDiffLon * sinHalfDiffLon; cosVesselLon * cosKSCLon * sinHalfDiffLon * sinHalfDiffLon;
   
double arc = 2d * Math.Atan2(Math.Sqrt(haversine), Math.Sqrt(1d - haversine)); double arc = 2d * Math.Atan2(Math.Sqrt(haversine), Math.Sqrt(1d - haversine));
   
return core.vessel.mainBody.Radius * arc; return core.vessel.mainBody.Radius * arc;
}, },
"m" "m"
); );
   
public static readonly VOID_StrValue surfLatitude = public static readonly VOID_StrValue surfLatitude =
new VOID_StrValue( new VOID_StrValue(
"Latitude", "Latitude",
new Func<string>(() => VOID_Tools.GetLatitudeString(core.vessel)) new Func<string>(() => VOID_Tools.GetLatitudeString(core.vessel))
); );
   
public static readonly VOID_StrValue surfLongitude = public static readonly VOID_StrValue surfLongitude =
new VOID_StrValue( new VOID_StrValue(
"Longitude", "Longitude",
new Func<string>(() => VOID_Tools.GetLongitudeString(core.vessel)) new Func<string>(() => VOID_Tools.GetLongitudeString(core.vessel))
); );
   
public static readonly VOID_DoubleValue trueAltitude = public static readonly VOID_DoubleValue trueAltitude =
new VOID_DoubleValue( new VOID_DoubleValue(
"Altitude (true)", "Altitude (true)",
delegate() delegate()
{ {
double alt_true = core.vessel.orbit.altitude - core.vessel.terrainAltitude; double alt_true = core.vessel.orbit.altitude - core.vessel.terrainAltitude;
// HACK: This assumes that on worlds with oceans, all water is fixed at 0 m, // HACK: This assumes that on worlds with oceans, all water is fixed at 0 m,
// and water covers the whole surface at 0 m. // and water covers the whole surface at 0 m.
if (core.vessel.terrainAltitude < 0 && core.vessel.mainBody.ocean) if (core.vessel.terrainAltitude < 0 && core.vessel.mainBody.ocean)
alt_true = core.vessel.orbit.altitude; alt_true = core.vessel.orbit.altitude;
return alt_true; return alt_true;
}, },
"m" "m"
); );
   
#endregion #endregion
   
#region Kinematics #region Kinematics
   
  public static readonly VOID_DoubleValue geeForce =
  new VOID_DoubleValue(
  "G-force",
  new Func<double>(() => core.vessel.geeForce),
  "gees"
  );
   
  public static readonly VOID_DoubleValue horzVelocity =
  new VOID_DoubleValue(
  "Horizontal speed",
  new Func<double>(() => core.vessel.horizontalSrfSpeed),
  "m/s"
  );
   
public static readonly VOID_DoubleValue surfVelocity = public static readonly VOID_DoubleValue surfVelocity =
new VOID_DoubleValue( new VOID_DoubleValue(
"Surface velocity", "Surface velocity",
new Func<double>(() => core.vessel.srf_velocity.magnitude), new Func<double>(() => core.vessel.srf_velocity.magnitude),
"m/s" "m/s"
); );
   
public static readonly VOID_DoubleValue vertVelocity = public static readonly VOID_DoubleValue vertVelocity =
new VOID_DoubleValue( new VOID_DoubleValue(
"Vertical speed", "Vertical speed",
new Func<double>(() => core.vessel.verticalSpeed), new Func<double>(() => core.vessel.verticalSpeed),
"m/s" "m/s"
); );
   
public static readonly VOID_DoubleValue horzVelocity =  
new VOID_DoubleValue(  
"Horizontal speed",  
new Func<double>(() => core.vessel.horizontalSrfSpeed),  
"m/s"  
);  
   
public static readonly VOID_DoubleValue geeForce =  
new VOID_DoubleValue(  
"G-force",  
new Func<double>(() => core.vessel.geeForce),  
"gees"  
);  
   
   
public static readonly VOID_DoubleValue vesselAngularVelocity =  
new VOID_DoubleValue(  
"Angular Velocity",  
delegate()  
{  
if (core.vessel != null)  
{  
return core.vessel.angularVelocity.magnitude;  
}  
else  
{  
return double.NaN;  
}  
},  
"rad/s"  
);  
   
public static readonly VOID_DoubleValue vesselAccel = public static readonly VOID_DoubleValue vesselAccel =
new VOID_DoubleValue( new VOID_DoubleValue(
"Acceleration", "Acceleration",
() => geeForce * KerbinGee, () => geeForce * KerbinGee,
"m/s²" "m/s²"
  );
   
  public static readonly VOID_DoubleValue vesselAngularVelocity =
  new VOID_DoubleValue(
  "Angular Velocity",
  delegate()
  {
  if (core.vessel != null)
  {
  return core.vessel.angularVelocity.magnitude;
  }
  else
  {
  return double.NaN;
  }
  },
  "rad/s"
); );
   
#endregion #endregion
   
#region Navigation #region Navigation
   
public static int upcomingManeuverNodes public static int upcomingManeuverNodes
{ {
get get
{ {
if (core.vessel == null || if (core.vessel == null ||
core.vessel.patchedConicSolver == null || core.vessel.patchedConicSolver == null ||
core.vessel.patchedConicSolver.maneuverNodes == null) core.vessel.patchedConicSolver.maneuverNodes == null)
{ {
return 0; return 0;
} }
   
return core.vessel.patchedConicSolver.maneuverNodes.Count; return core.vessel.patchedConicSolver.maneuverNodes.Count;
} }
} }
   
public static readonly VOID_DoubleValue currManeuverDeltaV =  
new VOID_DoubleValue(  
"Current Maneuver Delta-V",  
delegate()  
{  
if (upcomingManeuverNodes > 0)  
{  
return core.vessel.patchedConicSolver.maneuverNodes[0].DeltaV.magnitude;  
}  
else  
{  
return double.NaN;  
}  
},  
"m/s"  
);  
   
public static readonly VOID_DoubleValue currManeuverDVRemaining =  
new VOID_DoubleValue(  
"Remaining Maneuver Delta-V",  
delegate()  
{  
if (upcomingManeuverNodes > 0)  
{  
return core.vessel.patchedConicSolver.maneuverNodes[0].GetBurnVector(core.vessel.orbit).magnitude;  
}  
else  
{  
return double.NaN;  
}  
},  
"m/s"  
);  
   
public static readonly VOID_DoubleValue nextManeuverDeltaV =  
new VOID_DoubleValue(  
"Current Maneuver Delta-V",  
delegate()  
{  
if (upcomingManeuverNodes > 1)  
{  
return core.vessel.patchedConicSolver.maneuverNodes[1].DeltaV.magnitude;  
}  
else  
{  
return double.NaN;  
}  
},  
"m/s"  
);  
   
public static readonly VOID_DoubleValue currentNodeBurnDuration =  
new VOID_DoubleValue(  
"Total Burn Time",  
delegate()  
{  
if (core.LastStage == null || currManeuverDeltaV.Value == double.NaN)  
{  
return double.NaN;  
}  
   
double stageThrust = stageNominalThrust;  
   
return burnTime(currManeuverDeltaV.Value, totalMass, stageMassFlow, stageThrust);  
},  
"s"  
);  
   
public static readonly VOID_DoubleValue currentNodeBurnRemaining =  
new VOID_DoubleValue(  
"Burn Time Remaining",  
delegate()  
{  
if (core.LastStage == null || currManeuverDVRemaining == double.NaN)  
{  
return double.NaN;  
}  
   
double stageThrust = stageNominalThrust;  
   
return burnTime(currManeuverDVRemaining, totalMass, stageMassFlow, stageThrust);  
},  
"s"  
);  
   
public static readonly VOID_DoubleValue currentNodeHalfBurnDuration =  
new VOID_DoubleValue(  
"Half Burn Time",  
delegate()  
{  
if (core.LastStage == null || currManeuverDeltaV.Value == double.NaN)  
{  
return double.NaN;  
}  
   
double stageThrust = stageNominalThrust;  
   
return burnTime(currManeuverDeltaV.Value / 2d, totalMass, stageMassFlow, stageThrust);  
},  
"s"  
);  
   
public static readonly VOID_StrValue burnTimeDoneAtNode = public static readonly VOID_StrValue burnTimeDoneAtNode =
new VOID_StrValue( new VOID_StrValue(
"Full burn time to be half done at node", "Full burn time to be half done at node",
delegate() delegate()
{ {
if (core.LastStage == null && upcomingManeuverNodes < 1) if (core.LastStage == null && upcomingManeuverNodes < 1)
{ {
return "N/A"; return "N/A";
} }
   
ManeuverNode node = core.vessel.patchedConicSolver.maneuverNodes[0]; ManeuverNode node = core.vessel.patchedConicSolver.maneuverNodes[0];
   
if ((node.UT - Planetarium.GetUniversalTime()) < 0) if ((node.UT - Planetarium.GetUniversalTime()) < 0)
{ {
return string.Empty; return string.Empty;
} }
   
double interval = (node.UT - currentNodeBurnDuration) - Planetarium.GetUniversalTime(); double interval = (node.UT - currentNodeBurnDuration) - Planetarium.GetUniversalTime();
   
if (double.IsNaN(interval)) if (double.IsNaN(interval))
{ {
return string.Intern("NaN"); return string.Intern("NaN");
} }
   
int sign = Math.Sign(interval); int sign = Math.Sign(interval);
interval = Math.Abs(interval); interval = Math.Abs(interval);
   
string format; string format;
   
if (sign >= 0) if (sign >= 0)
{ {
format = string.Intern("T - {0}"); format = string.Intern("T - {0}");
} }
else else
{ {
format = string.Intern("T + {0}"); format = string.Intern("T + {0}");
} }
   
return string.Format(format, VOID_Tools.ConvertInterval(interval)); return string.Format(format, VOID_Tools.ConvertInterval(interval));
} }
); );
   
public static readonly VOID_StrValue burnTimeHalfDoneAtNode = public static readonly VOID_StrValue burnTimeHalfDoneAtNode =
new VOID_StrValue( new VOID_StrValue(
"Full burn time to be half done at node", "Full burn time to be half done at node",
delegate() delegate()
{ {
if (core.LastStage == null && upcomingManeuverNodes < 1) if (core.LastStage == null && upcomingManeuverNodes < 1)
{ {
return "N/A"; return "N/A";
} }
   
ManeuverNode node = core.vessel.patchedConicSolver.maneuverNodes[0]; ManeuverNode node = core.vessel.patchedConicSolver.maneuverNodes[0];
   
if ((node.UT - Planetarium.GetUniversalTime()) < 0) if ((node.UT - Planetarium.GetUniversalTime()) < 0)
{ {
return string.Empty; return string.Empty;
} }
   
double interval = (node.UT - currentNodeHalfBurnDuration) - Planetarium.GetUniversalTime(); double interval = (node.UT - currentNodeHalfBurnDuration) - Planetarium.GetUniversalTime();
   
if (double.IsNaN(interval)) if (double.IsNaN(interval))
{ {
return string.Intern("NaN"); return string.Intern("NaN");
} }
   
int sign = Math.Sign(interval); int sign = Math.Sign(interval);
interval = Math.Abs(interval); interval = Math.Abs(interval);
   
string format; string format;
   
if (sign >= 0) if (sign >= 0)
{ {
format = string.Intern("T - {0}"); format = string.Intern("T - {0}");
} }
else else
{ {
format = string.Intern("T + {0}"); format = string.Intern("T + {0}");
} }
   
return string.Format(format, VOID_Tools.ConvertInterval(interval)); return string.Format(format, VOID_Tools.ConvertInterval(interval));
} }
  );
   
  public static readonly VOID_DoubleValue currManeuverDeltaV =
  new VOID_DoubleValue(
  "Current Maneuver Delta-V",
  delegate()
  {
  if (upcomingManeuverNodes > 0)
  {
  return core.vessel.patchedConicSolver.maneuverNodes[0].DeltaV.magnitude;
  }
  else
  {
  return double.NaN;
  }
  },
  "m/s"
  );
   
  public static readonly VOID_DoubleValue currManeuverDVRemaining =
  new VOID_DoubleValue(
  "Remaining Maneuver Delta-V",
  delegate()
  {
  if (upcomingManeuverNodes > 0)
  {
  return core.vessel.patchedConicSolver.maneuverNodes[0].GetBurnVector(core.vessel.orbit).magnitude;
  }
  else
  {
  return double.NaN;
  }
  },
  "m/s"
  );
   
  public static readonly VOID_DoubleValue currentNodeBurnDuration =
  new VOID_DoubleValue(
  "Total Burn Time",
  delegate()
  {
  if (core.LastStage == null || currManeuverDeltaV.Value == double.NaN)
  {
  return double.NaN;
  }
   
  double stageThrust = stageNominalThrust;
   
  return burnTime(currManeuverDeltaV.Value, totalMass, stageMassFlow, stageThrust);
  },
  "s"
  );
   
  public static readonly VOID_DoubleValue currentNodeBurnRemaining =
  new VOID_DoubleValue(
  "Burn Time Remaining",
  delegate()
  {
  if (core.LastStage == null || currManeuverDVRemaining == double.NaN)
  {
  return double.NaN;
  }
   
  double stageThrust = stageNominalThrust;
   
  return burnTime(currManeuverDVRemaining, totalMass, stageMassFlow, stageThrust);
  },
  "s"
  );
   
  public static readonly VOID_DoubleValue currentNodeHalfBurnDuration =
  new VOID_DoubleValue(
  "Half Burn Time",
  delegate()
  {
  if (core.LastStage == null || currManeuverDeltaV.Value == double.NaN)
  {
  return double.NaN;
  }
   
  double stageThrust = stageNominalThrust;
   
  return burnTime(currManeuverDeltaV.Value / 2d, totalMass, stageMassFlow, stageThrust);
  },
  "s"
  );
   
  public static readonly VOID_DoubleValue nextManeuverDeltaV =
  new VOID_DoubleValue(
  "Current Maneuver Delta-V",
  delegate()
  {
  if (upcomingManeuverNodes > 1)
  {
  return core.vessel.patchedConicSolver.maneuverNodes[1].DeltaV.magnitude;
  }
  else
  {
  return double.NaN;
  }
  },
  "m/s"
); );
   
#endregion #endregion
   
#region Orbits #region Orbits
   
public static readonly VOID_StrValue primaryName = public static readonly VOID_StrValue primaryName =
new VOID_StrValue( new VOID_StrValue(
VOID_Localization.void_primary, VOID_Localization.void_primary,
delegate() delegate()
{ {
if (core.vessel == null) if (core.vessel == null)
{ {
return string.Empty; return string.Empty;
} }
return core.vessel.mainBody.name; return core.vessel.mainBody.name;
} }
); );
   
public static readonly VOID_DoubleValue orbitAltitude = public static readonly VOID_DoubleValue orbitAltitude =
new VOID_DoubleValue( new VOID_DoubleValue(
"Altitude (ASL)", "Altitude (ASL)",
new Func<double>(() => core.vessel.orbit.altitude), new Func<double>(() => core.vessel.orbit.altitude),
"m" "m"
); );
   
public static readonly VOID_DoubleValue orbitVelocity = public static readonly VOID_DoubleValue orbitVelocity =
new VOID_DoubleValue( new VOID_DoubleValue(
VOID_Localization.void_velocity, VOID_Localization.void_velocity,
new Func<double>(() => core.vessel.orbit.vel.magnitude), new Func<double>(() => core.vessel.orbit.vel.magnitude),
"m/s" "m/s"
); );
   
public static readonly VOID_DoubleValue orbitApoAlt = public static readonly VOID_DoubleValue orbitApoAlt =
new VOID_DoubleValue( new VOID_DoubleValue(
VOID_Localization.void_apoapsis, VOID_Localization.void_apoapsis,
new Func<double>(() => core.vessel.orbit.ApA), new Func<double>(() => core.vessel.orbit.ApA),
"m" "m"
); );
   
public static readonly VOID_DoubleValue oribtPeriAlt = public static readonly VOID_DoubleValue oribtPeriAlt =
new VOID_DoubleValue( new VOID_DoubleValue(
VOID_Localization.void_periapsis, VOID_Localization.void_periapsis,
new Func<double>(() => core.vessel.orbit.PeA), new Func<double>(() => core.vessel.orbit.PeA),
"m" "m"
); );
   
public static readonly VOID_StrValue timeToApo = public static readonly VOID_StrValue timeToApo =
new VOID_StrValue( new VOID_StrValue(
"Time to Apoapsis", "Time to Apoapsis",
new Func<string>(() => VOID_Tools.ConvertInterval(core.vessel.orbit.timeToAp)) new Func<string>(() => VOID_Tools.ConvertInterval(core.vessel.orbit.timeToAp))
); );
   
public static readonly VOID_StrValue timeToPeri = public static readonly VOID_StrValue timeToPeri =
new VOID_StrValue( new VOID_StrValue(
"Time to Periapsis", "Time to Periapsis",
new Func<string>(() => VOID_Tools.ConvertInterval(core.vessel.orbit.timeToPe)) new Func<string>(() => VOID_Tools.ConvertInterval(core.vessel.orbit.timeToPe))
); );
   
public static readonly VOID_DoubleValue orbitInclination = public static readonly VOID_DoubleValue orbitInclination =
new VOID_DoubleValue( new VOID_DoubleValue(
"Inclination", "Inclination",
new Func<double>(() => core.vessel.orbit.inclination), new Func<double>(() => core.vessel.orbit.inclination),
"°" "°"
); );
   
public static readonly VOID_DoubleValue gravityAccel = public static readonly VOID_DoubleValue gravityAccel =
new VOID_DoubleValue( new VOID_DoubleValue(
"Gravity", "Gravity",
delegate() delegate()
{ {
double orbitRadius = core.vessel.mainBody.Radius + double orbitRadius = core.vessel.mainBody.Radius +
core.vessel.mainBody.GetAltitude(core.vessel.findWorldCenterOfMass()); core.vessel.mainBody.GetAltitude(core.vessel.findWorldCenterOfMass());
return (VOID_Core.Constant_G * core.vessel.mainBody.Mass) / return (VOID_Core.Constant_G * core.vessel.mainBody.Mass) /
(orbitRadius * orbitRadius); (orbitRadius * orbitRadius);
}, },
"m/s²" "m/s²"
); );
   
public static readonly VOID_StrValue orbitPeriod = public static readonly VOID_StrValue orbitPeriod =
new VOID_StrValue( new VOID_StrValue(
"Period", "Period",
new Func<string>(() => VOID_Tools.ConvertInterval(core.vessel.orbit.period)) new Func<string>(() => VOID_Tools.ConvertInterval(core.vessel.orbit.period))
); );
   
public static readonly VOID_DoubleValue semiMajorAxis = public static readonly VOID_DoubleValue semiMajorAxis =
new VOID_DoubleValue( new VOID_DoubleValue(
"Semi-Major Axis", "Semi-Major Axis",
new Func<double>(() => core.vessel.orbit.semiMajorAxis), new Func<double>(() => core.vessel.orbit.semiMajorAxis),
"m" "m"
); );
   
public static readonly VOID_DoubleValue eccentricity = public static readonly VOID_DoubleValue eccentricity =
new VOID_DoubleValue( new VOID_DoubleValue(
"Eccentricity", "Eccentricity",
new Func<double>(() => core.vessel.orbit.eccentricity), new Func<double>(() => core.vessel.orbit.eccentricity),
"" ""
); );
   
public static readonly VOID_DoubleValue meanAnomaly = public static readonly VOID_DoubleValue meanAnomaly =
new VOID_DoubleValue( new VOID_DoubleValue(
"Mean Anomaly", "Mean Anomaly",
new Func<double>(() => core.vessel.orbit.meanAnomaly * 180d / Math.PI), new Func<double>(() => core.vessel.orbit.meanAnomaly * 180d / Math.PI),
"°" "°"
); );
   
public static readonly VOID_DoubleValue trueAnomaly = public static readonly VOID_DoubleValue trueAnomaly =
new VOID_DoubleValue( new VOID_DoubleValue(
"True Anomaly", "True Anomaly",
new Func<double>(() => core.vessel.orbit.trueAnomaly), new Func<double>(() => core.vessel.orbit.trueAnomaly),
"°" "°"
); );
   
public static readonly VOID_DoubleValue eccAnomaly = public static readonly VOID_DoubleValue eccAnomaly =
new VOID_DoubleValue( new VOID_DoubleValue(
"Eccentric Anomaly", "Eccentric Anomaly",
new Func<double>(() => core.vessel.orbit.eccentricAnomaly * 180d / Math.PI), new Func<double>(() => core.vessel.orbit.eccentricAnomaly * 180d / Math.PI),
"°" "°"
); );
   
public static readonly VOID_DoubleValue longitudeAscNode = public static readonly VOID_DoubleValue longitudeAscNode =
new VOID_DoubleValue( new VOID_DoubleValue(
"Long. Ascending Node", "Long. Ascending Node",
new Func<double>(() => core.vessel.orbit.LAN), new Func<double>(() => core.vessel.orbit.LAN),
"°" "°"
); );
   
public static readonly VOID_DoubleValue argumentPeriapsis = public static readonly VOID_DoubleValue argumentPeriapsis =
new VOID_DoubleValue( new VOID_DoubleValue(
"Argument of Periapsis", "Argument of Periapsis",
new Func<double>(() => core.vessel.orbit.argumentOfPeriapsis), new Func<double>(() => core.vessel.orbit.argumentOfPeriapsis),
"°" "°"
); );
   
public static readonly VOID_DoubleValue localSiderealLongitude = public static readonly VOID_DoubleValue localSiderealLongitude =
new VOID_DoubleValue( new VOID_DoubleValue(
"Local Sidereal Longitude", "Local Sidereal Longitude",
new Func<double>(() => VOID_Tools.FixDegreeDomain( new Func<double>(() => VOID_Tools.FixDegreeDomain(
core.vessel.longitude + core.vessel.orbit.referenceBody.rotationAngle)), core.vessel.longitude + core.vessel.orbit.referenceBody.rotationAngle)),
"°" "°"
); );
   
#endregion #endregion
   
#region Science #region Science
   
public static readonly VOID_StrValue expSituation = public static readonly VOID_StrValue expSituation =
new VOID_StrValue( new VOID_StrValue(
"Situation", "Situation",
new Func<string>(() => core.vessel.GetExperimentSituation().HumanString()) new Func<string>(() => core.vessel.GetExperimentSituation().HumanString())
); );
   
public static readonly VOID_StrValue currBiome = public static readonly VOID_StrValue currBiome =
new VOID_StrValue( new VOID_StrValue(
"Biome", "Biome",
new Func<string>(() => VOID_Tools.GetBiome(core.vessel).name) new Func<string>(() => VOID_Tools.GetBiome(core.vessel).name)
); );
   
#endregion #endregion
   
#region Surface #region Surface
   
public static readonly VOID_DoubleValue terrainElevation = public static readonly VOID_DoubleValue terrainElevation =
new VOID_DoubleValue( new VOID_DoubleValue(
"Terrain elevation", "Terrain elevation",
new Func<double>(() => core.vessel.terrainAltitude), new Func<double>(() => core.vessel.terrainAltitude),
"m" "m"
); );
   
#endregion #endregion
   
private static double burnTime(double deltaV, double initialMass, double massFlow, double thrust) private static double burnTime(double deltaV, double initialMass, double massFlow, double thrust)
{ {
Tools.PostDebugMessage(typeof(VOID_Data), "calculating burnTime from:\n" + Tools.PostDebugMessage(typeof(VOID_Data), "calculating burnTime from:\n" +
"\tdeltaV: {0}\n" + "\tdeltaV: {0}\n" +
"\tinitialMass: {1}\n" + "\tinitialMass: {1}\n" +
"\tmassFlow: {2}\n" + "\tmassFlow: {2}\n" +
"\tthrust: {3}\n", "\tthrust: {3}\n",
deltaV, deltaV,
initialMass, initialMass,
massFlow, massFlow,
thrust thrust
); );
return initialMass / massFlow * (1d - Math.Exp(-deltaV * massFlow / thrust)); return initialMass / massFlow * (1d - Math.Exp(-deltaV * massFlow / thrust));
} }
} }
} }