Skip to content

Commit

Permalink
Don't clobber fuelFlowGUI, instead set it properly the way stock does…
Browse files Browse the repository at this point in the history
…, and show a new massFlowGUI instead. Also cache whether we're displaying in kg/s or ton/s so we don't clobber strings we don't have to.
  • Loading branch information
NathanKell committed May 24, 2021
1 parent 1d90c97 commit 1b79a1c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
Binary file modified GameData/SolverEngines/Plugins/SolverEngines.dll
Binary file not shown.
28 changes: 24 additions & 4 deletions SolverEngines/EngineModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public abstract class ModuleEnginesSolver : ModuleEnginesFX, IModuleInfo, IEngin
[KSPField(isPersistant = false, guiActive = true, guiName = "Current Throttle", guiFormat = "N2", guiUnits = "%")]
public float actualThrottle;

[KSPField(guiActive = true, guiName = "Mass Flow", guiUnits = " kg/s", guiFormat = "F5")]
public float massFlowGui;

[KSPField(isPersistant = false)]
public double thrustUpperLimit = double.MaxValue;

Expand Down Expand Up @@ -74,6 +77,8 @@ public abstract class ModuleEnginesSolver : ModuleEnginesFX, IModuleInfo, IEngin

protected const double invg0 = 1d / 9.80665d;

protected bool flowKG = true;

#region Properties

public virtual string EnginePartName => part.name;
Expand Down Expand Up @@ -105,7 +110,9 @@ virtual public void Start()
currentThrottle = 0f;
flameout = false;
SetUnflameout();
Fields["fuelFlowGui"].guiUnits = " kg/sec";
Fields["fuelFlowGui"].guiActive = false;
Fields["massFlowGui"].guiUnits = " kg/s";
flowKG = true;
}

public override void OnStart(PartModule.StartState state)
Expand Down Expand Up @@ -231,6 +238,7 @@ protected void InitializeThrustTransforms()
realIsp = 0f;
finalThrust = 0f;
fuelFlowGui = 0f;
massFlowGui = 0f;
requestedThrottle = 0f;

SetUnflameout();
Expand Down Expand Up @@ -377,6 +385,7 @@ virtual public void CalculateEngineParams()
}
realIsp = 0f;
fuelFlowGui = 0f;
massFlowGui = 0f;
producedThrust = 0d;

// If engine is not ignited, then UpdatePropellantStatus() will not be called so no point in updating propellant fraction
Expand Down Expand Up @@ -429,14 +438,25 @@ virtual public void CalculateEngineParams()
producedThrust = thrustUpperLimit + (producedThrust - thrustUpperLimit) * 0.1d;

// set fuel flow
fuelFlowGui = (float)(fuelFlow * mixtureDensityRecip / ratioSum);
if (fuelFlow > 1000d)
{
fuelFlow *= 0.001d;
Fields["fuelFlowGui"].guiUnits = " ton/s";
if (flowKG)
{
Fields["massFlowGui"].guiUnits = " ton/s";
flowKG = false;
}
}
else
Fields["fuelFlowGui"].guiUnits = " kg/s";
fuelFlowGui = (float)fuelFlow;
{
if (!flowKG)
{
Fields["massFlowGui"].guiUnits = " kg/s";
flowKG = true;
}
}
massFlowGui = (float)fuelFlow;


realIsp = (float)isp;
Expand Down

0 comments on commit 1b79a1c

Please sign in to comment.