private void OnDestroy() { if (vessel != null && vessel.gameObject.activeInHierarchy && FlightGlobals.fetch != null && ReferenceEquals(FlightGlobals.fetch.VesselTarget, this)) { vessel.StartCoroutine(CallbackUtil.DelayedCallback(1, FlightGlobals.fetch.SetVesselTarget, vessel, false)); } Fields[nameof(numSegments)].OnValueModified -= onNumSegmentsChange; Fields[nameof(ShowUI)].OnValueModified -= showUI; Fields[nameof(ShowConstructionUI)].OnValueModified -= showConstructionUI; GameEvents.onVesselWasModified.Remove(onVesselWasModified); GameEvents.onVesselCrewWasModified.Remove(onVesselCrewWasModified); axisController?.Disconnect(); axisController = null; UI?.Close(); cUI?.Close(); #if NIGHTBUILD GlobalsReloader.RemoveListener(onGlobalsLoaded); #endif }
public override void OnStart(StartState state) { base.OnStart(state); #if DEBUG this.Debug( $"prefab model tree: {DebugUtils.formatTransformTree(part.partInfo.partPrefab.transform)}"); #endif loadingDamper = ATMagneticDamper.GetDamper(part, LoadingDamperID); if (loadingDamper == null) { this.ConfigurationInvalid($"Unable to find loading damper with ID {LoadingDamperID}"); return; } launchingDamper = ATMagneticDamper.GetDamper(part, LaunchingDamperID) as ExtensibleMagneticDamper; if (launchingDamper == null) { this.ConfigurationInvalid($"Unable to find launching damper with ID {LoadingDamperID}"); return; } if (!updateSegments((int)numSegments) || !updateScaffold(DeploymentProgress)) { this.ConfigurationInvalid("Unable to initialize dynamic model components"); } setupNumSegmentsControls(); Fields[nameof(ShowUI)].OnValueModified += showUI; Fields[nameof(ShowConstructionUI)].OnValueModified += showConstructionUI; axisController = new AxisAttitudeController(this); UI = new AcceleratorWindow(this); if (ShowUI) { UI.Show(this); } cUI = new ConstructionWindow(this); if (ShowConstructionUI) { cUI.Show(this); } fixConstructionState(); updateWorkforce(); UpdateParams(); UpdateSegmentCost(); }