Пример #1
0
        public string GetTextReadout()
        {
            StringBuilder stringBuilder = new StringBuilder();

            if (visibilityShift > 0)
            {
                stringBuilder.AppendLine("   " + "CR_VisibilityError".Translate() + "\t" + GenText.ToStringByStyle(visibilityShift, ToStringStyle.FloatTwo) + " c");

                if (lightingShift > 0)
                {
                    stringBuilder.AppendLine("      " + "Darkness".Translate() + "\t" + GenText.AsPercent(lightingShift));
                }
                if (weatherShift > 0)
                {
                    stringBuilder.AppendLine("      " + "Weather".Translate() + "\t" + GenText.AsPercent(weatherShift));
                }
            }
            if (leadShift > 0)
            {
                stringBuilder.AppendLine("   " + "CR_LeadError".Translate() + "\t" + GenText.ToStringByStyle(leadShift, ToStringStyle.FloatTwo) + " c");
            }
            if (distShift > 0)
            {
                stringBuilder.AppendLine("   " + "CR_RangeError".Translate() + "\t" + GenText.ToStringByStyle(distShift, ToStringStyle.FloatTwo) + " c");
            }
            if (swayDegrees > 0)
            {
                stringBuilder.AppendLine("   " + "CR_Sway".Translate() + "\t\t" + GenText.ToStringByStyle(swayDegrees, ToStringStyle.FloatTwo) + "°");
            }
            if (spreadDegrees > 0)
            {
                stringBuilder.AppendLine("   " + "CR_Spread".Translate() + "\t\t" + GenText.ToStringByStyle(spreadDegrees, ToStringStyle.FloatTwo) + "°");
            }
            // Don't display cover and target size if our weapon has a CEP
            if (circularMissRadius > 0)
            {
                stringBuilder.AppendLine("   " + "CR_MissRadius".Translate() + "\t" + GenText.ToStringByStyle(circularMissRadius, ToStringStyle.FloatTwo) + " c");
                if (indirectFireShift > 0)
                {
                    stringBuilder.AppendLine("   " + "CR_IndirectFire".Translate() + "\t" + GenText.ToStringByStyle(indirectFireShift, ToStringStyle.FloatTwo) + " c");
                }
            }
            else
            {
                if (cover != null)
                {
                    stringBuilder.AppendLine("   " + "CR_CoverHeight".Translate() + "\t" + GenText.ToStringByStyle(Utility.GetCollisionHeight(cover), ToStringStyle.FloatTwo) + " c");
                }
                if (target.Thing != null)
                {
                    stringBuilder.AppendLine("   " + "CR_TargetHeight".Translate() + "\t" + GenText.ToStringByStyle(Utility.GetCollisionHeight(target.Thing), ToStringStyle.FloatTwo) + " c");
                    stringBuilder.AppendLine("   " + "CR_TargetWidth".Translate() + "\t" + GenText.ToStringByStyle(Utility.GetCollisionWidth(target.Thing) * 2, ToStringStyle.FloatTwo) + " c");
                }
            }
            return(stringBuilder.ToString());
        }
        private void DrawPawnRow(Pawn pawn, float rowY, Rect fillRect)
        {
            Rect position = new Rect(0f, rowY, fillRect.width, 30f);

            if (position.Contains(Event.current.mousePosition))
            {
                GUI.DrawTexture(position, TexUI.HighlightTex);
            }
            Rect rect      = new Rect(0f, rowY, 175f, 30f);
            Rect innerRect = rect.GetInnerRect(3f);

            if (pawn.healthTracker.Health < pawn.healthTracker.MaxHealth - 1)
            {
                Rect screenRect = new Rect(rect);
                screenRect.xMin -= 4f;
                screenRect.yMin += 4f;
                screenRect.yMax -= 6f;
                Widgets.FillableBar(screenRect, (float)pawn.healthTracker.Health / (float)pawn.healthTracker.MaxHealth, PawnUIOverlay.HealthTex, false, BaseContent.ClearTex);
            }
            if (rect.Contains(Event.current.mousePosition))
            {
                GUI.DrawTexture(innerRect, TexUI.HighlightTex);
            }
            Text.Font      = GameFont.Small;
            Text.Alignment = TextAnchor.MiddleLeft;
            Rect rect2 = new Rect(rect);

            rect2.xMin += 15f;
            Widgets.Label(rect2, pawn.Label);
            if (Widgets.InvisibleButton(rect))
            {
                Find.LayerStack.FirstLayerOfType <Dialog_Overview>().Close();
                Find.CameraMap.JumpTo(pawn.Position);
                return;
            }
            TipSignal tooltip = pawn.GetTooltip();

            tooltip.text = "ClickToJumpTo".Translate() + "\n\n" + tooltip.text;
            TooltipHandler.TipRegion(rect, tooltip);

            SkillRecord skill = pawn.skills.GetSkill(SkillDefOf.Shooting);
            float       skillBarLeftMargin = 175f;

            Rect passionIconPosition = new Rect(skillBarLeftMargin, rowY + 2.5f, 24f, 24f);

            if (skill.passion > Passion.None)
            {
                Texture2D image = (skill.passion != Passion.Major) ? PassionMinorIcon : PassionMajorIcon;
                GUI.DrawTexture(passionIconPosition, image);
            }

            skillBarLeftMargin += 24f;
            Vector2 topLeft = new Vector2(skillBarLeftMargin, rowY + 2.5f);


            if (!skill.TotallyDisabled)
            {
                Widgets.FillableBar(new Rect(topLeft.x, topLeft.y, 240f, 24f), (float)skill.level / 20f, SkillBarFillTex, false, null);
            }

            string label;

            if (skill.TotallyDisabled)
            {
                GUI.color = DisabledSkillColor;
                label     = "-";
            }
            else
            {
                label = GenString.NumberString(skill.level);
            }
            Text.Alignment = TextAnchor.MiddleLeft;
            Widgets.Label(new Rect(topLeft.x + 4f, topLeft.y, 240f, 24f), label);

            if (pawn.Downed)
            {
                GUI.color = Color.red;
                Widgets.DrawLineHorizontal(new Vector2(175f, rowY + 15f), skillBarLeftMargin - 175f - 17f);
            }
            GUI.color = Color.white;


            // Draw equipment
            if (pawn.equipment != null)
            {
                Equipment weapon = pawn.equipment.AllEquipment.FirstOrDefault();
                if (weapon != null)
                {
                    // Draw weapon
                    Rect weaponRect = new Rect(topLeft.x + 240f + 4f, topLeft.y, 30f, 24f);
                    Widgets.ThingIcon(weaponRect, weapon);
                    Widgets.Label(new Rect(weaponRect.max.x + 4f, topLeft.y, 100f, 24f), new GUIContent(weapon.LabelCap));
                }
            }

            // Draw hit chance factor
            float f          = 1f;
            float statValue  = pawn.GetStatValue(StatDefOf.HitChanceFactor, true);
            float statValue2 = pawn.GetStatValue(StatDefOf.ShootingAccuracy, true);

            if (statValue < 0f)
            {
                f = statValue2 + statValue * statValue2;
            }
            else
            {
                f = statValue2 + statValue * (1f - statValue2);
            }

            Rect hitChanceRect = new Rect(topLeft.x + 240f + 4f + 30f + 100f, topLeft.y, 50f, 24f);

            Widgets.Label(hitChanceRect, GenText.AsPercent(f));

            // Draw sight efficiency
            Widgets.Label(new Rect(hitChanceRect.max.x + 4f, hitChanceRect.y, 50f, 24f), GenText.AsPercent(pawn.healthTracker.GetEfficiency(PawnActivityDefOf.Sight)));
        }