public static void HealNonPermanentInjuriesAndRestoreLegs(Pawn p) { if (p.Dead) { return; } HealthUtility.tmpHediffs.Clear(); HealthUtility.tmpHediffs.AddRange(p.health.hediffSet.hediffs); for (int i = 0; i < HealthUtility.tmpHediffs.Count; i++) { Hediff_Injury hediff_Injury = HealthUtility.tmpHediffs[i] as Hediff_Injury; if (hediff_Injury != null && !hediff_Injury.IsPermanent()) { p.health.RemoveHediff(hediff_Injury); } else { Hediff_MissingPart hediff_MissingPart = HealthUtility.tmpHediffs[i] as Hediff_MissingPart; if (hediff_MissingPart != null && hediff_MissingPart.Part.def.tags.Contains(BodyPartTagDefOf.MovingLimbCore) && (hediff_MissingPart.Part.parent == null || p.health.hediffSet.GetNotMissingParts(BodyPartHeight.Undefined, BodyPartDepth.Undefined, null, null).Contains(hediff_MissingPart.Part.parent))) { p.health.RestorePart(hediff_MissingPart.Part, null, true); } } } HealthUtility.tmpHediffs.Clear(); }
public static void HealNonPermanentInjuriesAndRestoreLegs(Pawn p) { if (!p.Dead) { tmpHediffs.Clear(); tmpHediffs.AddRange(p.health.hediffSet.hediffs); for (int i = 0; i < tmpHediffs.Count; i++) { Hediff_Injury hediff_Injury = tmpHediffs[i] as Hediff_Injury; if (hediff_Injury != null && !hediff_Injury.IsPermanent()) { p.health.RemoveHediff(hediff_Injury); } else { Hediff_MissingPart hediff_MissingPart = tmpHediffs[i] as Hediff_MissingPart; if (hediff_MissingPart != null && hediff_MissingPart.Part.def.tags.Contains(BodyPartTagDefOf.MovingLimbCore) && (hediff_MissingPart.Part.parent == null || p.health.hediffSet.GetNotMissingParts().Contains(hediff_MissingPart.Part.parent))) { p.health.RestorePart(hediff_MissingPart.Part); } } } tmpHediffs.Clear(); } }
public static bool CanHealFromTending(this Hediff_Injury hd) { if (hd.IsTended()) { return(!hd.IsPermanent()); } return(false); }
public static string GetGeneralConditionLabel(Pawn pawn, bool shortVersion = false) { string result; if (pawn.health.Dead) { result = "Dead".Translate(); } else if (!pawn.health.capacities.CanBeAwake) { result = "Unconscious".Translate(); } else if (pawn.health.InPainShock) { result = ((!shortVersion || !"PainShockShort".CanTranslate()) ? "PainShock".Translate() : "PainShockShort".Translate()); } else if (pawn.Downed) { result = "Incapacitated".Translate(); } else { bool flag = false; for (int i = 0; i < pawn.health.hediffSet.hediffs.Count; i++) { Hediff_Injury hediff_Injury = pawn.health.hediffSet.hediffs[i] as Hediff_Injury; if (hediff_Injury != null) { if (!hediff_Injury.IsPermanent()) { flag = true; } } } if (flag) { result = "Injured".Translate(); } else if (pawn.health.hediffSet.PainTotal > 0.3f) { result = "InPain".Translate(); } else { result = "Healthy".Translate(); } } return(result); }
public override bool TryMergeWith(Hediff other) { Hediff_Injury hediff_Injury = other as Hediff_Injury; return(hediff_Injury != null && hediff_Injury.def == this.def && hediff_Injury.Part == base.Part && !hediff_Injury.IsTended() && !hediff_Injury.IsPermanent() && !this.IsTended() && !this.IsPermanent() && this.def.injuryProps.canMerge && base.TryMergeWith(other)); }
public static bool CanHealNaturally(this Hediff_Injury hd) { return(!hd.IsPermanent()); }
private void CalculatePermanentInjuryDamageThreshold(Pawn pawn, Hediff_Injury injury) { HediffCompProperties_GetsPermanent hediffCompProperties_GetsPermanent = injury.def.CompProps <HediffCompProperties_GetsPermanent>(); if (hediffCompProperties_GetsPermanent != null) { if (!injury.Part.def.IsSolid(injury.Part, pawn.health.hediffSet.hediffs) && !pawn.health.hediffSet.PartOrAnyAncestorHasDirectlyAddedParts(injury.Part) && !injury.IsPermanent() && injury.Part.def.permanentInjuryBaseChance >= 1E-05f) { bool isDelicate = injury.Part.def.IsDelicate; if ((Rand.Value <= injury.Part.def.permanentInjuryBaseChance * hediffCompProperties_GetsPermanent.becomePermanentChance && injury.Severity >= injury.Part.def.GetMaxHealth(pawn) * 0.25f && injury.Severity >= 7f) || isDelicate) { HediffComp_GetsPermanent hediffComp_GetsPermanent = injury.TryGetComp <HediffComp_GetsPermanent>(); float num = 1f; float num2 = injury.Severity / 2f; if (num <= num2) { hediffComp_GetsPermanent.permanentDamageThreshold = Rand.Range(num, num2); } if (isDelicate) { hediffComp_GetsPermanent.permanentDamageThreshold = injury.Severity; hediffComp_GetsPermanent.IsPermanent = true; } } } } }
public override bool TryMergeWith(Hediff other) { Hediff_Injury hediff_Injury = other as Hediff_Injury; if (hediff_Injury == null || hediff_Injury.def != def || hediff_Injury.Part != base.Part || hediff_Injury.IsTended() || hediff_Injury.IsPermanent() || this.IsTended() || this.IsPermanent() || !def.injuryProps.canMerge) { return(false); } return(base.TryMergeWith(other)); }