public void HealthTick() { if (Dead) { return; } for (int num = hediffSet.hediffs.Count - 1; num >= 0; num--) { Hediff hediff = hediffSet.hediffs[num]; try { hediff.Tick(); hediff.PostTick(); } catch (Exception ex) { Log.Error("Exception ticking hediff " + hediff.ToStringSafe() + " for pawn " + pawn.ToStringSafe() + ". Removing hediff... Exception: " + ex); try { RemoveHediff(hediff); } catch (Exception arg) { Log.Error("Error while removing hediff: " + arg); } } if (Dead) { return; } } bool flag = false; for (int num2 = hediffSet.hediffs.Count - 1; num2 >= 0; num2--) { Hediff hediff2 = hediffSet.hediffs[num2]; if (hediff2.ShouldRemove) { hediffSet.hediffs.RemoveAt(num2); hediff2.PostRemoved(); flag = true; } } if (flag) { Notify_HediffChanged(null); } if (Dead) { return; } immunity.ImmunityHandlerTick(); if (pawn.RaceProps.IsFlesh && pawn.IsHashIntervalTick(600) && (pawn.needs.food == null || !pawn.needs.food.Starving)) { bool flag2 = false; if (hediffSet.HasNaturallyHealingInjury()) { float num3 = 8f; if (pawn.GetPosture() != 0) { num3 += 4f; Building_Bed building_Bed = pawn.CurrentBed(); if (building_Bed != null) { num3 += building_Bed.def.building.bed_healPerDay; } } foreach (Hediff hediff3 in hediffSet.hediffs) { HediffStage curStage = hediff3.CurStage; if (curStage != null && curStage.naturalHealingFactor != -1f) { num3 *= curStage.naturalHealingFactor; } } (from x in hediffSet.GetHediffs <Hediff_Injury>() where x.CanHealNaturally() select x).RandomElement().Heal(num3 * pawn.HealthScale * 0.01f); flag2 = true; } if (hediffSet.HasTendedAndHealingInjury() && (pawn.needs.food == null || !pawn.needs.food.Starving)) { Hediff_Injury hediff_Injury = (from x in hediffSet.GetHediffs <Hediff_Injury>() where x.CanHealFromTending() select x).RandomElement(); float tendQuality = hediff_Injury.TryGetComp <HediffComp_TendDuration>().tendQuality; float num4 = GenMath.LerpDouble(0f, 1f, 0.5f, 1.5f, Mathf.Clamp01(tendQuality)); hediff_Injury.Heal(8f * num4 * pawn.HealthScale * 0.01f); flag2 = true; } if (flag2 && !HasHediffsNeedingTendByPlayer() && !HealthAIUtility.ShouldSeekMedicalRest(pawn) && !hediffSet.HasTendedAndHealingInjury() && PawnUtility.ShouldSendNotificationAbout(pawn)) { Messages.Message("MessageFullyHealed".Translate(pawn.LabelCap, pawn), pawn, MessageTypeDefOf.PositiveEvent); } } if (pawn.RaceProps.IsFlesh && hediffSet.BleedRateTotal >= 0.1f) { float num5 = hediffSet.BleedRateTotal * pawn.BodySize; num5 = ((pawn.GetPosture() != 0) ? (num5 * 0.0004f) : (num5 * 0.004f)); if (Rand.Value < num5) { DropBloodFilth(); } } if (!pawn.IsHashIntervalTick(60)) { return; } List <HediffGiverSetDef> hediffGiverSets = pawn.RaceProps.hediffGiverSets; if (hediffGiverSets != null) { for (int i = 0; i < hediffGiverSets.Count; i++) { List <HediffGiver> hediffGivers = hediffGiverSets[i].hediffGivers; for (int j = 0; j < hediffGivers.Count; j++) { hediffGivers[j].OnIntervalPassed(pawn, null); if (pawn.Dead) { return; } } } } if (pawn.story == null) { return; } List <Trait> allTraits = pawn.story.traits.allTraits; for (int k = 0; k < allTraits.Count; k++) { TraitDegreeData currentData = allTraits[k].CurrentData; if (!(currentData.randomDiseaseMtbDays > 0f) || !Rand.MTBEventOccurs(currentData.randomDiseaseMtbDays, 60000f, 60f)) { continue; } BiomeDef biome; if (pawn.Tile != -1) { biome = Find.WorldGrid[pawn.Tile].biome; } else { biome = DefDatabase <BiomeDef> .GetRandom(); } IncidentDef incidentDef = DefDatabase <IncidentDef> .AllDefs.Where((IncidentDef d) => d.category == IncidentCategoryDefOf.DiseaseHuman).RandomElementByWeightWithFallback((IncidentDef d) => biome.CommonalityOfDisease(d)); if (incidentDef == null) { continue; } string blockedInfo; List <Pawn> list = ((IncidentWorker_Disease)incidentDef.Worker).ApplyToPawns(Gen.YieldSingle(pawn), out blockedInfo); if (PawnUtility.ShouldSendNotificationAbout(pawn)) { if (list.Contains(pawn)) { Find.LetterStack.ReceiveLetter("LetterLabelTraitDisease".Translate(incidentDef.diseaseIncident.label), "LetterTraitDisease".Translate(pawn.LabelCap, incidentDef.diseaseIncident.label, pawn.Named("PAWN")).AdjustedFor(pawn), LetterDefOf.NegativeEvent, pawn); } else if (!blockedInfo.NullOrEmpty()) { Messages.Message(blockedInfo, pawn, MessageTypeDefOf.NeutralEvent); } } } }
private static void DoSaveTranslationReport() { LoadedLanguage activeLanguage = LanguageDatabase.activeLanguage; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("Translation report for " + activeLanguage); if (activeLanguage.defInjections.Any((DefInjectionPackage x) => x.usedOldRepSyntax)) { stringBuilder.AppendLine(); stringBuilder.AppendLine("Consider using <Something.Field.Example.Etc>translation</Something.Field.Example.Etc> def-injection syntax instead of <rep>."); } try { AppendGeneralLoadErrors(stringBuilder); } catch (Exception arg) { Log.Error("Error while generating translation report (general load errors): " + arg); } try { AppendDefInjectionsLoadErros(stringBuilder); } catch (Exception arg2) { Log.Error("Error while generating translation report (def-injections load errors): " + arg2); } try { AppendBackstoriesLoadErrors(stringBuilder); } catch (Exception arg3) { Log.Error("Error while generating translation report (backstories load errors): " + arg3); } try { AppendMissingKeyedTranslations(stringBuilder); } catch (Exception arg4) { Log.Error("Error while generating translation report (missing keyed translations): " + arg4); } List <string> list = new List <string>(); try { AppendMissingDefInjections(stringBuilder, list); } catch (Exception arg5) { Log.Error("Error while generating translation report (missing def-injections): " + arg5); } try { AppendMissingBackstories(stringBuilder); } catch (Exception arg6) { Log.Error("Error while generating translation report (missing backstories): " + arg6); } try { AppendUnnecessaryDefInjections(stringBuilder, list); } catch (Exception arg7) { Log.Error("Error while generating translation report (unnecessary def-injections): " + arg7); } try { AppendRenamedDefInjections(stringBuilder); } catch (Exception arg8) { Log.Error("Error while generating translation report (renamed def-injections): " + arg8); } try { AppendArgumentCountMismatches(stringBuilder); } catch (Exception arg9) { Log.Error("Error while generating translation report (argument count mismatches): " + arg9); } try { AppendUnnecessaryKeyedTranslations(stringBuilder); } catch (Exception arg10) { Log.Error("Error while generating translation report (unnecessary keyed translations): " + arg10); } try { AppendKeyedTranslationsMatchingEnglish(stringBuilder); } catch (Exception arg11) { Log.Error("Error while generating translation report (keyed translations matching English): " + arg11); } try { AppendBackstoriesMatchingEnglish(stringBuilder); } catch (Exception arg12) { Log.Error("Error while generating translation report (backstories matching English): " + arg12); } try { AppendDefInjectionsSyntaxSuggestions(stringBuilder); } catch (Exception arg13) { Log.Error("Error while generating translation report (def-injections syntax suggestions): " + arg13); } try { AppendTKeySystemErrors(stringBuilder); } catch (Exception arg14) { Log.Error("Error while generating translation report (TKeySystem errors): " + arg14); } string text = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); if (text.NullOrEmpty()) { text = GenFilePaths.SaveDataFolderPath; } text = Path.Combine(text, "TranslationReport.txt"); File.WriteAllText(text, stringBuilder.ToString()); Messages.Message("MessageTranslationReportSaved".Translate(Path.GetFullPath(text)), MessageTypeDefOf.TaskCompletion, historical: false); }
public void HealthTick() { if (!this.Dead) { for (int num = this.hediffSet.hediffs.Count - 1; num >= 0; num--) { Hediff hediff = this.hediffSet.hediffs[num]; hediff.Tick(); hediff.PostTick(); } bool flag = false; for (int num2 = this.hediffSet.hediffs.Count - 1; num2 >= 0; num2--) { Hediff hediff2 = this.hediffSet.hediffs[num2]; if (hediff2.ShouldRemove) { this.hediffSet.hediffs.RemoveAt(num2); hediff2.PostRemoved(); flag = true; } } if (flag) { this.Notify_HediffChanged(null); } if (!this.Dead) { this.immunity.ImmunityHandlerTick(); if (this.pawn.RaceProps.IsFlesh && this.pawn.IsHashIntervalTick(600) && (this.pawn.needs.food == null || !this.pawn.needs.food.Starving)) { bool flag2 = false; if (this.hediffSet.HasNaturallyHealingInjury()) { float num3 = 8f; if (this.pawn.GetPosture() != 0) { num3 = (float)(num3 + 4.0); Building_Bed building_Bed = this.pawn.CurrentBed(); if (building_Bed != null) { num3 += building_Bed.def.building.bed_healPerDay; } } Hediff_Injury hediff_Injury = this.hediffSet.GetHediffs <Hediff_Injury>().Where(HediffUtility.CanHealNaturally).RandomElement(); hediff_Injury.Heal((float)(num3 * this.pawn.HealthScale * 0.0099999997764825821)); flag2 = true; } if (this.hediffSet.HasTendedAndHealingInjury() && (this.pawn.needs.food == null || !this.pawn.needs.food.Starving)) { Hediff_Injury hediff_Injury2 = this.hediffSet.GetHediffs <Hediff_Injury>().Where(HediffUtility.CanHealFromTending).RandomElement(); float tendQuality = hediff_Injury2.TryGetComp <HediffComp_TendDuration>().tendQuality; float num4 = GenMath.LerpDouble(0f, 1f, 0.5f, 1.5f, Mathf.Clamp01(tendQuality)); hediff_Injury2.Heal((float)(22.0 * num4 * this.pawn.HealthScale * 0.0099999997764825821)); flag2 = true; } if (flag2 && !this.HasHediffsNeedingTendByColony(false) && !HealthAIUtility.ShouldSeekMedicalRest(this.pawn) && !this.hediffSet.HasTendedAndHealingInjury() && PawnUtility.ShouldSendNotificationAbout(this.pawn)) { Messages.Message("MessageFullyHealed".Translate(this.pawn.LabelCap), this.pawn, MessageTypeDefOf.PositiveEvent); } } if (this.pawn.RaceProps.IsFlesh && this.hediffSet.BleedRateTotal >= 0.10000000149011612) { float num5 = this.hediffSet.BleedRateTotal * this.pawn.BodySize; num5 = (float)((this.pawn.GetPosture() != 0) ? (num5 * 0.00079999997979030013) : (num5 * 0.00800000037997961)); if (Rand.Value < num5) { this.TryDropBloodFilth(); } } List <HediffGiverSetDef> hediffGiverSets = this.pawn.RaceProps.hediffGiverSets; if (hediffGiverSets != null && this.pawn.IsHashIntervalTick(60)) { for (int i = 0; i < hediffGiverSets.Count; i++) { List <HediffGiver> hediffGivers = hediffGiverSets[i].hediffGivers; int num6 = 0; while (num6 < hediffGivers.Count) { hediffGivers[num6].OnIntervalPassed(this.pawn, null); if (!this.pawn.Dead) { num6++; continue; } return; } } } } } }
private void CheckDiscovered() { if (this.discovered) { return; } if (!this.parent.CurStage.becomeVisible) { return; } this.discovered = true; if (this.Props.sendLetterWhenDiscovered && PawnUtility.ShouldSendNotificationAbout(base.Pawn)) { if (base.Pawn.RaceProps.Humanlike) { string label; if (!this.Props.discoverLetterLabel.NullOrEmpty()) { label = string.Format(this.Props.discoverLetterLabel, base.Pawn.LabelShort.CapitalizeFirst()).CapitalizeFirst(); } else { label = "LetterLabelNewDisease".Translate() + " (" + base.Def.label + ")"; } string text; if (!this.Props.discoverLetterText.NullOrEmpty()) { text = string.Format(this.Props.discoverLetterText, base.Pawn.LabelIndefinite()).AdjustedFor(base.Pawn, "PAWN").CapitalizeFirst(); } else if (this.parent.Part == null) { text = "NewDisease".Translate(new object[] { base.Pawn.LabelIndefinite(), base.Def.label, base.Pawn.LabelDefinite() }).AdjustedFor(base.Pawn, "PAWN").CapitalizeFirst(); } else { text = "NewPartDisease".Translate(new object[] { base.Pawn.LabelIndefinite(), this.parent.Part.Label, base.Pawn.LabelDefinite(), base.Def.label }).AdjustedFor(base.Pawn, "PAWN").CapitalizeFirst(); } Find.LetterStack.ReceiveLetter(label, text, (this.Props.letterType == null) ? LetterDefOf.NegativeEvent : this.Props.letterType, base.Pawn, null, null); } else { string text2; if (!this.Props.discoverLetterText.NullOrEmpty()) { text2 = string.Format(this.Props.discoverLetterText, base.Pawn.LabelIndefinite()).AdjustedFor(base.Pawn, "PAWN").CapitalizeFirst(); } else if (this.parent.Part == null) { text2 = "NewDiseaseAnimal".Translate(new object[] { base.Pawn.LabelShort, base.Def.LabelCap, base.Pawn.LabelDefinite() }).AdjustedFor(base.Pawn, "PAWN").CapitalizeFirst(); } else { text2 = "NewPartDiseaseAnimal".Translate(new object[] { base.Pawn.LabelShort, this.parent.Part.Label, base.Pawn.LabelDefinite(), base.Def.LabelCap }).AdjustedFor(base.Pawn, "PAWN").CapitalizeFirst(); } Messages.Message(text2, base.Pawn, (this.Props.messageType == null) ? MessageTypeDefOf.NegativeHealthEvent : this.Props.messageType, true); } } }