public static void Postfix(WeatherManager __instance, Map map) { if (map.weatherManager.curWeather.defName == "LotRW_HealingRainWD") { if (Find.TickManager.TicksGame % 10 == 0) { Pawn pawn = map.mapPawns.AllPawnsSpawned.RandomElement(); if (!pawn.Position.Roofed(map)) { IEnumerable <Hediff_Injury> injuries = pawn.health.hediffSet.GetHediffs <Hediff_Injury>(); if (injuries != null && injuries.Count() > 0) { Hediff_Injury injury = injuries.RandomElement(); if (injury.CanHealNaturally() && !injury.IsPermanent()) { injury.Heal(Rand.Range(.2f, 2f)); if (Rand.Chance(.5f)) { EffectMaker.MakeEffect(ThingDef.Named("Mote_HealingWaves"), pawn.DrawPos, map, Rand.Range(.4f, .6f), 180, 1f, 0); } else { EffectMaker.MakeEffect(ThingDef.Named("Mote_HealingWaves"), pawn.DrawPos, map, Rand.Range(.4f, .6f), 180, 1f, 0, 180, .1f, .02f, .19f, false); } } } } } } }
public static void CleanBite(Pawn actor, Pawn victim) { HediffWithComps fangs = actor.GetVampFangs(); string dmgLabel; float dmgAmount; DamageDef dmgDef; RulePackDef dmgRules; if (fangs != null && TryGetFangsDmgInfo(fangs, out dmgLabel, out dmgAmount, out dmgDef, out dmgRules)) { Hediff_Injury neckInjury = (Hediff_Injury)victim.health.hediffSet.hediffs.FirstOrDefault(x => x is Hediff_Injury y && !y.IsPermanent() && y?.Part?.def == BodyPartDefOf.Neck); if (neckInjury == null) { neckInjury = (Hediff_Injury)victim.health.hediffSet.hediffs.FirstOrDefault(x => x is Hediff_Injury y && !y.IsPermanent()); } if (neckInjury != null) { neckInjury.Heal((int)neckInjury.Severity + 1); Find.BattleLog.Add( new BattleLogEntry_StateTransition(victim, RulePackDef.Named("ROMV_BiteCleaned"), actor, null, null) ); if (victim.IsGhoul() && victim?.VampComp()?.ThrallData?.BondStage == BondStage.Thrall) { TryRemoveHarmedMemory(actor, victim); } else if (!victim.health.capacities.CanBeAwake) { TryRemoveHarmedMemory(actor, victim); } } } }
private static void HealToStanding(Pawn pawn, BodyPartRecord part) { bool shouldStop = false; float extraHealth = 100f; //TODO: no magic number; extraHealth *= pawn.HealthScale; float healPerIteration = 10f; float totalExtraHealed = 0f; int guard = 0; while (totalExtraHealed <= extraHealth && guard < 1000) { Hediff_Injury hediff_Injury = pawn.health.hediffSet.GetHediffs <Hediff_Injury>().Where(new Func <Hediff_Injury, bool>(HediffUtility.CanHealNaturally)).RandomElement <Hediff_Injury>(); if (hediff_Injury == null || !pawn.Downed) { shouldStop = true; } hediff_Injury.Heal(healPerIteration); if (shouldStop) { totalExtraHealed += healPerIteration; } guard++; } pawn.jobs.EndCurrentJob(JobCondition.InterruptForced); if (pawn.GetLord() == null || pawn.GetLord().LordJob == null) { LordMaker.MakeNewLord(Faction.OfPlayer, new LordJob_SearchAndDestroy(), pawn.Map, new List <Pawn> { pawn }); } Find.LetterStack.ReceiveLetter("WTH_Letter_HealedToStanding_Label".Translate(), "WTH_Letter_HealedToStanding_Description".Translate(), LetterDefOf.ThreatBig, pawn); }
public void TryHealWounds() { IEnumerable <Hediff> enumerable = from hd in this.pawn.health.hediffSet.hediffs where !hd.IsPermanent() && hd.def.isBad && hd is Hediff_Injury select hd; bool flag = enumerable != null; if (flag && canHeal) { foreach (Hediff hediff in enumerable) { Hediff_Injury Injury = hediff as Hediff_Injury; bool flag2 = Injury != null; Rand.PushState(); float chance = Rand.Value; Rand.PopState(); if (flag2 && canHeal && chance < Props.healFreshChance) { float num = Injury.Severity * 0.001f; Injury.Heal(num); // Log.Message(string.Format("num = {0}",num)); if (Props.useFood) { pawn.needs.food.CurLevel -= num; } if (Props.useRest) { pawn.needs.rest.CurLevel -= num; } // Traverse.Create(hediff_Injury).Property(name: "BleedRate").SetValue(hediff_Injury.BleedRate*0.95); } } } }
// Self healing //private int timerRepairDamage = 0; private void TryHealDamagedBodyPartOfRobot(X2_AIRobot robot) { //timerRepairDamage--; //if (timerRepairDamage > 0) // return; //timerRepairDamage = 300; if (robot == null || !Verse.Gen.IsHashIntervalTick(robot, 300)) { return; } IEnumerable <Hediff_Injury> hediff_injuries = (from x in robot.health.hediffSet.GetHediffs <Hediff_Injury>() where x.CanHealFromTending() || x.CanHealNaturally() select x); // Apply Treated, but not healing! if (robot.health.HasHediffsNeedingTend(false)) { float quality = (Rand.Value); int batchPosition = 0; foreach (Hediff_Injury injury in from x in robot.health.hediffSet.GetInjuriesTendable() orderby x.Severity descending select x) { injury.Tended(quality, batchPosition); batchPosition++; if (batchPosition >= 1) { break; } } } // Apply healing if (hediff_injuries != null && hediff_injuries.Count() > 0) { Hediff_Injury hediff_Injury2 = hediff_injuries.RandomElement(); float tendQuality = hediff_Injury2.TryGetComp <HediffComp_TendDuration>().tendQuality; float num2 = GenMath.LerpDouble(0f, 1f, 0.5f, 1.5f, Mathf.Clamp01(tendQuality)); ////hediff_Injury2.Heal(22f * num2 * robot.HealthScale * 0.01f); -> At quality 0.5 --> 0.066 healed. //Log.Error("Calculation: " + (GenMath.LerpDouble(0f, 1f, 0.5f, 1.5f, Mathf.Clamp01(tendQuality)).ToString())); //Log.Error("Healing: " + (22f * num2 * robot.HealthScale * 0.1f).ToString()); //Log.Error("PRE:" + hediff_Injury2.Severity.ToString()); //hediff_Injury2.Heal(1f); hediff_Injury2.Heal(22f * num2 * robot.HealthScale * 0.1f * 0.5f); //Log.Error("POST:" + hediff_Injury2.Severity.ToString()); // Throw Healing Mote MoteMaker.ThrowMetaIcon(this.Position, this.Map, ThingDefOf.Mote_HealingCross); } }
public override void CompPostTick(ref float severityAdjustment) { base.CompPostTick(ref severityAdjustment); Hediff_Injury hediff_Injury = Utilities.FindPermanentInjury(base.Pawn); if (hediff_Injury == null) { severityAdjustment = -1; } if (base.Pawn.IsHashIntervalTick(600)) hediff_Injury.Heal((float)MorePsycasts_Mod.settings.heal_scars_healing_speed*Utilities.getHealingAmount(base.Pawn)); }
// Self healing private void DoHealDamagedBodyPart(bool enhancedAI) { IEnumerable <Hediff> notTendedBodyParts = (from x in this.health.hediffSet.hediffs where (x is Hediff_Injury) && x.TendableNow(false) //!(x is Hediff_MissingPart) && x.CanHealFromTending() && !x.IsTended() select x); IEnumerable <Hediff_Injury> hediff_injuries = (from x in this.health.hediffSet.GetHediffs <Hediff_Injury>() where x.CanHealFromTending() || x.CanHealNaturally() select x); if (notTendedBodyParts.Count() == 0) // && hediff_injuries.Count() == 0) { // Nothing to heal/tend, check for missing body parts next DoHealMissingBodyPart(enhancedAI); return; } // Apply Treated, but not healing! if (this.health.HasHediffsNeedingTend(false)) { float quality = (enhancedAI ? 1.0f : Rand.Value); int batchPosition = 0; foreach (Hediff_Injury injury in from x in this.health.hediffSet.GetInjuriesTendable() orderby x.Severity descending select x) { injury.Tended(quality, 1f, batchPosition); batchPosition++; if (batchPosition >= (IsInBed(Map) ? 3 : 1)) { break; } } } // No additional healing while in bed (it heals by itself here) if (IsInBed(Map)) { return; } if (hediff_injuries != null && hediff_injuries.Count() > 0) { Hediff_Injury hediff_Injury2 = hediff_injuries.RandomElement <Hediff_Injury>(); float tendQuality = hediff_Injury2.TryGetComp <HediffComp_TendDuration>().tendQuality; float num2 = GenMath.LerpDouble(0f, 1f, 0.5f, 1.5f, Mathf.Clamp01(tendQuality)); hediff_Injury2.Heal(22f * num2 * this.HealthScale * 0.01f * (enhancedAI ? 2 : 1)); } }
private IEnumerable <Toil> MechToils() { Toil toil = Toils_General.Wait(6000); toil.socialMode = RandomSocialMode.Off; toil.initAction = delegate() { this.ticksLeftThisToil = 6000; Building firstBuilding = base.GetActor().Position.GetFirstBuilding(base.GetActor().Map); if (firstBuilding is Building_Bed) { //TODO: check if it works JobMaker.MakeJob(JobDefOf.LayDown, firstBuilding); //base.GetActor().jobs.curDriver.layingDown = 2; } }; toil.tickAction = delegate() { if (Rand.Chance(0.0004f)) { IEnumerable <Hediff_Injury> injuriesTendable = base.GetActor().health.hediffSet.GetInjuriesTendable(); if (injuriesTendable.Count <Hediff_Injury>() > 0) { Hediff_Injury hediff_Injury = injuriesTendable.RandomElement <Hediff_Injury>(); hediff_Injury.Heal((float)Rand.RangeInclusive(1, 3)); } } }; toil.AddEndCondition(delegate { JobCondition result; if (base.GetActor().health.hediffSet.GetInjuriesTendable().Count <Hediff_Injury>() == 0) { result = JobCondition.Succeeded; } else { result = JobCondition.Ongoing; } return(result); }); yield return(toil); yield break; }
public override void CompTick() { /* * if (parent.Faction == null) * { * parent.SetFaction(Find.FactionManager.FirstFactionOfDef(XenomorphDefOf.RRY_Xenomorph)); * } */ base.CompTick(); this.ticksSinceHeal++; bool flag = this.ticksSinceHeal > this.healIntervalTicks; if (flag) { bool flag2 = pawn.health.hediffSet.HasNaturallyHealingInjury(); if (flag2) { this.ticksSinceHeal = 0; float num = 10f; num = num * pawn.HealthScale * 0.01f; Need_Food food = pawn.needs.food; if (food.CurLevel > (num / 100)) { Hediff_Injury hediff_Injury = GenCollection.RandomElement <Hediff_Injury> (from x in pawn.health.hediffSet.GetHediffs <Hediff_Injury>() where HediffUtility.CanHealNaturally(x) select x); doClot(pawn); if (hediff_Injury != null) { hediff_Injury.Heal(num); food.CurLevel -= (num / 100); string text = string.Format("{0} healed {1} for {2} and food reduced to {3}", pawn.LabelCap, hediff_Injury.Label, num, food.CurLevel); bool selected = Find.Selector.SingleSelectedThing == pawn; if (selected && Prefs.DevMode) { // Log.Message(text); } } } } } }
public void TryHealOldWounds() { IEnumerable <Hediff> enumerable = from hd in this.pawn.health.hediffSet.hediffs where hd.IsPermanent() && hd.def.isBad && hd.GetType() == typeof(Hediff_Injury) select hd; bool flag = enumerable != null; if (flag && canHeal) { foreach (Hediff hediff in enumerable) { Hediff_Injury Injury = hediff as Hediff_Injury; bool flag2 = Injury != null; Rand.PushState(); float chance = Rand.Value; Rand.PopState(); if (flag2 && canHeal && chance < Props.healPermenantChance) { float num = Injury.Severity * 0.01f; if (num > Injury.Severity && !Props.allowScarRemoval) { Rand.PushState(); chance = Rand.Value; Rand.PopState(); if (flag2 && canHeal && chance < Props.scarRemovalChance) { num = Injury.Severity - 0.01f; } } if (Props.useFood) { pawn.needs.food.CurLevel -= num; } if (Props.useRest) { pawn.needs.rest.CurLevel -= num; } Injury.Heal(num); // Traverse.Create(hediff_Injury).Property(name: "BleedRate").SetValue(hediff_Injury.BleedRate*0.95); } } } }
public override void CompPostTick(ref float severityAdjustment) { base.CompPostTick(ref severityAdjustment); this.ticksSinceHeal++; if (this.ticksSinceHeal > this.Props.healIntervalTicks) { if (base.Pawn.health.hediffSet.HasNaturallyHealingInjury()) { this.ticksSinceHeal = 0; float num = 8f; Hediff_Injury hediff_Injury = (from x in base.Pawn.health.hediffSet.GetHediffs <Hediff_Injury>() where x.CanHealNaturally() select x).RandomElement <Hediff_Injury>(); hediff_Injury.Heal(num * base.Pawn.HealthScale * 0.01f); string msg = string.Format("{0} healed.", base.Pawn.LabelCap); //Messages.Message(msg, MessageSound.Silent); } } }
private static void TryHealRandomInjury(Pawn_HealthTracker __instance, Pawn pawn, float healAmount, Building_BaseMechanoidPlatform platform = null) { IEnumerable <Hediff_Injury> hediffs = __instance.hediffSet.GetHediffs <Hediff_Injury>().Where((Hediff_Injury i) => HediffUtility.CanHealNaturally(i)); if (hediffs.Count() == 0) { return; } Hediff_Injury hediff_Injury = hediffs.RandomElement(); hediff_Injury.Heal(healAmount); if (pawn.IsHashIntervalTick(50) && !pawn.IsHashIntervalTick(100) && pawn.Map != null && !pawn.Position.Fogged(pawn.Map)) { MoteMaker.ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_HealingCross); } if (platform != null) { platform.refuelableComp.ConsumeFuel((platform.GetStatValue(WTH_DefOf.WTH_PartConsumptionRate) * 10f) / GenDate.TicksPerDay);//TODO no magic number } }
public override void Apply(LocalTargetInfo target, LocalTargetInfo dest) { Props.sound = SoundDefOf.PsycastPsychicEffect;//SoundDefOf.PsycastPsychicPulse; base.Apply(target, dest); if (target.Pawn == null) { return; } for (int i = 0; i < 10*MorePsycasts_Mod.settings.flash_heal_heal_amount; i++) { Hediff_Injury hediff_Injury = FindInjury(target.Pawn); if (hediff_Injury != null) { hediff_Injury.Heal(0.1f); HediffWithComps hediffWithComps = hediff_Injury as HediffWithComps; if (hediffWithComps != null) { hediffWithComps.TryGetComp<HediffComp_GetsPermanent>().Props.becomePermanentChanceFactor *= (float)MorePsycasts_Mod.settings.flash_heal_scar_chance; } } } //SoundDefOf.PsycastPsychicEffect.PlayOneShot(new TargetInfo(target.Cell, parent.pawn.Map)); }
// Token: 0x06000007 RID: 7 RVA: 0x00002274 File Offset: 0x00000474 public override void CompPostTick(ref float severityAdjustment) { base.CompPostTick(ref severityAdjustment); this.ticksSinceHeal++; bool flag = this.ticksSinceHeal > this.Props.healIntervalTicks; if (flag) { bool flag2 = base.Pawn.health.hediffSet.HasNaturallyHealingInjury(); if (flag2) { this.ticksSinceHeal = 0; float num = 8f; Hediff_Injury hediff_Injury = GenCollection.RandomElement <Hediff_Injury>(from x in base.Pawn.health.hediffSet.GetHediffs <Hediff_Injury>() where HediffUtility.CanHealNaturally(x) select x); hediff_Injury.Heal(num * base.Pawn.HealthScale * 0.01f); string text = string.Format("{0} healed.", base.Pawn.LabelCap); } } }
public override void CompTick() { if (Facehugger.Faction == null && Find.FactionManager.FirstFactionOfDef(XenomorphDefOf.RRY_Xenomorph) != null) { Facehugger.SetFaction(Find.FactionManager.FirstFactionOfDef(XenomorphDefOf.RRY_Xenomorph)); } base.CompTick(); this.ticksSinceHeal++; if (Impregnations >= maxImpregnations) { this.ticksSinceImpregnation++; } bool flag = this.ticksSinceHeal > this.healIntervalTicks; if (flag) { bool flag2 = Facehugger.health.hediffSet.HasNaturallyHealingInjury(); if (flag2) { float num = 4f; Hediff_Injury hediff_Injury = GenCollection.RandomElement <Hediff_Injury>(from x in Facehugger.health.hediffSet.GetHediffs <Hediff_Injury>() where HediffUtility.CanHealNaturally(x) select x); hediff_Injury.Heal(num * Facehugger.HealthScale * 0.01f); string text = string.Format("{0} healed.", Facehugger.LabelCap); } if (Impregnations >= maxImpregnations) { bool flag3 = this.ticksSinceImpregnation > this.deathIntervalTicks; if (flag3) { this.ticksSinceImpregnation = 0; if (Rand.Chance(0.5f)) { Facehugger.Kill(null); } } } } }
public override void CompTick() { if (pawn.ageTracker.CurLifeStage != XenomorphDefOf.RRY_XenomorphFullyFormed) { if (pawn.CurJobDef == JobDefOf.Ingest && Hidden) { hidden = false; } else if (!Hidden) { hidden = true; } } if (pawn.Faction == null) { if (Find.FactionManager.FirstFactionOfDef(XenomorphDefOf.RRY_Xenomorph) != null) { pawn.SetFaction(Find.FactionManager.FirstFactionOfDef(XenomorphDefOf.RRY_Xenomorph)); } } base.CompTick(); this.ticksSinceHeal++; bool flag = this.ticksSinceHeal > this.healIntervalTicks; if (flag) { bool flag2 = ((Pawn)base.parent).health.hediffSet.HasNaturallyHealingInjury(); if (flag2) { this.ticksSinceHeal = 0; float num = 8f; Hediff_Injury hediff_Injury = GenCollection.RandomElement <Hediff_Injury>(from x in ((Pawn)base.parent).health.hediffSet.GetHediffs <Hediff_Injury>() where HediffUtility.CanHealNaturally(x) select x); doClot(pawn); hediff_Injury.Heal(num * ((Pawn)base.parent).HealthScale * 0.01f); string text = string.Format("{0} healed.", ((Pawn)base.parent).LabelCap); } } }
private void HealInjuryRandom(Pawn pawn, float amount) { BodyPartRecord part; if (!pawn.health.hediffSet.GetInjuredParts().TryRandomElement(out part)) { return; } Hediff_Injury hediff_Injury = null; foreach (Hediff_Injury hediff_Injury2 in from x in pawn.health.hediffSet.GetHediffs <Hediff_Injury>() where x.Part == part select x) { if (hediff_Injury == null || hediff_Injury2.Severity > hediff_Injury.Severity) { hediff_Injury = hediff_Injury2; } } if (hediff_Injury != null) { hediff_Injury.Heal(amount); } }
public static bool HealthTick(Pawn_HealthTracker __instance) { if (__instance.Dead) { return(false); } for (int index = __instance.hediffSet.hediffs.Count - 1; index >= 0; --index) { Hediff hediff = __instance.hediffSet.hediffs[index]; try { hediff.Tick(); hediff.PostTick(); } catch (Exception ex1) { Log.Error("Exception ticking hediff " + hediff.ToStringSafe <Hediff>() + " for pawn " + __instance.pawn.ToStringSafe <Pawn>() + ". Removing hediff... Exception: " + (object)ex1); try { __instance.RemoveHediff(hediff); } catch (Exception ex2) { Log.Error("Error while removing hediff: " + (object)ex2); } } if (__instance.Dead) { return(false); } } bool flag1 = false; lock (__instance.hediffSet) //added { List <Hediff> newHediffs = new List <Hediff>(__instance.hediffSet.hediffs); //added for (int index = newHediffs.Count - 1; index >= 0; --index) //changed { Hediff hediff = newHediffs[index]; if (hediff.ShouldRemove) { newHediffs.RemoveAt(index); //changed __instance.hediffSet.hediffs = newHediffs; //added hediff.PostRemoved(); flag1 = true; } } } if (flag1) { __instance.Notify_HediffChanged((Hediff)null); } if (__instance.Dead) { return(false); } __instance.immunity.ImmunityHandlerTick(); if (__instance.pawn.RaceProps.IsFlesh && __instance.pawn.IsHashIntervalTick(600) && (__instance.pawn.needs.food == null || !__instance.pawn.needs.food.Starving)) { bool flag2 = false; if (__instance.hediffSet.HasNaturallyHealingInjury()) { float num = 8f; if (__instance.pawn.GetPosture() != PawnPosture.Standing) { num += 4f; Building_Bed buildingBed = __instance.pawn.CurrentBed(); if (buildingBed != null) { num += buildingBed.def.building.bed_healPerDay; } } foreach (Hediff hediff in __instance.hediffSet.hediffs) { HediffStage curStage = hediff.CurStage; if (curStage != null && (double)curStage.naturalHealingFactor != -1.0) { num *= curStage.naturalHealingFactor; } } __instance.hediffSet.GetHediffs <Hediff_Injury>().Where <Hediff_Injury>((Func <Hediff_Injury, bool>)(x => x.CanHealNaturally())).RandomElement <Hediff_Injury>().Heal((float)((double)num * (double)__instance.pawn.HealthScale * 0.00999999977648258) * __instance.pawn.GetStatValue(StatDefOf.InjuryHealingFactor)); flag2 = true; } if (__instance.hediffSet.HasTendedAndHealingInjury() && (__instance.pawn.needs.food == null || !__instance.pawn.needs.food.Starving)) { Hediff_Injury hd = __instance.hediffSet.GetHediffs <Hediff_Injury>().Where <Hediff_Injury>((Func <Hediff_Injury, bool>)(x => x.CanHealFromTending())).RandomElement <Hediff_Injury>(); hd.Heal((float)(8.0 * (double)GenMath.LerpDouble(0.0f, 1f, 0.5f, 1.5f, Mathf.Clamp01(hd.TryGetComp <HediffComp_TendDuration>().tendQuality)) * (double)__instance.pawn.HealthScale * 0.00999999977648258) * __instance.pawn.GetStatValue(StatDefOf.InjuryHealingFactor)); flag2 = true; } if (flag2 && !__instance.HasHediffsNeedingTendByPlayer() && (!HealthAIUtility.ShouldSeekMedicalRest(__instance.pawn) && !__instance.hediffSet.HasTendedAndHealingInjury()) && PawnUtility.ShouldSendNotificationAbout(__instance.pawn)) { Messages.Message((string)"MessageFullyHealed".Translate((NamedArgument)__instance.pawn.LabelCap, (NamedArgument)(Thing)__instance.pawn), (LookTargets)(Thing)__instance.pawn, MessageTypeDefOf.PositiveEvent); } } if (__instance.pawn.RaceProps.IsFlesh && (double)__instance.hediffSet.BleedRateTotal >= 0.100000001490116) { float num = __instance.hediffSet.BleedRateTotal * __instance.pawn.BodySize; if ((double)Rand.Value < (__instance.pawn.GetPosture() != PawnPosture.Standing ? (double)(num * 0.0004f) : (double)(num * 0.004f))) { __instance.DropBloodFilth(); } } if (!__instance.pawn.IsHashIntervalTick(60)) { return(false); } List <HediffGiverSetDef> hediffGiverSets = __instance.pawn.RaceProps.hediffGiverSets; if (hediffGiverSets != null) { for (int index1 = 0; index1 < hediffGiverSets.Count; ++index1) { List <HediffGiver> hediffGivers = hediffGiverSets[index1].hediffGivers; for (int index2 = 0; index2 < hediffGivers.Count; ++index2) { hediffGivers[index2].OnIntervalPassed(__instance.pawn, (Hediff)null); if (__instance.pawn.Dead) { return(false); } } } } if (__instance.pawn.story == null) { return(false); } List <Trait> allTraits = __instance.pawn.story.traits.allTraits; for (int index = 0; index < allTraits.Count; ++index) { TraitDegreeData currentData = allTraits[index].CurrentData; if ((double)currentData.randomDiseaseMtbDays > 0.0 && Rand.MTBEventOccurs(currentData.randomDiseaseMtbDays, 60000f, 60f)) { BiomeDef biome = __instance.pawn.Tile == -1 ? DefDatabase <BiomeDef> .GetRandom() : Find.WorldGrid[__instance.pawn.Tile].biome; IncidentDef incidentDef = DefDatabase <IncidentDef> .AllDefs.Where <IncidentDef>((Func <IncidentDef, bool>)(d => d.category == IncidentCategoryDefOf.DiseaseHuman)).RandomElementByWeightWithFallback <IncidentDef>((Func <IncidentDef, float>)(d => biome.CommonalityOfDisease(d))); if (incidentDef != null) { string blockedInfo; List <Pawn> pawns = ((IncidentWorker_Disease)incidentDef.Worker).ApplyToPawns(Gen.YieldSingle <Pawn>(__instance.pawn), out blockedInfo); if (PawnUtility.ShouldSendNotificationAbout(__instance.pawn)) { if (pawns.Contains(__instance.pawn)) { Find.LetterStack.ReceiveLetter("LetterLabelTraitDisease".Translate((NamedArgument)incidentDef.diseaseIncident.label), "LetterTraitDisease".Translate((NamedArgument)__instance.pawn.LabelCap, (NamedArgument)incidentDef.diseaseIncident.label, __instance.pawn.Named("PAWN")).AdjustedFor(__instance.pawn), LetterDefOf.NegativeEvent, (LookTargets)(Thing)__instance.pawn); } else if (!blockedInfo.NullOrEmpty()) { Messages.Message(blockedInfo, (LookTargets)(Thing)__instance.pawn, MessageTypeDefOf.NeutralEvent); } } } } } return(false); }