public static void DrawPawnLabel(Pawn pawn, Vector2 pos, float alpha = 1f, float truncateToWidth = 9999f, Dictionary <string, string> truncatedLabelsCache = null, GameFont font = GameFont.Tiny, bool alwaysDrawBg = true, bool alignCenter = true) { float pawnLabelNameWidth = GenMapUI.GetPawnLabelNameWidth(pawn, truncateToWidth, truncatedLabelsCache, font); Rect bgRect = new Rect(pos.x - pawnLabelNameWidth / 2f - 4f, pos.y, pawnLabelNameWidth + 8f, 12f); if (!pawn.RaceProps.Humanlike) { bgRect.y -= 4f; } GenMapUI.DrawPawnLabel(pawn, bgRect, alpha, truncateToWidth, truncatedLabelsCache, font, alwaysDrawBg, alignCenter); }
public static void DrawPawnLabel(Pawn pawn, Rect bgRect, float alpha = 1f, float truncateToWidth = 9999f, Dictionary <string, string> truncatedLabelsCache = null, GameFont font = GameFont.Tiny, bool alwaysDrawBg = true, bool alignCenter = true) { GUI.color = new Color(1f, 1f, 1f, alpha); Text.Font = font; string pawnLabel = GenMapUI.GetPawnLabel(pawn, truncateToWidth, truncatedLabelsCache, font); float pawnLabelNameWidth = GenMapUI.GetPawnLabelNameWidth(pawn, truncateToWidth, truncatedLabelsCache, font); float summaryHealthPercent = pawn.health.summaryHealth.SummaryHealthPercent; if (alwaysDrawBg || summaryHealthPercent < 0.99900001287460327) { GUI.DrawTexture(bgRect, TexUI.GrayTextBG); } if (summaryHealthPercent < 0.99900001287460327) { Rect rect = bgRect.ContractedBy(1f); Widgets.FillableBar(rect, summaryHealthPercent, GenMapUI.OverlayHealthTex, BaseContent.ClearTex, false); } Color color = PawnNameColorUtility.PawnNameColorOf(pawn); color.a = alpha; GUI.color = color; Rect rect2 = default(Rect); if (alignCenter) { Text.Anchor = TextAnchor.UpperCenter; Vector2 center = bgRect.center; rect2 = new Rect((float)(center.x - pawnLabelNameWidth / 2.0), (float)(bgRect.y - 2.0), pawnLabelNameWidth, 100f); } else { Text.Anchor = TextAnchor.UpperLeft; double x = bgRect.x + 2.0; Vector2 center2 = bgRect.center; float y = center2.y; Vector2 vector = Text.CalcSize(pawnLabel); rect2 = new Rect((float)x, (float)(y - vector.y / 2.0), pawnLabelNameWidth, 100f); } Widgets.Label(rect2, pawnLabel); if (pawn.Drafted) { Vector2 center3 = bgRect.center; Widgets.DrawLineHorizontal((float)(center3.x - pawnLabelNameWidth / 2.0), (float)(bgRect.y + 11.0), pawnLabelNameWidth); } GUI.color = Color.white; Text.Anchor = TextAnchor.UpperLeft; }