public IEnumerator Landing() { float SuicideBurnTime = 0; float SuicideBurnAltitude = 0; SuicideBurnTime = AutolandCalculator.CalculateBurnTime(vessel); SuicideBurnAltitude = AutolandCalculator.CalculateBurnAltitude(SuicideBurnTime, vessel); Debug.Log("Coasting To Suicide Burn"); auto.SetMode(VesselAutopilot.AutopilotMode.Retrograde); yield return new WaitUntil(() => vessel.GetHeightFromTerrain() > SuicideBurnAltitude); auto.SetMode(VesselAutopilot.AutopilotMode.StabilityAssist); vessel.ctrlState.mainThrottle = 100; Debug.Log("Burning"); yield return new WaitUntil(() => vessel.verticalSpeed < -1); vessel.ctrlState.mainThrottle = 0; }
public void autopilotModeCallback(byte ID, object Data) { byte[] payload = (byte[])Data; VesselAutopilot autopilot = FlightGlobals.ActiveVessel.Autopilot; if (autopilot == null) { Debug.Log("KerbalSimpit : Ignoring a SAS MODE Message since I could not find the autopilot"); return; } mySASMode = (VesselAutopilot.AutopilotMode)(payload[0]); if (autopilot.CanSetMode(mySASMode)) { autopilot.SetMode(mySASMode); if (KSPit.Config.Verbose) { Debug.Log(String.Format("KerbalSimpit: payload is {0}", mySASMode)); Debug.Log(String.Format("KerbalSimpit: SAS mode is {0}", FlightGlobals.ActiveVessel.Autopilot.Mode.ToString())); } } else { Debug.Log(String.Format("KerbalSimpit: Unable to set SAS mode to {0}", mySASMode.ToString())); } }
public static bool SetActualMode(this VesselAutopilot autopilot, VesselAutopilot.AutopilotMode mode) { mode = ConvertMode(mode); if (autopilot.CanSetMode(mode)) { var result = autopilot.SetMode(mode); var autopilotUI = GameObject.FindObjectOfType <VesselAutopilotUI>(); if (autopilotUI != null && mode >= 0 && (int)mode < autopilotUI.modeButtons.Length) { autopilotUI.modeButtons[(int)mode].SetState(true); } return(result); } return(false); }