public void UpdateElement(IVesselElement element) { if (element == null) { return; } vesselElementInterface = element; m_vesselName.OnTextUpdate.Invoke(element.VesselName); if (element.VesselIcon != m_vesselIcon.sprite) { m_vesselIcon.sprite = element.VesselIcon; } m_persistentThrustToggle.isOn = element.HasPersistentThrustActive; m_vesselInfoToggle.isOn = element.HasInfoWindowActive; m_vesselName.OnColorUpdate.Invoke(vesselElementInterface.IsVesselCommandable ? Color.white : Color.yellow); if (currentAutopilotMode != element.VesselAutopilotMode) { UpdateElementAutopilotInfo(element.VesselAutopilotMode); currentAutopilotMode = element.VesselAutopilotMode; } }
public void SetElement(IVesselElement element) { if (element == null) { return; } vesselElementInterface = element; if (element.VesselName != null) { m_vesselName.OnTextUpdate.Invoke(element.VesselName); } if (element.VesselIcon != null) { m_vesselIcon.sprite = element.VesselIcon; } m_persistentThrustToggle.isOn = element.HasPersistentThrustActive; m_vesselInfoToggle.isOn = element.HasInfoWindowActive; currentAutopilotMode = element.VesselAutopilotMode; if (goToButton != null && element.IsActiveVessel) { goToButton.enabled = false; } m_vesselName.OnColorUpdate.Invoke(vesselElementInterface.IsVesselCommandable ? Color.white : Color.yellow); UpdateElementAutopilotInfo(element.VesselAutopilotMode); }
public bool CheckAutopilotModeAvailable(AutoPilotModeEnum apMode) { if (!vessel.isCommandable) { return(false); } if (vessel.loaded) { return(true); } var vesselData = PersistentScenarioModule.VesselDataDict[vessel.id]; switch (apMode.ToKSPEnum()) { case VesselAutopilot.AutopilotMode.Target: case VesselAutopilot.AutopilotMode.AntiTarget: { Guid persistentVesselTargetGuid = new Guid(vesselData.persistentVesselTargetId); if (persistentVesselTargetGuid != Guid.Empty || !string.IsNullOrEmpty(vesselData.persistentVesselTargetBodyName)) { return(true); } break; } case VesselAutopilot.AutopilotMode.Maneuver: { //if (vessel.patchedConicSolver is null) // return false; //else if (vessel.patchedConicSolver.maneuverNodes.Count > 0) // return true; if (vessel.orbit.GetThrustVectorToManeuver(vesselData.persistentManeuverNextPatch, vesselData.persistentManeuverPatch, vesselData.persistentManeuverUT, vesselData.maneuverToleranceInDegree) != Vector3d.zero) { return(true); } if (!string.IsNullOrEmpty(vesselData.persistentManeuverNextPatch)) { return(true); } break; } default: return(true); } return(false); }
public void OpenModeUnavailableDialog(AutoPilotModeEnum mode) { string title = "Warning!"; string msg; DialogGUIButton[] buttons; switch (mode) { case AutoPilotModeEnum.AntiTarget: case AutoPilotModeEnum.Target: { msg = $"Vessel {VesselName} doesn't have a valid target."; buttons = new DialogGUIButton[] { new DialogGUIButton($"Jump to vessel to set a Target", () => { Utils.JumpToVessel(vessel); }), new DialogGUIButton("Ok", () => { }) }; break; } case AutoPilotModeEnum.Maneuver: { msg = $"Vessel {VesselName} has no active maneuver nodes."; buttons = new DialogGUIButton[] { new DialogGUIButton($"Jump to vessel to plot a maneuver", () => { Utils.JumpToVessel(vessel); }), new DialogGUIButton("Ok", () => { }) }; break; } default: { msg = $"Invalid option"; buttons = new DialogGUIButton[] { new DialogGUIButton("Ok", () => { }) }; break; } } PopupDialog.SpawnPopupDialog ( new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new MultiOptionDialog(title, msg, title, HighLogic.UISkin, buttons), false, HighLogic.UISkin, true, string.Empty ); }
private void SetInterfaceAutopilotMode(AutoPilotModeEnum mode, bool active = true) { currentAutopilotMode = mode; if (active && !vesselElementInterface.CheckAutopilotModeAvailable(mode)) { vesselElementInterface.OpenModeUnavailableDialog(mode); return; } vesselElementInterface.VesselAutopilotActive = active; vesselElementInterface.VesselAutopilotMode = mode; vesselElementInterface.ChangeAutopilotMode(); }
public static VesselAutopilot.AutopilotMode ToKSPEnum(this AutoPilotModeEnum apMode) { switch (apMode) { case AutoPilotModeEnum.StabilityAssist: return(VesselAutopilot.AutopilotMode.StabilityAssist); case AutoPilotModeEnum.Prograde: return(VesselAutopilot.AutopilotMode.Prograde); case AutoPilotModeEnum.Retrograde: return(VesselAutopilot.AutopilotMode.Retrograde); case AutoPilotModeEnum.Normal: return(VesselAutopilot.AutopilotMode.Normal); case AutoPilotModeEnum.Antinormal: return(VesselAutopilot.AutopilotMode.Antinormal); case AutoPilotModeEnum.RadialIn: return(VesselAutopilot.AutopilotMode.RadialIn); case AutoPilotModeEnum.RadialOut: return(VesselAutopilot.AutopilotMode.RadialOut); case AutoPilotModeEnum.Target: return(VesselAutopilot.AutopilotMode.Target); case AutoPilotModeEnum.AntiTarget: return(VesselAutopilot.AutopilotMode.AntiTarget); case AutoPilotModeEnum.Maneuver: return(VesselAutopilot.AutopilotMode.Maneuver); default: return(VesselAutopilot.AutopilotMode.StabilityAssist); } }
private void UpdateElementAutopilotInfo(AutoPilotModeEnum ap) { switch (ap) { case AutoPilotModeEnum.StabilityAssist: { m_stabilityToggle.isOn = true; break; } case AutoPilotModeEnum.Antinormal: { m_antinormalToggle.isOn = true; break; } case AutoPilotModeEnum.AntiTarget: { m_antiTargetToggle.isOn = true; break; } case AutoPilotModeEnum.Maneuver: { m_maneuverToggle.isOn = true; break; } case AutoPilotModeEnum.Normal: { m_normalToggle.isOn = true; break; } case AutoPilotModeEnum.Prograde: { m_progradeToggle.isOn = true; break; } case AutoPilotModeEnum.RadialIn: { m_radialIntoggle.isOn = true; break; } case AutoPilotModeEnum.RadialOut: { m_radialOutToggle.isOn = true; break; } case AutoPilotModeEnum.Retrograde: { m_retrogradeToggle.isOn = true; break; } case AutoPilotModeEnum.Target: { m_targetToggle.isOn = true; break; } default: { m_HeadingsToggleGroup.SetAllTogglesOff(); break; } } }