コード例 #1
0
        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));
        }