public void OnPartBroken(BaseQualityControl moduleQualityControl) { if (!BARISBridge.PartsCanBreak || !BARISBridge.EnginesCanFail) { return; } //Record state isBroken = true; //If the chute is deployed then cut the chute string message = string.Empty; string qualityDisplay = string.Empty; if (deploymentState == deploymentStates.DEPLOYED || deploymentState == deploymentStates.SEMIDEPLOYED) { CutParachute(); //Player messages message = this.part.partInfo.title + " chute cut!"; qualityDisplay = "Broken"; } else { //The chute cannot deploy message = this.part.partInfo.title + " cannot deploy chute!"; qualityDisplay = " stuck"; ; } //Inform player qualityControl.UpdateQualityDisplay(qualityControl.qualityDisplay + qualityDisplay); if (this.part.vessel == FlightGlobals.ActiveVessel) { BARISScenario.Instance.LogPlayerMessage(message); } }
public void onPartBroken(BaseQualityControl moduleQualityControl) { if (!isRunning || moduleQualityControl.part == this.part) { return; } ModuleQualityControl qualityModule = null; if (moduleQualityControl is ModuleQualityControl) { qualityModule = (ModuleQualityControl)moduleQualityControl; } if (qualityModule == null) { return; } //Record original highlight color qualityModule.originalHighlightColor = qualityModule.part.highlightColor; //Set broken highlight color qualityModule.part.highlightColor = Color.red; qualityModule.part.Highlight(true); //Roll RNG to see if the part gains quality. int rollResult = UnityEngine.Random.Range(minDieRoll, maxDieRoll); string partTitle = string.Empty; int totalQuality = 0; string message = ""; //If we've met our target number then improve part quality. if (rollResult >= improveQualityTargetNumber) { //Get the part title partTitle = qualityModule.part.partInfo.title; //Don't exceed max quality. totalQuality = qualityModule.quality + BARISScenario.Instance.GetFlightBonus(qualityModule.part); if (totalQuality + qualityImprovementAmount <= BARISBridge.QualityCap) { //Record the flight experience. BARISScenario.Instance.RecordFlightExperience(qualityModule.part, BARISBridge.FlightsPerQualityBonus * qualityImprovementAmount); //Calculate the new quality rating. totalQuality = qualityModule.quality + BARISScenario.Instance.GetFlightBonus(qualityModule.part); message = partTitle + " " + BARISScenario.QualityLabel + totalQuality; //Inform the user. ScreenMessages.PostScreenMessage(message, BARISScenario.MessageDuration, ScreenMessageStyle.UPPER_CENTER); } else { //Max quality reached. message = partTitle + Localizer.Format(BARISScenario.kMaxQualityReached); //Inform the user. ScreenMessages.PostScreenMessage(message, BARISScenario.MessageDuration, ScreenMessageStyle.UPPER_CENTER); } } //Roll to see if the vessel explodes. If not then increase the chances slightly. float explodeResult = UnityEngine.Random.Range(0f, 100.0f); if (explodeResult >= (100.0f - vesselExplodeProbability)) { for (int index = 0; index < qualityModules.Length; index++) { qualityModules[index].SetMarkedForDeath(true); } } else { vesselExplodeProbability += explodeProbabilityIncrement; //Update quality qualityModule.quality = totalQuality; qualityModule.UpdateQualityDisplay(BARISScenario.GetConditionSummary(qualityModule.currentMTBF, qualityModule.MaxMTBF, qualityModule.currentQuality, qualityModule.MaxQuality)); } }