Skip to content

Commit

Permalink
Fix Principia Node execution again
Browse files Browse the repository at this point in the history
Need to not spill out into the AngleFromNode() test.

Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
  • Loading branch information
lamont-granquist committed Nov 4, 2023
1 parent 89ead30 commit 0e54ef9
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions MechJeb2/MechJebModuleNodeExecutor.cs
Expand Up @@ -262,35 +262,36 @@ private void SetAttitude()
Core.Attitude.attitudeTo(_worldDirection, AttitudeReference.INERTIAL, this);
}

private bool ShouldTerminate()
private bool ShouldTerminatePrincipia()
{
if (_isLoadedPrincipia && _dvLeft < 0)
{
if (_mode == Mode.ALL_NODES && Vessel.patchedConicSolver.maneuverNodes.Count > 0)
Init();
else
Abort();
if (_dvLeft > 0) return false;

return true;
}
if (_mode == Mode.ALL_NODES && Vessel.patchedConicSolver.maneuverNodes.Count > 0)
Init();
else
Abort();

if (AngleFromNode() >= 0.5 * PI)
{
ManeuverNode node = Vessel.patchedConicSolver.maneuverNodes[0];
return true;
}

node.RemoveSelf();
private bool ShouldTerminateStock()
{
if (AngleFromNode() < 0.5 * PI) return false;

if (_mode == Mode.ALL_NODES && Vessel.patchedConicSolver.maneuverNodes.Count > 0)
Init();
else
Abort();
ManeuverNode node = Vessel.patchedConicSolver.maneuverNodes[0];

return true;
}
node.RemoveSelf();

return false;
if (_mode == Mode.ALL_NODES && Vessel.patchedConicSolver.maneuverNodes.Count > 0)
Init();
else
Abort();

return true;
}

private bool ShouldTerminate() => _isLoadedPrincipia ? ShouldTerminatePrincipia() : ShouldTerminateStock();

private bool AlignedAndSettled() => AngleFromDirection() < Deg2Rad(1) && Core.vessel.angularVelocity.magnitude < 0.001;

// This returns the angle to the node (in radians), note that you probably don't want to use this outside of
Expand Down

0 comments on commit 0e54ef9

Please sign in to comment.