public void SendCommand(ManeuverCommand _maneuverCommand, float _speedMod = 1.0f) { switch (_maneuverCommand) { case ManeuverCommand.OnPitch: playerSpaceship.Spaceship.OnPitch(_speedMod > 0.0f ? PitchMode.ToUp : PitchMode.ToDown, Mathf.Abs(_speedMod)); break; case ManeuverCommand.OnRoll: playerSpaceship.Spaceship.OnRoll(_speedMod > 0.0f ? RollMode.ToRight : RollMode.ToLeft, Mathf.Abs(_speedMod)); break; case ManeuverCommand.OnYaw: playerSpaceship.Spaceship.OnYaw(_speedMod > 0.0f ? YawMode.ToRight : YawMode.ToLeft, Mathf.Abs(_speedMod)); break; case ManeuverCommand.OnStrafeY: playerSpaceship.Spaceship.OnStrafe(_speedMod > 0.0f ? StrafeMode.ToUp : StrafeMode.ToDown, Mathf.Abs(_speedMod)); break; case ManeuverCommand.OnStrafeX: playerSpaceship.Spaceship.OnStrafe(_speedMod > 0.0f ? StrafeMode.ToRight : StrafeMode.ToLeft, Mathf.Abs(_speedMod)); break; case ManeuverCommand.OnEngineSpeedChange: playerSpaceship.Spaceship.OnEngineSpeedChange(_speedMod); break; } }
private void OnExecClick() { if (mFlightComputer.Vessel.patchedConicSolver == null || mFlightComputer.Vessel.patchedConicSolver.maneuverNodes.Count == 0) { return; } var cmd = ManeuverCommand.WithNode(0, mFlightComputer); if (cmd.TimeStamp < RTUtil.GameTime + mFlightComputer.Delay) { RTUtil.ScreenMessage(Localizer.Format("#RT_FC_msg5"));//"[Flight Computer]: Signal delay is too high to execute this maneuver at the proper time." } else { mFlightComputer.Enqueue(cmd, false, false, true); //check for subsequent nodes int numSubsequentNodes = mFlightComputer.Vessel.patchedConicSolver.maneuverNodes.Count - 1; if (numSubsequentNodes >= 1) { for (int nodeIndex = 1; nodeIndex <= numSubsequentNodes; nodeIndex++) { mFlightComputer.Enqueue(ManeuverCommand.WithNode(nodeIndex, mFlightComputer), false, false, true); } } } }
public ManeuverCommandData(ManeuverCommand _command, ManeuverType _type, Vector3 _direction) { command = _command; type = _type; direction = _direction; targetDirection = _direction; }
private void OnExecClick() { if (mFlightComputer.Vessel.patchedConicSolver == null || mFlightComputer.Vessel.patchedConicSolver.maneuverNodes.Count == 0) { return; } var cmd = ManeuverCommand.WithNode(0, mFlightComputer); if (cmd.TimeStamp < RTUtil.GameTime + mFlightComputer.Delay) { RTUtil.ScreenMessage("[Flight Computer]: Signal delay is too high to execute this maneuver at the proper time."); } else { mFlightComputer.Enqueue(cmd, false, false, true); } }
/// <summary> /// Draws the RT add node to queue on the maneuver gizmo /// </summary> public void Draw() { if (!this.mShowOverlay) { return; } if (this.mMap != null && FlightGlobals.ActiveVessel != null) { // if we r on local control, skip these part if (FlightGlobals.ActiveVessel.HasLocalControl()) { return; } // if we've no flightcomputer, go out var satellite = RTCore.Instance.Satellites[FlightGlobals.ActiveVessel]; if (satellite == null || satellite.SignalProcessor.FlightComputer == null) { return; } var flightComputer = satellite.SignalProcessor.FlightComputer; PatchedConicSolver pCS = FlightGlobals.ActiveVessel.patchedConicSolver; // PatchedConicSolver instantiated? and more than one maneuver node? if (pCS != null && pCS.maneuverNodes.Count > 0) { // Loop maneuvers for (var i = 0; i < pCS.maneuverNodes.Count; i++) { float btnWidth = 23.0f; ManeuverNode node = pCS.maneuverNodes[i]; // node has an attached gizmo? if (node.attachedGizmo == null || node.UT < RTUtil.GameTime) { continue; } ManeuverGizmo gizmo = node.attachedGizmo; ScreenSafeUIButton gizmoDeleteBtn = gizmo.deleteBtn; // We are on the right gizmo but no buttons are visible so skip the rest if (!gizmoDeleteBtn.GetComponent <Renderer>().isVisible) { continue; } Vector3 screenCoord = gizmo.camera.WorldToScreenPoint(gizmo.transform.position); //Vector3 screenCenter = new Vector2(Screen.width / 2, Screen.height / 2); //double dist = Math.Sqrt(Math.Pow(screenCenter.x - screenCoord.x, 2.0) + Math.Pow(screenCenter.y - screenCoord.y, 2.0)); //double btnDim = 20.0f + (8.0f * ((1.2f / screenCenter.magnitude) * Math.Abs(dist))); //btnDim = 1.0f * gizmoDeleteBtn.transform.lossyScale.x; Rect screenPos = new Rect(screenCoord.x - btnWidth - 5.0f, Screen.height - screenCoord.y - btnWidth, btnWidth, btnWidth); GUIStyle maneuverCtrl = mManeuverNodeButtonAdd; bool nodeAlreadyQueued = flightComputer.hasManeuverCommandByNode(node); // switch the button style if (nodeAlreadyQueued) { maneuverCtrl = mManeuverNodeButtonDelete; } GUILayout.BeginArea(screenPos); if (GUILayout.Button("", maneuverCtrl)) { if (!nodeAlreadyQueued) { flightComputer.Enqueue(ManeuverCommand.WithNode(i, flightComputer), false, false, true); } else { flightComputer.removeManeuverCommandByNode(node); } } GUILayout.EndArea(); } } } }