private void triggerFailure(int type) { failure_du += failureData[type]; failureTypes ft = (failureTypes)type; updateCore(); /* Make sure we save our failureData, just in case we explode the part */ Logging.LogFormat("Failing engine {0}: {1}", configuration, ft.ToString()); ScreenMessages.PostScreenMessage(String.Format("[TestLite] {0} on {1}", failureDescription[type], configuration), 5f); FlightLogger.eventLog.Add(String.Format("[{0}] {1} on {2}", KSPUtil.PrintTimeCompact((int)Math.Floor(this.vessel.missionTime), false), failureDescription[type], configuration)); switch (severityType[type]) { case 0: transient_failure = true; break; case 1: minor_failure = true; break; case 2: major_failure = true; break; } switch (ft) { case failureTypes.TRANSIENT: case failureTypes.IGNITION: engine.Shutdown(); break; case failureTypes.PERMANENT: engine.Shutdown(); /* It's permanently dead. It might even explode. */ engine.ignitions = 0; if (Core.Instance.rand.Next(3) == 0) { part.explode(); } break; case failureTypes.PERFLOSS: engine.ispMult *= 0.4d + Core.Instance.rand.NextDouble() * 0.2d; break; case failureTypes.THRUSTLOSS: engine.flowMult *= 0.4d + Core.Instance.rand.NextDouble() * 0.2d; break; } setColour(); }
private void triggerFailure(int type) { if (isSolid) /* Map non-solid-appropriate failureTypes to more suitable ones */ { if (type == (int)failureTypes.TRANSIENT) { type = (int)failureTypes.PERMANENT; } else if (type == (int)failureTypes.THRUSTLOSS) { type = (int)failureTypes.PERFLOSS; } } double fdScale = Math.Min(1.0, (remainingBurnTime + ratedContinuousBurnTime + 5.0 - currentRunTime) / ratedContinuousBurnTime); double award_du = failureData[type] * Math.Pow(fdScale, 2.0); failure_du += award_du; failureTypes ft = (failureTypes)type; updateCore(); /* Make sure we save our failureData, just in case we explode the part */ Logging.LogFormat("Failing engine {0}: {1}; awarding {2} du", configuration, ft.ToString(), award_du); ScreenMessages.PostScreenMessage(String.Format("[TestLite] {0} on {1}", failureDescription[type], configuration), 5f); FlightLogger.eventLog.Add(String.Format("[{0}] {1} on {2}", KSPUtil.PrintTimeCompact((int)Math.Floor(this.vessel.missionTime), false), failureDescription[type], configuration)); switch (severityType[type]) { case 0: transient_failure = true; break; case 1: minor_failure = true; break; case 2: major_failure = true; break; } switch (ft) { case failureTypes.TRANSIENT: case failureTypes.IGNITION: engine.Shutdown(); break; case failureTypes.PERMANENT: engine.Shutdown(); /* It's permanently dead. It might even explode. */ engine.ignitions = 0; if (isSolid || Core.Instance.rand.Next(3) == 0) /* Solids always explode */ { part.explode(); if (!determinismMode) { fraternalDamage(); } } break; case failureTypes.PERFLOSS: engine.ispMult *= 0.4d + Core.Instance.rand.NextDouble() * 0.2d; break; case failureTypes.THRUSTLOSS: engine.flowMult *= 0.4d + Core.Instance.rand.NextDouble() * 0.2d; break; } setColour(); }