void Activate(VesselSettings vessel) { Debug.Log($"[{nameof(AutoAction)}] flight: Activate"); // Loading facility default settings FacilitySettings facility = GetFacilitySettings(); // Selecting action set if (vessel.ActionSet is int set) { Static.Vessel.SetGroupOverride(FlightGlobals.ActiveVessel, set); } // Activating standard action groups ActionGroupList actionGroups = FlightGlobals.ActiveVessel.ActionGroups; actionGroups.SetGroup(KSPActionGroup.SAS, vessel.ActivateSAS ?? facility.ActivateSAS); actionGroups.SetGroup(KSPActionGroup.RCS, vessel.ActivateRCS ?? facility.ActivateRCS); actionGroups.SetGroup(KSPActionGroup.Brakes, vessel.ActivateBrakes ?? facility.ActivateBrakes); actionGroups.SetGroup(KSPActionGroup.Abort, vessel.ActivateAbort ?? facility.ActivateAbort); // Special treatment for the groups with the initial state determined by the part state SetAutoInitializingGroup(KSPActionGroup.Gear, vessel.ActivateGear); SetAutoInitializingGroup(KSPActionGroup.Light, vessel.ActivateLights); // Activating custom action groups foreach (int customGroup in vessel.CustomGroups.OfType <int>()) { ActivateCustomActionGroup(customGroup); } // Setting precision control SetPrecisionMode(vessel.SetPrecCtrl ?? facility.SetPrecCtrl); // Setting throttle FlightInputHandler.state.mainThrottle = Mathf.Max(0, Mathf.Min(1, (vessel.SetThrottle ?? facility.SetThrottle) / 100F)); // Setting trim FlightInputHandler.state.pitchTrim = TrimStep * vessel.SetPitchTrim; FlightInputHandler.state.yawTrim = TrimStep * vessel.SetYawTrim; FlightInputHandler.state.rollTrim = TrimStep * vessel.SetRollTrim; FlightInputHandler.state.wheelThrottleTrim = TrimStep * vessel.SetWheelMotorTrim; FlightInputHandler.state.wheelSteerTrim = -TrimStep * vessel.SetWheelSteerTrim; // inverted // Staging if (vessel.Stage ?? facility.Stage) { StageManager.ActivateNextStage(); } }
// executes the abort action group and write event to log public void executeAbort() { if (auto_destruct_active) { return; } string log_entry = Localizer.GetStringByTag("#autoLOC_OCTO_RED_SELF_DESTRUCT_ACTIVATED"); FlightLogger.eventLog.Add(log_entry); ActionGroupList groups = vessel.ActionGroups; groups.SetGroup(KSPActionGroup.Abort, true); }