private void Confirm() { ICommand newCommand; switch (mMode) { default: // Off mAttitude = 0; newCommand = AttitudeCommand.Off(); break; case 1: // Killrot mAttitude = 0; newCommand = AttitudeCommand.KillRot(); break; case 2: // Node mAttitude = 0; newCommand = AttitudeCommand.ManeuverNode(); break; case 3: // Target Parallel mAttitude = (mAttitude == 0) ? 1 : mAttitude; newCommand = AttitudeCommand.WithAttitude(Attitude, ReferenceFrame.TargetParallel); break; case 4: // Orbital reference mAttitude = (mAttitude == 0) ? 1 : mAttitude; newCommand = AttitudeCommand.WithAttitude(Attitude, ReferenceFrame.Orbit); break; case 5: // Surface reference mAttitude = (mAttitude == 0) ? 1 : mAttitude; newCommand = AttitudeCommand.WithAttitude(Attitude, ReferenceFrame.Surface); break; case 6: // Target Velocity mAttitude = (mAttitude == 0) ? 1 : mAttitude; newCommand = AttitudeCommand.WithAttitude(Attitude, ReferenceFrame.TargetVelocity); break; case 7: // Custom Surface Heading mAttitude = 0; newCommand = AttitudeCommand.WithSurface(Pitch, Heading, Roll); break; } mFlightComputer.Enqueue(newCommand); }
private void Confirm() { DelayedCommand newCommand; switch (mMode) { default: // Off mAttitude = 0; newCommand = AttitudeCommand.Off(); break; case 1: // Killrot mAttitude = 0; newCommand = AttitudeCommand.KillRot(); break; case 2: // Node mAttitude = 0; newCommand = AttitudeCommand.ManeuverNode(); break; case 3: // Pitch, heading, roll mAttitude = 0; newCommand = AttitudeCommand.WithSurface( Pitch, Heading, mRollEnabled ? Roll : Single.NaN); break; case 4: // Orbital reference mAttitude = (mAttitude == 0) ? 1 : mAttitude; newCommand = AttitudeCommand.WithAttitude(Attitude, ReferenceFrame.Orbit); break; case 5: // Surface reference mAttitude = (mAttitude == 0) ? 1 : mAttitude; newCommand = AttitudeCommand.WithAttitude(Attitude, ReferenceFrame.Surface); break; case 6: // Target reference mAttitude = (mAttitude == 0) ? 1 : mAttitude; newCommand = AttitudeCommand.WithAttitude(Attitude, ReferenceFrame.Target); break; } mFlightComputer.Enqueue(newCommand); }
public override bool Execute(FlightComputer f, FlightCtrlState fcs) { if (RemainingDelta > 0) { var forward = Node.GetBurnVector(f.Vessel.orbit).normalized; var up = (f.SignalProcessor.Body.position - f.SignalProcessor.Position).normalized; var orientation = Quaternion.LookRotation(forward, up); FlightCore.HoldOrientation(fcs, f, orientation); double thrustToMass = (FlightCore.GetTotalThrust(f.Vessel) / f.Vessel.GetTotalMass()); if (thrustToMass == 0.0) { EngineActivated = false; return(false); } EngineActivated = true; fcs.mainThrottle = 1.0f; RemainingTime = RemainingDelta / thrustToMass; RemainingDelta -= thrustToMass * TimeWarp.deltaTime; return(false); } f.Enqueue(AttitudeCommand.Off(), true, true, true); return(true); }
private void Submit() { if (!mFlightComputer.InputAllowed) { return; } var newCommand = AttitudeCommand.WithAltitude(Altitude); mFlightComputer.Enqueue(newCommand); }
public override bool Execute(FlightComputer f, FlightCtrlState fcs) { if (RemainingDelta > 0) { var forward = Node.GetBurnVector(f.Vessel.orbit).normalized; var up = (f.SignalProcessor.Body.position - f.SignalProcessor.Position).normalized; var orientation = Quaternion.LookRotation(forward, up); FlightCore.HoldOrientation(fcs, f, orientation); double thrustToMass = (FlightCore.GetTotalThrust(f.Vessel) / f.Vessel.GetTotalMass()); if (thrustToMass == 0.0) { EngineActivated = false; return false; } EngineActivated = true; fcs.mainThrottle = 1.0f; RemainingTime = RemainingDelta / thrustToMass; RemainingDelta -= thrustToMass * TimeWarp.deltaTime; return false; } f.Enqueue(AttitudeCommand.Off(), true, true, true); return true; }
public void Draw() { if (Event.current.Equals(Event.KeyboardEvent("return")) && GUI.GetNameOfFocusedControl() == "xd") { mExtraDelay = Delay.ToString(); mFlightComputer.ExtraDelay = Delay; } GUILayout.BeginVertical(GUILayout.Width(250)); { mScrollPosition = GUILayout.BeginScrollView(mScrollPosition, GUILayout.ExpandHeight(true)); { foreach (DelayedCommand dc in mFlightComputer) { GUILayout.BeginHorizontal(GUI.skin.box); { GUILayout.Label(Format(dc)); RTUtil.Button("x", () => { mFlightComputer.Enqueue(DelayedCommand.Cancel(dc)); }, GUILayout.Width(21)); } GUILayout.EndHorizontal(); } } GUILayout.EndScrollView(); GUILayout.BeginHorizontal(); { GUILayout.Label("Artificial delay: "); GUI.SetNextControlName("xd"); GUILayout.Label(mFlightComputer.ExtraDelay.ToString("F2")); RTUtil.TextField(ref mExtraDelay, GUILayout.ExpandWidth(true)); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); }
private void EnqueueTurn() { mFlightComputer.Enqueue(DriveCommand.Turn(mSteering, Turn, Speed)); }
public IEnumerator OnClickCancel(ICommand c) { yield return(null); mFlightComputer.Enqueue(CancelCommand.WithCommand(c)); }