Skip to content

Commit 7bb3484

Browse files
Enable Flight Computer to queue and execute a sequence of maneuver nodes at one go and increase the message duration by 2 seconds
1 parent e1391e3 commit 7bb3484

3 files changed

Lines changed: 24 additions & 5 deletions

File tree

src/RemoteTech/FlightComputer/Commands/ManeuverCommand.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,22 @@ public override string Description
3737
return flightInfo + Environment.NewLine + base.Description;
3838
}
3939
else
40-
return "Execute planned maneuver" + Environment.NewLine + base.Description;
40+
{
41+
return "Execute planned maneuver"+ Environment.NewLine + base.Description;
42+
}
4143
}
4244
}
4345
public override string ShortName { get { return "Execute maneuver node"; } }
4446

4547
public override bool Pop(FlightComputer f)
4648
{
49+
// check if the stored node is still valid
50+
if (f.Vessel.patchedConicSolver.maneuverNodes.IndexOf(this.Node) < 0)
51+
{
52+
RTUtil.ScreenMessage("[Flight Computer]: No maneuver node found.");
53+
return false;
54+
}
55+
4756
var burn = f.ActiveCommands.FirstOrDefault(c => c is BurnCommand);
4857
if (burn != null) {
4958
f.Remove (burn);
@@ -75,12 +84,12 @@ private double getRemainingDeltaV(FlightComputer computer)
7584
}
7685

7786
/// <summary>
78-
///
87+
/// Remove the current maneuver node from MapView
7988
/// </summary>
8089
/// <param name="computer">FlightComputer instance of the computer of the vessel.</param>
8190
private void AbortManeuver(FlightComputer computer)
8291
{
83-
RTUtil.ScreenMessage("[Flight Computer]: Maneuver removed");
92+
RTUtil.ScreenMessage("[Flight Computer]: Maneuver node removed");
8493
if (computer.Vessel.patchedConicSolver != null)
8594
{
8695
Node.RemoveSelf();

src/RemoteTech/RTUtil.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public static double TryParseDuration(String duration)
8282

8383
public static void ScreenMessage(String msg)
8484
{
85-
ScreenMessages.PostScreenMessage(new ScreenMessage(msg, 4.0f, ScreenMessageStyle.UPPER_LEFT));
85+
ScreenMessages.PostScreenMessage(new ScreenMessage(msg, 6.0f, ScreenMessageStyle.UPPER_LEFT));
8686
}
8787

8888
public static String Truncate(this String targ, int len)

src/RemoteTech/UI/AttitudeFragment.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ public void Draw()
209209
{
210210
RTUtil.Button(new GUIContent("BURN", "Example: 125, 125s, 5m20s, 1d6h20m10s, 123m/s."),
211211
OnBurnClick, GUILayout.Width(width3));
212-
RTUtil.Button(new GUIContent("EXEC", "Executes next maneuver node."),
212+
RTUtil.Button(new GUIContent("EXEC", "Executes next and subsequent maneuver nodes."),
213213
OnExecClick, GUILayout.Width(width3));
214214
RTUtil.Button(new GUIContent(">>", "Toggles the queue and delay functionality."),
215215
mOnClickQueue, GUILayout.Width(width3));
@@ -314,6 +314,16 @@ private void OnExecClick()
314314
else
315315
{
316316
mFlightComputer.Enqueue(cmd, false, false, true);
317+
318+
//check for subsequent nodes
319+
int numSubsequentNodes = mFlightComputer.Vessel.patchedConicSolver.maneuverNodes.Count - 1;
320+
if (numSubsequentNodes >= 1)
321+
{
322+
for (int nodeIndex = 1; nodeIndex <= numSubsequentNodes; nodeIndex++)
323+
{
324+
mFlightComputer.Enqueue(ManeuverCommand.WithNode(nodeIndex, mFlightComputer), false, false, true);
325+
}
326+
}
317327
}
318328
}
319329

0 commit comments

Comments
 (0)