private Hediff_Injury FindOldInjury(Pawn pawn) { Hediff_Injury hediff_Injury = null; List <Hediff> hediffs = pawn.health.hediffSet.hediffs; for (int i = 0; i < hediffs.Count; i++) { Hediff_Injury hediff_Injury2 = hediffs[i] as Hediff_Injury; if (hediff_Injury2 != null && hediff_Injury2.Visible && hediff_Injury2.IsOld() && (hediff_Injury == null || hediff_Injury2.Severity > hediff_Injury.Severity)) { hediff_Injury = hediff_Injury2; } } return(hediff_Injury); }
private static void HealIfPossible(Pawn p) { PawnBanishUtility.tmpHediffs.Clear(); PawnBanishUtility.tmpHediffs.AddRange(p.health.hediffSet.hediffs); for (int i = 0; i < PawnBanishUtility.tmpHediffs.Count; i++) { Hediff_Injury hediff_Injury = PawnBanishUtility.tmpHediffs[i] as Hediff_Injury; if (hediff_Injury != null && !hediff_Injury.IsOld()) { p.health.RemoveHediff(hediff_Injury); } else { ImmunityRecord immunityRecord = p.health.immunity.GetImmunityRecord(PawnBanishUtility.tmpHediffs[i].def); if (immunityRecord != null) { immunityRecord.immunity = 1f; } } } }
public void RenderOverBody(Vector3 drawLoc, Mesh bodyMesh, Quaternion quat, bool forPortrait) { int num = 0; List <Hediff> hediffs = this.pawn.health.hediffSet.hediffs; for (int i = 0; i < hediffs.Count; i++) { if (hediffs[i].def.displayWound) { Hediff_Injury hediff_Injury = hediffs[i] as Hediff_Injury; if (hediff_Injury == null || !hediff_Injury.IsOld()) { num++; } } } int num2 = Mathf.CeilToInt((float)((float)num / 2.0)); if (num2 > this.MaxDisplayWounds) { num2 = this.MaxDisplayWounds; } while (this.wounds.Count < num2) { this.wounds.Add(new Wound(this.pawn)); PortraitsCache.SetDirty(this.pawn); } while (this.wounds.Count > num2) { this.wounds.Remove(this.wounds.RandomElement()); PortraitsCache.SetDirty(this.pawn); } for (int j = 0; j < this.wounds.Count; j++) { this.wounds[j].DrawWound(drawLoc, quat, this.pawn.Rotation, forPortrait); } }
private void CalculateOldInjuryDamageThreshold(Pawn pawn, Hediff_Injury injury) { HediffCompProperties hediffCompProperties = injury.def.CompPropsFor(typeof(HediffComp_GetsOld)); if (hediffCompProperties == null) { return; } if (injury.Part.def.IsSolid(injury.Part, pawn.health.hediffSet.hediffs) || pawn.health.hediffSet.PartOrAnyAncestorHasDirectlyAddedParts(injury.Part) || injury.IsOld() || injury.Part.def.oldInjuryBaseChance < 1E-05f) { return; } bool isDelicate = injury.Part.def.IsDelicate; if ((Rand.Value <= injury.Part.def.oldInjuryBaseChance * hediffCompProperties.becomeOldChance && injury.Severity >= injury.Part.def.GetMaxHealth(pawn) * 0.25f && injury.Severity >= 7f) || isDelicate) { HediffComp_GetsOld hediffComp_GetsOld = injury.TryGetComp <HediffComp_GetsOld>(); float num = 1f; float num2 = injury.Severity / 2f; if (num <= num2) { hediffComp_GetsOld.oldDamageThreshold = Rand.Range(num, num2); } if (isDelicate) { hediffComp_GetsOld.oldDamageThreshold = injury.Severity; hediffComp_GetsOld.IsOld = true; } } }
public static bool CanHealNaturally(this Hediff_Injury hd) { return(!hd.IsOld()); }
public static bool CanHealFromTending(this Hediff_Injury hd) { return(hd.IsTended() && !hd.IsOld()); }
private void CalculateOldInjuryDamageThreshold(Pawn pawn, Hediff_Injury injury) { HediffCompProperties hediffCompProperties = injury.def.CompPropsFor(typeof(HediffComp_GetsOld)); if (hediffCompProperties == null) { return; } if (injury.Part.def.IsSolid(injury.Part, pawn.health.hediffSet.hediffs) || pawn.health.hediffSet.PartOrAnyAncestorHasDirectlyAddedParts(injury.Part) || injury.IsOld() || injury.Part.def.oldInjuryBaseChance < 1E-05f) { return; } bool flag = injury.Part.def.oldInjuryBaseChance >= 0.8f; if ((Rand.Value <= injury.Part.def.oldInjuryBaseChance * hediffCompProperties.becomeOldChance && injury.Severity >= injury.Part.def.GetMaxHealth(pawn) * 0.25f && injury.Severity >= 7f) || flag) { HediffComp_GetsOld hediffComp_GetsOld = injury.TryGetComp<HediffComp_GetsOld>(); float num = 1f; float num2 = injury.Severity / 2f; if (num <= num2) { hediffComp_GetsOld.oldDamageThreshold = Rand.Range(num, num2); } if (flag) { hediffComp_GetsOld.oldDamageThreshold = injury.Severity; hediffComp_GetsOld.isOld = true; } } }
private void CalculateOldInjuryDamageThreshold(Pawn pawn, Hediff_Injury injury) { HediffComp_GetsOld comp = injury.TryGetComp <HediffComp_GetsOld>(); if (comp == null) { return; } // No permanent injuries on solid parts, prosthetics or injuries that are already old if (injury.Part.def.IsSolid(injury.Part, pawn.health.hediffSet.hediffs) || pawn.health.hediffSet.PartOrAnyAncestorHasDirectlyAddedParts(injury.Part) || injury.IsOld()) { return; } // Delicate parts get old instantly if (injury.Part.def.IsDelicate) { comp.oldDamageThreshold = injury.Severity; comp.IsOld = true; } // Check if injury is at least 10% of part health and make a random roll else if (injury.Severity >= injury.Part.def.GetMaxHealth(pawn) * 0.1f && injury.Severity > 1) { float getOldChance = injury.Part.def.oldInjuryBaseChance * comp.Props.becomeOldChance * Mathf.Pow((injury.Severity / injury.Part.def.GetMaxHealth(pawn)), 2); if (Rand.Value < getOldChance) { comp.oldDamageThreshold = Rand.Range(1, injury.Severity); } } }
public void DrawHediffRow(Rect rect, Pawn pawn, IEnumerable <Hediff> diffs, ref float curY) { float num = 6f; float num2 = rect.width * 0.4f; float width = rect.width - num2 - 20f; num2 -= num; float a; if (diffs.First <Hediff>().Part == null) { a = Text.CalcHeight("WholeBody".Translate(), num2); } else { a = Text.CalcHeight(diffs.First <Hediff>().Part.def.LabelCap, num2); } float b = 0f; float num3 = curY; float num4 = 0f; foreach (IGrouping <int, Hediff> current in from x in diffs group x by x.UIGroupKey) { int num5 = current.Count <Hediff>(); string text = current.First <Hediff>().LabelCap; if (num5 != 1) { text = text + " x" + num5.ToString(); } num4 += Text.CalcHeight(text, width); } b = num4; Rect rect2 = new Rect(0f, curY, rect.width, Mathf.Max(a, b)); HealthCardUtility.DoRightRowHighlight(rect2); StringBuilder stringBuilder = new StringBuilder(); if (diffs.First <Hediff>().Part != null) { stringBuilder.Append(diffs.First <Hediff>().Part.def.LabelCap + ": "); GUI.color = HealthUtility.GetPartConditionLabel(pawn, diffs.First <Hediff>().Part).Second; Widgets.Label(new Rect(num, curY + 1f, num2, 100f), new GUIContent(diffs.First <Hediff>().Part.def.LabelCap)); stringBuilder.Append(" " + pawn.health.hediffSet.GetPartHealth(diffs.First <Hediff>().Part).ToString() + " / " + diffs.First <Hediff>().Part.def.GetMaxHealth(pawn).ToString()); } else { stringBuilder.Append("WholeBody".Translate()); GUI.color = HealthUtility.DarkRedColor; Widgets.Label(new Rect(num, curY + 1f, num2, 100f), new GUIContent("WholeBody".Translate())); } GUI.color = Color.white; stringBuilder.AppendLine(); stringBuilder.AppendLine("------------------"); foreach (IGrouping <int, Hediff> current2 in from x in diffs group x by x.UIGroupKey) { Hediff hediff = current2.First <Hediff>(); int num6 = 0; bool flag = false; Texture2D texture2D = null; foreach (Hediff current3 in current2) { num6++; Hediff_Injury hediff_Injury = current3 as Hediff_Injury; if (hediff_Injury != null && hediff_Injury.IsTended() && !hediff_Injury.IsOld()) { if (hediff_Injury.IsTendedWell()) { texture2D = HealthCardUtility.TreatedWellIcon; } else { texture2D = HealthCardUtility.TreatedPoorIcon; } } float bleedRate = current3.BleedRate; if ((double)bleedRate > 1E-05) { flag = true; } bool flag2 = HealthCardUtility.showHediffsDebugInfo && !current3.DebugString.NullOrEmpty(); string damageLabel = current3.DamageLabel; if (!current3.Label.NullOrEmpty() || !damageLabel.NullOrEmpty() || !current3.CapMods.NullOrEmpty <PawnCapacityModifier>() || flag2) { stringBuilder.Append(current3.LabelCap); if (!damageLabel.NullOrEmpty()) { stringBuilder.Append(": " + damageLabel); } stringBuilder.AppendLine(); stringBuilder.AppendLine(current3.TipString.TrimEndNewlines().Indented()); if (flag2) { stringBuilder.AppendLine(current3.DebugString.TrimEndNewlines().Indented()); } } } string text2 = hediff.LabelCap; if (num6 != 1) { text2 = text2 + " x" + num6.ToString(); } GUI.color = hediff.LabelColor; float num7 = Text.CalcHeight(text2, width); Rect rect3 = new Rect(num + num2, curY + 1f, width, num7); Widgets.Label(rect3, text2); GUI.color = Color.white; Rect position = new Rect(rect2.xMax - 20f, curY, 20f, 20f); if (flag) { GUI.DrawTexture(position, HealthCardUtility.BleedingIcon); } if (texture2D != null) { GUI.DrawTexture(position, texture2D); } curY += num7; } GUI.color = Color.white; curY = num3 + Mathf.Max(a, b); TooltipHandler.TipRegion(rect2, new TipSignal(stringBuilder.ToString().TrimEnd(new char[0]), (int)curY + 7857)); }