public static void ResurrectWithSideEffects(Pawn pawn) { Corpse corpse = pawn.Corpse; float num; bool flag; if (corpse != null) { CompRottable comp = corpse.GetComp <CompRottable>(); num = (float)(comp.RotProgress / 60000.0); flag = (comp.Stage == RotStage.Fresh); } else { num = 0f; flag = true; } ResurrectionUtility.Resurrect(pawn); BodyPartRecord brain = pawn.health.hediffSet.GetBrain(); float chance = Mathf.Max((float)(0.20000000298023224 * num), 0.08f); if (Rand.Chance(chance) && brain != null) { int a = Rand.RangeInclusive(1, 5); int b = Mathf.FloorToInt(pawn.health.hediffSet.GetPartHealth(brain)) - 1; a = Mathf.Min(a, b); if (a > 0 && !pawn.health.WouldDieAfterAddingHediff(HediffDefOf.Burn, brain, (float)a)) { DamageDef burn = DamageDefOf.Burn; int amount = a; BodyPartRecord hitPart = brain; pawn.TakeDamage(new DamageInfo(burn, amount, -1f, null, hitPart, null, DamageInfo.SourceCategory.ThingOrUnknown)); } } float chance2 = Mathf.Max((float)(0.11999999731779099 * num), 0.04f); if (Rand.Chance(chance2)) { IEnumerable <BodyPartRecord> enumerable = from x in pawn.health.hediffSet.GetNotMissingParts(BodyPartHeight.Undefined, BodyPartDepth.Undefined) where x.def == BodyPartDefOf.LeftEye || x.def == BodyPartDefOf.RightEye select x; foreach (BodyPartRecord item in enumerable) { Hediff hediff = HediffMaker.MakeHediff(HediffDefOf.Blindness, pawn, item); pawn.health.AddHediff(hediff, null, null); } } Hediff hediff2 = HediffMaker.MakeHediff(HediffDefOf.ResurrectionSickness, pawn, null); if (!pawn.health.WouldDieAfterAddingHediff(hediff2)) { pawn.health.AddHediff(hediff2, null, null); } if ((!flag || Rand.Chance(0.3f)) && brain != null) { Hediff hediff3 = HediffMaker.MakeHediff(HediffDefOf.ResurrectionPsychosis, pawn, brain); if (!pawn.health.WouldDieAfterAddingHediff(hediff3)) { pawn.health.AddHediff(hediff3, null, null); } } if (pawn.Dead) { Log.Error("The pawn has died while being resurrected."); ResurrectionUtility.Resurrect(pawn); } }
public static void ResurrectWithSideEffects(Pawn pawn) { Corpse corpse = pawn.Corpse; float x2; if (corpse != null) { CompRottable comp = corpse.GetComp <CompRottable>(); x2 = comp.RotProgress / 60000f; } else { x2 = 0f; } ResurrectionUtility.Resurrect(pawn); BodyPartRecord brain = pawn.health.hediffSet.GetBrain(); Hediff hediff = HediffMaker.MakeHediff(HediffDefOf.ResurrectionSickness, pawn, null); if (!pawn.health.WouldDieAfterAddingHediff(hediff)) { pawn.health.AddHediff(hediff, null, null, null); } float chance = ResurrectionUtility.DementiaChancePerRotDaysCurve.Evaluate(x2); if (Rand.Chance(chance) && brain != null) { Hediff hediff2 = HediffMaker.MakeHediff(HediffDefOf.Dementia, pawn, brain); if (!pawn.health.WouldDieAfterAddingHediff(hediff2)) { pawn.health.AddHediff(hediff2, null, null, null); } } float chance2 = ResurrectionUtility.BlindnessChancePerRotDaysCurve.Evaluate(x2); if (Rand.Chance(chance2)) { IEnumerable <BodyPartRecord> enumerable = from x in pawn.health.hediffSet.GetNotMissingParts(BodyPartHeight.Undefined, BodyPartDepth.Undefined, null, null) where x.def == BodyPartDefOf.Eye select x; foreach (BodyPartRecord current in enumerable) { Hediff hediff3 = HediffMaker.MakeHediff(HediffDefOf.Blindness, pawn, current); pawn.health.AddHediff(hediff3, null, null, null); } } if (brain != null) { float chance3 = ResurrectionUtility.ResurrectionPsychosisChancePerRotDaysCurve.Evaluate(x2); if (Rand.Chance(chance3)) { Hediff hediff4 = HediffMaker.MakeHediff(HediffDefOf.ResurrectionPsychosis, pawn, brain); if (!pawn.health.WouldDieAfterAddingHediff(hediff4)) { pawn.health.AddHediff(hediff4, null, null, null); } } } if (pawn.Dead) { Log.Error("The pawn has died while being resurrected.", false); ResurrectionUtility.Resurrect(pawn); } }