public void OnDestroy() { if (HighLogic.LoadedSceneIsFlight) { if (vessel != null && !vessel.HoldPhysics && FlightGlobals.ready && vessel.missionTime > 0) { BPB_VesselModule vm = vessel.GetComponent <BPB_VesselModule>(); if (vm != null && vm.armed && vm.explosiveTriggerEnabled && !revert) { Log.Info("Explosion detected, part: " + part.partInfo.title); if (this.vessel.isActiveVessel) { ScreenMessages.PostScreenMessage("<color=red>ABORTING - Explosion Detected!</color>"); } else { ScreenMessages.PostScreenMessage(vessel.vesselName + " - ABORTING - Explosion Detected!"); } ScreenMessages.PostScreenMessage(this.part.partInfo.title + " exploded", 10f); vm.SetAllActive(true, false, "Aborted! Explosion Detected"); GameEvents.onGameSceneSwitchRequested.Remove(onGameSceneSwitchRequested); vm.TriggerAbort(); return; } } } GameEvents.onGameSceneSwitchRequested.Remove(onGameSceneSwitchRequested); }
IEnumerator UpdateButton() { while (true) { if (FlightGlobals.ActiveVessel != null) { if (lastActiveVessel != FlightGlobals.ActiveVessel) { lastActiveVessel = FlightGlobals.ActiveVessel; vmLastActiveVessel = FlightGlobals.ActiveVessel.GetComponent <BPB_VesselModule>(); } if (vmLastActiveVessel.armed && (!lastActiveVessel.IsControllable || lastActiveVessel.Parts.Count == 0)) { DisableAbortSequence(); } if (toolbarControl != null && vmLastActiveVessel.aborted && !vmLastActiveVessel.abortAcknowledged) { // Flash the button here if (Planetarium.GetUniversalTime() - lastFlashTime > 0.5f) { lastFlashTime = Planetarium.GetUniversalTime(); if (buttonRed) { SetButtonNormal(); } else { SetButtonRed(); } } } else { if (vmLastActiveVessel.abortAcknowledged) { if (!buttonRed) { SetButtonRed(); } } else { if (buttonRed) { SetButtonNormal(); } } } } else if (toolbarControl != null) { SetButtonNormal(); } yield return(new WaitForSeconds(0.5f)); } }
void Start() { if (!HighLogic.LoadedSceneIsFlight && !HighLogic.LoadedSceneIsEditor) { return; } if (HighLogic.LoadedSceneIsFlight) { vm = this.vessel.GetComponent <BPB_VesselModule>(); flightInfo = new Flight(); av = new AbortValues(flightInfo); Events["openAutoAbort"].guiActive = HighLogic.CurrentGame.Parameters.CustomParams <BPB_Options>().allowChangeInFlight&& HighLogic.CurrentGame.Parameters.CustomParams <BPB_UI_Options>().pawWindow; } else { if (editorInfo == null) { editorInfo = new Editor(); SetAllValues(editorInfo.av); } if (HighLogic.CurrentGame.Parameters.CustomParams <BPB_Options>().activeInVAB&& EditorDriver.editorFacility == EditorFacility.VAB) { Events["openAutoAbort"].guiActive = HighLogic.CurrentGame.Parameters.CustomParams <BPB_Options>().activeInVAB&& HighLogic.CurrentGame.Parameters.CustomParams <BPB_UI_Options>().pawWindow; } if (HighLogic.CurrentGame.Parameters.CustomParams <BPB_Options>().activeInSPH&& EditorDriver.editorFacility == EditorFacility.SPH) { Events["openAutoAbort"].guiActive = HighLogic.CurrentGame.Parameters.CustomParams <BPB_Options>().activeInSPH&& HighLogic.CurrentGame.Parameters.CustomParams <BPB_UI_Options>().pawWindow; } av = new AbortValues(editorInfo); } if (!initted) { if (HighLogic.LoadedSceneIsEditor) { av = new AbortValues(flightInfo); CopyOrInit(); } else { flightInfo.av.ResetToDefault(); SetAllValues(av); flightInfo.SaveCurrent(this); } initted = true; } else { if (HighLogic.LoadedSceneIsEditor) { editorInfo.av.armed = armed; editorInfo.av.vertSpeedTriggerEnabled = vertSpeedTriggerEnabled; editorInfo.av.gForceTriggerEnabled = gForceTriggerEnabled; editorInfo.av.vertSpeed = vertSpeed; editorInfo.av.exceedingAoA = exceedingAoA; editorInfo.av.maxAoA = maxAoA; editorInfo.av.gForceTrigger = gForceTrigger; editorInfo.av.explosiveTriggerEnabled = explosiveTriggerEnabled; editorInfo.av.disableAfter = disableAfter; editorInfo.av.actionAfterTimeout = actionAfterTimeout; editorInfo.av.disableAtAltitudeKm = disableAtAltitudeKm; editorInfo.av.disableAtAltitude = disableAtAltitudeKm * 1000; editorInfo.av.ignoreAoAAboveAltitudeKm = ignoreAoAAboveAltitudeKm; editorInfo.av.ignoreAoAAboveAltitude = ignoreAoAAboveAltitudeKm * 1000; editorInfo.av.maxTimeoutActionG = maxTimeoutActionG; editorInfo.av.postAbortAction = postAbortAction; editorInfo.av.postAbortDelay = postAbortDelay; editorInfo.av.delayPostAbortUntilSafe = delayPostAbortUntilSafe; SetAllValues(editorInfo.av); } else { flightInfo.av.armed = armed; flightInfo.av.vertSpeedTriggerEnabled = vertSpeedTriggerEnabled; flightInfo.av.gForceTriggerEnabled = gForceTriggerEnabled; flightInfo.av.vertSpeed = vertSpeed; flightInfo.av.exceedingAoA = exceedingAoA; flightInfo.av.maxAoA = maxAoA; flightInfo.av.gForceTrigger = gForceTrigger; flightInfo.av.explosiveTriggerEnabled = explosiveTriggerEnabled; flightInfo.av.disableAfter = disableAfter; flightInfo.av.actionAfterTimeout = actionAfterTimeout; flightInfo.av.disableAtAltitudeKm = disableAtAltitudeKm; flightInfo.av.disableAtAltitude = disableAtAltitudeKm * 1000; flightInfo.av.ignoreAoAAboveAltitudeKm = ignoreAoAAboveAltitudeKm; flightInfo.av.ignoreAoAAboveAltitude = ignoreAoAAboveAltitudeKm * 1000; flightInfo.av.maxTimeoutActionG = maxTimeoutActionG; flightInfo.av.postAbortAction = postAbortAction; flightInfo.av.postAbortDelay = postAbortDelay; flightInfo.av.delayPostAbortUntilSafe = delayPostAbortUntilSafe; av = (AbortValues)flightInfo.av.Clone(); SetAllValues(flightInfo.av); if (vm != null) { vm.SetAllValues(flightInfo.av); } else { Log.Info("No VesselModule found"); } flightInfo.SaveCurrent(this); } } }