private static Color GetHealthColorForBodypart(Pawn pawn, BodyPartRecord part) { if (pawn != null) { return(HealthUtility.GetPartConditionLabel(pawn, part).Second); } else { return(Color.white); } }
// Token: 0x0600000E RID: 14 RVA: 0x000029BC File Offset: 0x00000BBC public static bool GetBPR(Pawn p, out BodyPartRecord part, out BodyPartDef partdef) { part = null; partdef = null; var partsChance = Rand.Range(1, 100); if (partsChance <= 50) { partdef = partsChance <= 20 ? BodyPartDefOf.Arm : BodyPartDefOf.Hand; } else if (partsChance >= 80) { partdef = BodyPartDefOf.Leg; } else { partdef = DefDatabase <BodyPartDef> .GetNamed("Foot", false); } var body = p.RaceProps.body; var parts = body?.GetPartsWithDef(partdef) !.ToList(); part = parts.RandomElement(); if (part == null || partdef == null) { return(false); } var condition = HealthUtility.GetPartConditionLabel(p, part); if (condition.First == "SeriouslyImpaired".Translate() || condition.First == "ShatteredBodyPart".Translate() || condition.First == "DestroyedBodyPart".Translate() || condition.First == "MissingBodyPart".Translate()) { return(false); } var health = p.health; return(health?.hediffSet == null || !p.health.hediffSet.HasDirectlyAddedPartFor(part)); }
private static void DrawHediffRow(Rect rect, Pawn pawn, IEnumerable <Hediff> diffs, ref float curY) { float num = rect.width * 0.375f; float width = rect.width - num - lastMaxIconsTotalWidth; BodyPartRecord part = diffs.First().Part; float a = ((part != null) ? Text.CalcHeight(part.LabelCap, num) : Text.CalcHeight("WholeBody".Translate(), num)); float num2 = 0f; float num3 = curY; float num4 = 0f; foreach (IGrouping <int, Hediff> item in from x in diffs group x by x.UIGroupKey) { int num5 = item.Count(); string text = item.First().LabelCap; if (num5 != 1) { text = text + " x" + num5; } num4 += Text.CalcHeight(text, width); } num2 = num4; Rect rect2 = new Rect(0f, curY, rect.width, Mathf.Max(a, num2)); DoRightRowHighlight(rect2); if (part != null) { GUI.color = HealthUtility.GetPartConditionLabel(pawn, part).Second; Widgets.Label(new Rect(0f, curY, num, 100f), part.LabelCap); } else { GUI.color = HealthUtility.RedColor; Widgets.Label(new Rect(0f, curY, num, 100f), "WholeBody".Translate()); } GUI.color = Color.white; foreach (IGrouping <int, Hediff> item2 in from x in diffs group x by x.UIGroupKey) { int num6 = 0; Hediff hediff = null; Texture2D bleedingIcon = null; TextureAndColor stateIcon = null; float totalBleedRate = 0f; foreach (Hediff item3 in item2) { if (num6 == 0) { hediff = item3; } stateIcon = item3.StateIcon; if (item3.Bleeding) { bleedingIcon = BleedingIcon; } totalBleedRate += item3.BleedRate; num6++; } string text2 = hediff.LabelCap; if (num6 != 1) { text2 = text2 + " x" + num6.ToStringCached(); } GUI.color = hediff.LabelColor; float num7 = Text.CalcHeight(text2, width); Rect rect3 = new Rect(num, curY, width, num7); Widgets.Label(rect3, text2); GUI.color = Color.white; Rect iconsRect = new Rect(rect3.x + 10f, rect3.y, rect.width - num - 10f, rect3.height); List <GenUI.AnonymousStackElement> list = new List <GenUI.AnonymousStackElement>(); foreach (HediffDef item4 in item2.Select((Hediff h) => h.def).Distinct()) { HediffDef localHediffDef = item4; list.Add(new GenUI.AnonymousStackElement { drawer = delegate(Rect r) { float num10 = iconsRect.width - (r.x - iconsRect.x) - 20f; r = new Rect(iconsRect.x + num10, r.y, 20f, 20f); Widgets.InfoCardButton(r.x, r.y, localHediffDef); }, width = 20f }); } if ((bool)bleedingIcon) { list.Add(new GenUI.AnonymousStackElement { drawer = delegate(Rect r) { float num9 = iconsRect.width - (r.x - iconsRect.x) - 20f; r = new Rect(iconsRect.x + num9, r.y, 20f, 20f); GUI.DrawTexture(r.ContractedBy(GenMath.LerpDouble(0f, 0.6f, 5f, 0f, Mathf.Min(totalBleedRate, 1f))), bleedingIcon); }, width = 20f }); } if (stateIcon.HasValue) { list.Add(new GenUI.AnonymousStackElement { drawer = delegate(Rect r) { float num8 = iconsRect.width - (r.x - iconsRect.x) - 20f; r = new Rect(iconsRect.x + num8, r.y, 20f, 20f); GUI.color = stateIcon.Color; GUI.DrawTexture(r, stateIcon.Texture); GUI.color = Color.white; }, width = 20f }); } GenUI.DrawElementStack(iconsRect, num7, list, delegate(Rect r, GenUI.AnonymousStackElement obj) { obj.drawer(r); }, (GenUI.AnonymousStackElement obj) => obj.width); lastMaxIconsTotalWidth = Mathf.Max(lastMaxIconsTotalWidth, list.Sum((GenUI.AnonymousStackElement x) => x.width + 5f) - 5f); curY += num7; } GUI.color = Color.white; curY = num3 + Mathf.Max(a, num2); if (Widgets.ButtonInvisible(rect2, CanEntryBeClicked(diffs, pawn))) { EntryClicked(diffs, pawn); } if (Mouse.IsOver(rect2)) { TooltipHandler.TipRegion(rect2, new TipSignal(() => GetTooltip(diffs, pawn, part), (int)curY + 7857)); } }
private static void DrawHediffRow(Rect rect, Pawn pawn, IEnumerable <Hediff> diffs, ref float curY) { float num = (float)(rect.width * 0.375); float width = (float)(rect.width - num - 20.0); BodyPartRecord part = diffs.First().Part; float a = (part != null) ? Text.CalcHeight(part.def.LabelCap, num) : Text.CalcHeight("WholeBody".Translate(), num); float num2 = 0f; float num3 = curY; float num4 = 0f; foreach (IGrouping <int, Hediff> item in from x in diffs group x by x.UIGroupKey) { int num5 = item.Count(); string text = item.First().LabelCap; if (num5 != 1) { text = text + " x" + num5.ToString(); } num4 += Text.CalcHeight(text, width); } num2 = num4; Rect rect2 = new Rect(0f, curY, rect.width, Mathf.Max(a, num2)); HealthCardUtility.DoRightRowHighlight(rect2); if (part != null) { GUI.color = HealthUtility.GetPartConditionLabel(pawn, part).Second; Widgets.Label(new Rect(0f, curY, num, 100f), part.def.LabelCap); } else { GUI.color = HealthUtility.DarkRedColor; Widgets.Label(new Rect(0f, curY, num, 100f), "WholeBody".Translate()); } GUI.color = Color.white; foreach (IGrouping <int, Hediff> item2 in from x in diffs group x by x.UIGroupKey) { int num6 = 0; Hediff hediff = null; Texture2D texture2D = null; TextureAndColor textureAndColor = null; float num7 = 0f; foreach (Hediff item3 in item2) { if (num6 == 0) { hediff = item3; } textureAndColor = item3.StateIcon; if (item3.Bleeding) { texture2D = HealthCardUtility.BleedingIcon; } num7 += item3.BleedRate; num6++; } string text2 = hediff.LabelCap; if (num6 != 1) { text2 = text2 + " x" + num6.ToStringCached(); } GUI.color = hediff.LabelColor; float num8 = Text.CalcHeight(text2, width); Rect rect3 = new Rect(num, curY, width, num8); Widgets.Label(rect3, text2); GUI.color = Color.white; Rect rect4 = new Rect((float)(rect2.xMax - 20.0), curY, 20f, 20f); if ((bool)texture2D) { Rect position = rect4.ContractedBy(GenMath.LerpDouble(0f, 0.6f, 5f, 0f, Mathf.Min(num7, 1f))); GUI.DrawTexture(position, texture2D); rect4.x -= rect4.width; } if (textureAndColor.HasValue) { GUI.color = textureAndColor.Color; GUI.DrawTexture(rect4, textureAndColor.Texture); GUI.color = Color.white; rect4.x -= rect4.width; } curY += num8; } GUI.color = Color.white; curY = num3 + Mathf.Max(a, num2); TooltipHandler.TipRegion(rect2, new TipSignal(() => HealthCardUtility.GetTooltip(diffs, pawn, part), (int)curY + 7857)); }
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)); }