public void SetVerticalCutoff(float cutoff) { TCA.SquadConfigAction(cfg => { cfg.VerticalCutoff = cutoff; cfg.BlockThrottle |= cfg.VSCIsActive; }); }
void set_vspeed(float vspeed) { TCA.SquadConfigAction(cfg => { cfg.VerticalCutoff = vspeed; cfg.BlockThrottle |= cfg.VSCIsActive; }); }
void land(SurfaceNode n) { CFG.Anchor = n.ToWayPoint(); CFG.Anchor.Radius = C.NodeTargetRange; SetTarget(CFG.Anchor); CFG.Nav.OnIfNot(Navigation.Anchor); WideCheckAlt = VSL.Geometry.H * (C.StopAtH + 1); TCA.SquadConfigAction(cfg => cfg.AP1.XOnIfNot(Autopilot1.Land)); stage = Stage.Land; }
protected override void DrawContent() { GUILayout.BeginVertical(); GUILayout.Label(CFG.Enabled? new GUIContent( string.Format("{0} {1} ►{2}", Utils.formatBigValue(VSL.Altitude.Current, "m"), Utils.formatBigValue(VSL.VerticalSpeed.Display, "m/s", "▲ 0.0;▼ 0.0;▲ 0.0"), Utils.formatBigValue(VSL.HorizontalSpeed.Absolute, "m/s")), "Altitude, Vertical speed, Horizontal speed.") : new GUIContent(""), Styles.boxed_label, GUILayout.MinWidth(240), GUILayout.ExpandWidth(true)); GUILayout.BeginHorizontal(); if (ALT != null && CFG.VF[VFlight.AltitudeControl]) { ALT.Draw(); } else if (VSC != null) { VSC.Draw(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (ALT != null) { if (Utils.ButtonSwitch("Hover", CFG.VF[VFlight.AltitudeControl], "Maintain altitude", GUILayout.ExpandWidth(true))) { TCA.SquadConfigAction(cfg => cfg.VF.XToggle(VFlight.AltitudeControl)); } if (RAD != null) { if (Utils.ButtonSwitch("Follow Terrain", ref CFG.AltitudeAboveTerrain, "Keep altitude above the ground", GUILayout.ExpandWidth(true))) { TCA.SquadAction(tca => { var alt = tca.GetModule <AltitudeControl>(); if (alt != null) { alt.SetAltitudeAboveTerrain(CFG.AltitudeAboveTerrain); } }); } // RAD.DrawDebugLines();//debug } } if (THR != null) { THR.Draw(); } GUILayout.EndHorizontal(); GUILayout.EndVertical(); }
void land() { var c = center_node; CFG.Anchor = new WayPoint(c.position, VSL.Body); CFG.Anchor.Radius = LND.NodeTargetRange; CFG.Target = CFG.Anchor; CFG.Nav.OnIfNot(Navigation.Anchor); CFG.DesiredAltitude = VSL.Geometry.H * (LND.StopAtH + 1); //Log("land: H {}, Alt {}", VSL.Geometry.H, CFG.DesiredAltitude);//debug TCA.SquadConfigAction(cfg => cfg.AP1.XOnIfNot(Autopilot1.Land)); stage = Stage.Land; }
void onHover(bool hover) { if (hover) { TCA.SquadConfigAction(cfg => { cfg.VF.XOnIfNot(VFlight.AltitudeControl); cfg.BlockThrottle = true; }); } else { TCA.SquadConfigAction(cfg => cfg.VF.XOffIfOn(VFlight.AltitudeControl)); } }
void set_altitude() { TCA.SquadConfigAction(set_altitude); set_altitude(CFG); }
void HFlightControls() { GUILayout.BeginHorizontal(); if (HSC != null) { if (Utils.ButtonSwitch("Level", CFG.HF[HFlight.Level], "Point thrust downward", GUILayout.ExpandWidth(true))) { TCA.SquadConfigAction(cfg => cfg.HF.XToggle(HFlight.Level)); } } if (CC != null) { if (Utils.ButtonSwitch("Cruise", CFG.HF[HFlight.CruiseControl], "Maintain course and speed", GUILayout.ExpandWidth(true))) { CFG.HF.XToggle(HFlight.CruiseControl); if (CFG.HF[HFlight.CruiseControl]) { follow_me(); } } } if (BRC != null) { BRC.Draw(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (HSC != null) { #if DEBUG HSC.DrawDebugLines(); #endif if (Utils.ButtonSwitch("Stop", CFG.HF[HFlight.Stop], "Kill horizontal velocity", GUILayout.ExpandWidth(true))) { if (CFG.HF[HFlight.Stop]) { TCA.SquadConfigAction(cfg => cfg.HF.OffIfOn(HFlight.Stop)); } else { TCA.SquadConfigAction(cfg => { cfg.HF.XOn(HFlight.Stop); cfg.StopMacro(); }); } } } if (ANC != null) { if (Utils.ButtonSwitch("Anchor", CFG.Nav.Any(Navigation.AnchorHere, Navigation.Anchor), "Hold current position", GUILayout.ExpandWidth(true))) { TCA.SquadConfigAction(cfg => cfg.Nav.XToggle(Navigation.AnchorHere)); } } if (LND != null) { #if DEBUG LND.DrawDebugLines(); #endif if (Utils.ButtonSwitch("Land", CFG.AP1[Autopilot1.Land], "Try to land on a nearest flat surface", GUILayout.ExpandWidth(true))) { var state = !CFG.AP1[Autopilot1.Land]; if (state) { follow_me(); CFG.AP1.XOn(Autopilot1.Land); } else { TCA.SquadConfigAction(cfg => cfg.AP1.XOffIfOn(Autopilot1.Land)); } } } GUILayout.EndHorizontal(); }
void NavigationControls() { GUILayout.BeginHorizontal(); if (BJ != null) { BJ.Draw(); } if (PN != null) { if (VSL.HasTarget && !CFG.Nav.Paused) { if (Utils.ButtonSwitch("Go To", CFG.Nav[Navigation.GoToTarget], "Fly to current target", GUILayout.ExpandWidth(true))) { VSL.Engines.ActivateEnginesAndRun(() => { CFG.Nav.XOn(Navigation.GoToTarget); if (CFG.Nav[Navigation.GoToTarget]) { follow_me(); } }); } if (Utils.ButtonSwitch("Follow", CFG.Nav[Navigation.FollowTarget], "Follow current target", GUILayout.ExpandWidth(true))) { VSL.Engines.ActivateEnginesAndRun(() => TCA.SquadAction(tca => { if (TCA.vessel.targetObject as Vessel == tca.vessel) { return; } tca.vessel.targetObject = TCA.vessel.targetObject; tca.CFG.Nav.XOn(Navigation.FollowTarget); })); } } else { GUILayout.Label(new GUIContent("Go To", CFG.Nav.Paused? "Paused" : "No target selected"), Styles.inactive_button, GUILayout.ExpandWidth(true)); GUILayout.Label(new GUIContent("Follow", CFG.Nav.Paused? "Paused" : "No target selected"), Styles.inactive_button, GUILayout.ExpandWidth(true)); } } GUILayout.EndHorizontal(); if (BJ != null && BJ.ShowOptions) { BJ.DrawOptions(); } GUILayout.BeginHorizontal(); if (SQD != null && SQD.SquadMode) { if (CFG.Nav.Paused) { GUILayout.Label(new GUIContent("Follow Me", "Make the squadron follow"), Styles.inactive_button, GUILayout.ExpandWidth(true)); } else if (GUILayout.Button(new GUIContent("Follow Me", "Make the squadron follow"), Styles.active_button, GUILayout.ExpandWidth(true))) { follow_me(); } } if (PN != null) { if (SelectingTarget) { SelectingTarget &= !GUILayout.Button("Cancel", Styles.close_button, GUILayout.Width(120)); } else if (!UI.RemoteControl && VSL.HasTarget && (VSL.TargetIsNavPoint || !VSL.TargetIsWayPoint && (CFG.Path.Count == 0 || VSL.Target != CFG.Path.Peek().GetTarget()))) { if (GUILayout.Button(new GUIContent("Add As Waypoint", "Add current target as a waypoint"), Styles.active_button, GUILayout.Width(120))) { var t = VSL.TargetAsWP; CFG.Path.Enqueue(t); CFG.ShowPath = true; } } else if (GUILayout.Button(new GUIContent("Add Waypoint", "Select a new waypoint"), Styles.active_button, GUILayout.Width(120))) { SelectingTarget = true; CFG.ShowPath = true; } if (CFG.Path.Count > 0 && !CFG.Nav.Paused) { if (Utils.ButtonSwitch("Follow Route", CFG.Nav[Navigation.FollowPath], "", GUILayout.ExpandWidth(true))) { VSL.Engines.ActivateEnginesAndRun(() => { CFG.Nav.XToggle(Navigation.FollowPath); if (CFG.Nav[Navigation.FollowPath]) { follow_me(); } }); } } else { GUILayout.Label(new GUIContent("Follow Route", CFG.Nav.Paused? "Paused" : "Add some waypoints first"), Styles.inactive_button, GUILayout.ExpandWidth(true)); } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (PN != null || CC != null) { var max_nav_speed = Utils.FloatSlider("", CFG.MaxNavSpeed, CFG.HF[HFlight.CruiseControl]? CruiseControl.C.MaxRevSpeed : PointNavigator.C.MinSpeed, PointNavigator.C.MaxSpeed, "0.0 m/s", 60, "Maximum horizontal speed on autopilot"); if (Mathf.Abs(max_nav_speed - CFG.MaxNavSpeed) > 1e-5) { TCA.SquadConfigAction(cfg => cfg.MaxNavSpeed = max_nav_speed); } } GUILayout.EndHorizontal(); }
public void SetDesiredAltitude(float altitude) { CFG.DesiredAltitude = altitude; TCA.SquadConfigAction(set_altitude); }
void set_altitude() { TCA.SquadConfigAction(set_altitude); s_altitude = altitude.ToString("F1"); }