Skip to content

Commit

Permalink
Rename ThrustPercentage to ThrottleLimiter
Browse files Browse the repository at this point in the history
I see why I made that last mistake and it was due to KSPs bad
API name.

Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
  • Loading branch information
lamont-granquist committed Oct 19, 2023
1 parent c6aa665 commit b6ea7de
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
11 changes: 4 additions & 7 deletions MechJeb2/MechJebLib/Simulations/PartModules/SimModuleEngines.cs
Expand Up @@ -48,7 +48,7 @@ public class SimModuleEngines : SimPartModule
public float FlowMultCap;
public float FlowMultCapSharpness;
public bool ThrottleLocked;
public float ThrustPercentage;
public float ThrottleLimiter;
public bool AtmChangeFlow;
public bool UseAtmCurve;
public bool UseAtmCurveIsp;
Expand Down Expand Up @@ -76,10 +76,7 @@ public class SimModuleEngines : SimPartModule
private double _machNumber => Part.Vessel.MachNumber;

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Activate()
{
IsOperational = true;
}
public void Activate() => IsOperational = true;

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void UpdateEngineStatus()
Expand Down Expand Up @@ -233,7 +230,7 @@ private double FlowRateAtConditions()
if (minFuelFlow == 0 && MinThrust > 0) minFuelFlow = MinThrust / (AtmosphereCurve.Evaluate(0f) * G);
if (maxFuelFlow == 0 && MaxThrust > 0) maxFuelFlow = MaxThrust / (AtmosphereCurve.Evaluate(0f) * G);

return Lerp(minFuelFlow, maxFuelFlow, _throttle * 0.01f * ThrustPercentage) * FlowMultiplier;
return Lerp(minFuelFlow, maxFuelFlow, _throttle * 0.01f * ThrottleLimiter) * FlowMultiplier;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand All @@ -243,7 +240,7 @@ private void RefreshThrust()
ThrustMax = V3.zero;
ThrustMin = V3.zero;

double thrustLimiter = ThrustPercentage / 100f;
double thrustLimiter = ThrottleLimiter / 100f;

double maxThrust = MaxFuelFlow * FlowMultiplier * ISP * G * MultIsp;
double minThrust = MinFuelFlow * FlowMultiplier * ISP * G * MultIsp;
Expand Down
12 changes: 6 additions & 6 deletions MechJeb2/MechJebLib/Simulations/SimVesselUpdater.cs
Expand Up @@ -158,12 +158,12 @@ private static void UpdateModuleEngines(SimPart part, SimModuleEngines engine, M
return;
}

engine.IsEnabled = kspEngine.isEnabled;
engine.IsOperational = kspEngine.isOperational;
engine.ThrustPercentage = kspEngine.thrustPercentage;
engine.MultIsp = kspEngine.multIsp;
engine.NoPropellants = kspEngine is { flameout: true, statusL2: "No propellants" };
engine.ModuleResiduals = 0;
engine.IsEnabled = kspEngine.isEnabled;
engine.IsOperational = kspEngine.isOperational;
engine.ThrottleLimiter = kspEngine.thrustPercentage;
engine.MultIsp = kspEngine.multIsp;
engine.NoPropellants = kspEngine is { flameout: true, statusL2: "No propellants" };
engine.ModuleResiduals = 0;

if (engine.isModuleEnginesRF && _rfPredictedMaximumResiduals!.GetValue(kspEngine) is double doubleVal)
engine.ModuleResiduals = doubleVal;
Expand Down

0 comments on commit b6ea7de

Please sign in to comment.