Skip to content

Commit

Permalink
Add option to override warp to plane
Browse files Browse the repository at this point in the history
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
  • Loading branch information
lamont-granquist committed Aug 14, 2023
1 parent cbd3964 commit 62f5364
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
25 changes: 14 additions & 11 deletions MechJeb2/MechJebModuleAscentBaseAutopilot.cs
Expand Up @@ -86,9 +86,18 @@ protected override void OnModuleDisabled()

public void StartCountdown(double time)
{
TimedLaunch = true;
_launchTime = time;
_lastTMinus = 999;
if (AscentSettings.OverrideWarpToPlane)
{
TimedLaunch = false;
_launchTime = VesselState.time;
_lastTMinus = 0;
}
else
{
TimedLaunch = true;
_launchTime = time;
_lastTMinus = 999;
}
}

public override void OnFixedUpdate()
Expand Down Expand Up @@ -320,15 +329,9 @@ protected float ThrottleToRaiseApoapsis(double currentApR, double finalApR)
return desiredThrottle;
}

protected double SrfvelPitch()
{
return 90.0 - Vector3d.Angle(VesselState.surfaceVelocity, VesselState.up);
}
protected double SrfvelPitch() => 90.0 - Vector3d.Angle(VesselState.surfaceVelocity, VesselState.up);

protected double SrfvelHeading()
{
return VesselState.HeadingFromDirection(VesselState.surfaceVelocity.ProjectOnPlane(VesselState.up));
}
protected double SrfvelHeading() => VesselState.HeadingFromDirection(VesselState.surfaceVelocity.ProjectOnPlane(VesselState.up));

// this provides ground track heading based on desired inclination and is what most consumers should call
protected void AttitudeTo(double desiredPitch)
Expand Down
2 changes: 2 additions & 0 deletions MechJeb2/MechJebModuleAscentMenu.cs
Expand Up @@ -344,6 +344,8 @@ private void ShowAutoWarpGUIElements()
_launchingToPlane = _launchingToRendezvous = _launchingToMatchLan = _launchingToLan = _autopilot.TimedLaunch = false;
}

_ascentSettings.OverrideWarpToPlane = GUILayout.Toggle(_ascentSettings.OverrideWarpToPlane, "Override Warp to Plane");

GUILayout.EndVertical();
Profiler.EndSample();
}
Expand Down
6 changes: 2 additions & 4 deletions MechJeb2/MechJebModuleAscentSettings.cs
Expand Up @@ -275,6 +275,7 @@ public bool Autostage
public bool LaunchingToRendezvous;
public bool LaunchingToMatchLan;
public bool LaunchingToLan;
public bool OverrideWarpToPlane;

/*
* Helpers for dealing with switching between modules
Expand Down Expand Up @@ -304,10 +305,7 @@ private void DisableAscentModules()
GetAscentModule(type).Enabled = false;
}

public override void OnFixedUpdate()
{
DisableAscentModules();
}
public override void OnFixedUpdate() => DisableAscentModules();

public void ApplyRODefaults()
{
Expand Down

0 comments on commit 62f5364

Please sign in to comment.