internal void UnHighlightStack() { if (/* HighLogic.LoadedSceneIsEditor && */ phl != null) { if (segments != null && highlightID >= 0) { foreach (var s in segments) { if (s != null) { phl.DisablePartHighlighting(highlightID, s.part); } } } } }
/// <summary> /// Update logic on every physics frame update. /// Place your custom update logic in DI_Update() /// </summary> public void FixedUpdate() { if (!HighLogic.LoadedSceneIsFlight || alarmDisabled) { return; } if (streamMultiplier > 0 && Planetarium.GetUniversalTime() - lastDecayTime > 1) { streamMultiplier = Math.Max(0, streamMultiplier - decayPerMinute); lastDecayTime = Planetarium.GetUniversalTime(); } if (vesselHighlightDict.ContainsKey(this.vessel.id)) { try { // Only update the module during flight and after the re-initialization has run if (HighLogic.LoadedSceneIsFlight && this.HasInitted && this.vessel == FlightGlobals.ActiveVessel) { // Highlighting the part, which contains this updating FailureModule if it is in a 'failed' state, // it is not in 'silent' state and 'glow' is globally enabled // Actually, there is not any place in a code of the whole mod where that 'silent' state is turning on // (maybe some FailureModules can be defined as 'silent' by editing files) if (this.HasFailed && (DangIt.Instance.CurrentSettings.Glow && (AlarmManager.visibleUI || !DangIt.Instance.CurrentSettings.DisableGlowOnF2))) { if (!phl.HighlightListContains(vesselHighlightDict[this.vessel.id], this.part)) { phl.AddPartToHighlight(vesselHighlightDict[this.vessel.id], this.part); Log.Info("Adding part to highlight list: part: " + part.persistentId + ", " + part.partInfo.title); } } else // Turning off the highlighting of the part, which contains this updating FailureModule // if it is not in a 'failed' state, or it is in 'silent' state, or if 'glow' is globally disabled // if (!this.HasFailed || this.Silent || !DangIt.Instance.CurrentSettings.Glow || (!visibleUI && DangIt.Instance.CurrentSettings.DisableGlowOnF2)) { if (!AlarmManager.failedParts.ContainsKey(new FailedPart(this.part))) { //Log.Info("Calling DisablePartHighlighting part: " + part.persistentId + ", " + part.partInfo.title); if (AlarmManager.failedParts.ContainsKey(new FailedPart(this.part))) { phl.DisablePartHighlighting(vesselHighlightDict[this.vessel.id], this.part); } } } float now = DangIt.Now(); float dt = now - LastFixedUpdate; this.LastFixedUpdate = now; // The temperature aging is independent from the use of the part this.Age += (dt * this.TemperatureMultiplier()); if (!PartIsActive() || !DangIt.Instance.CurrentSettings.EnabledForSave) { return; } else { this.Age += dt; this.CurrentMTBF = this.MTBF * HighLogic.CurrentGame.Parameters.CustomParams <DangItCustomParams1>().MTBF_Multiplier *this.ExponentialDecay(); // If the part has not already failed, toss the dice if (!this.HasFailed) { float f = this.Lambda(); #if DEBUG // if (printChances) // DangIt.myLog.Debug("this.Lambda: " + f.ToString()); #endif if (UnityEngine.Random.Range(0f, 1f) < f) { streamMultiplier = 0; this.Fail(); } } // Run custom update logic this.DI_Update(); } } } catch (Exception e) { OnError(e); } } }