diff --git a/MechJeb2/MechJebModuleAscentBaseAutopilot.cs b/MechJeb2/MechJebModuleAscentBaseAutopilot.cs index 8f657af66..5f5abf268 100644 --- a/MechJeb2/MechJebModuleAscentBaseAutopilot.cs +++ b/MechJeb2/MechJebModuleAscentBaseAutopilot.cs @@ -112,7 +112,6 @@ public override void OnFixedUpdate() { if (Enabled && VesselState.thrustAvailable < 10E-4) // only stage if we have no engines active StageManager.ActivateNextStage(); - TimedLaunchHook(); // let ascentPath modules do stuff edge triggered on launch starting TimedLaunch = false; } else @@ -214,11 +213,6 @@ private void DriveAscent() Debug.Log("Awaiting Liftoff"); Status = Localizer.Format("#MechJeb_Ascent_status6"); //"Awaiting liftoff" - if (TMinus > AscentSettings.WarpCountDown) - Core.Guidance.Enabled = false; - else - Core.Guidance.AssertStart(false); - Core.Attitude.SetAxisControl(false, false, false); return; } @@ -289,11 +283,6 @@ private void DriveCircularizationBurn() protected abstract bool DriveAscent2(); - protected virtual void TimedLaunchHook() - { - // triggered when timed launches start the actual launch - } - //data used by ThrottleToRaiseApoapsis private float _raiseApoapsisLastThrottle; private double _raiseApoapsisLastApR; diff --git a/MechJeb2/MechJebModuleAscentPVGAutopilot.cs b/MechJeb2/MechJebModuleAscentPVGAutopilot.cs index cab7130b7..d4a4d2d30 100644 --- a/MechJeb2/MechJebModuleAscentPVGAutopilot.cs +++ b/MechJeb2/MechJebModuleAscentPVGAutopilot.cs @@ -1,6 +1,7 @@ extern alias JetBrainsAnnotations; using System; using KSP.Localization; +using UnityEngine; /* * Optimized launches for RSS/RO @@ -32,6 +33,24 @@ protected override void OnModuleDisabled() Core.Glueball.Users.Remove(this); } + public override void Drive(FlightCtrlState s) + { + if (TimedLaunch) + { + if (TMinus <= AscentSettings.WarpCountDown) + { + SetTarget(); + Core.Guidance.AssertStart(false); + } + } + else + { + SetTarget(); + Core.Guidance.AssertStart(); + } + base.Drive(s); + } + private enum AscentMode { VERTICAL_ASCENT, @@ -43,14 +62,8 @@ private enum AscentMode private AscentMode _mode; - protected override void TimedLaunchHook() => - // timedLaunch kills the optimizer so re-enable it here - Core.Guidance.Enabled = true; - protected override bool DriveAscent2() { - SetTarget(); - Core.Guidance.AssertStart(); switch (_mode) { case AscentMode.VERTICAL_ASCENT: diff --git a/MechJeb2/MechJebModuleGuidanceController.cs b/MechJeb2/MechJebModuleGuidanceController.cs index 8e4b08756..1bf00094e 100644 --- a/MechJeb2/MechJebModuleGuidanceController.cs +++ b/MechJeb2/MechJebModuleGuidanceController.cs @@ -75,7 +75,10 @@ protected override void OnModuleDisabled() private bool _allowExecution; // we wait until we get a signal to allow execution to start - public void AssertStart(bool allowExecution = true) => _allowExecution = allowExecution; + public void AssertStart(bool allowExecution = true) + { + _allowExecution = allowExecution; + } public override void OnFixedUpdate() {