Exemplo n.º 1
0
        string ExplanationPartForPawn(StatRequest req)
        {
            //Just in case
            var pawn = req.Thing as Pawn;

            if (pawn == null)
            {
                return(null);
            }

            var result = new StringBuilder();

            result.AppendLine(ResourceBank.Strings.DescBonus);

            //Pawn has a primary weapon
            if (CompInfused.TryGetInfusedComp(pawn.equipment.Primary, out CompInfused comp))
            {
                result.Append(WriteExplanation(pawn.equipment.Primary, comp));
            }

            //Pawn has apparels
            foreach (var apparel in pawn.apparel.WornApparel)
            {
                if (CompInfused.TryGetInfusedComp(pawn.equipment.Primary, out comp))
                {
                    result.Append(WriteExplanation(apparel, comp));
                }
            }

            return(result.ToString());
        }
Exemplo n.º 2
0
 void TransformValueForThing(StatRequest req, ref float val)
 {
     if (CompInfused.TryGetInfusedComp(req.Thing, out CompInfused inf))
     {
         TransformValue(inf, parentStat, ref val);
     }
 }
Exemplo n.º 3
0
        void TransformValueForPawn(StatRequest req, ref float val)
        {
            var pawn = req.Thing as Pawn;

            //Just in case
            if (pawn == null)
            {
                return;
            }

            //Pawn has a primary weapon
            if (pawn.equipment.Primary != null)
            {
                if (CompInfused.TryGetInfusedComp(pawn.equipment.Primary, out CompInfused inf))
                {
                    TransformValue(inf, parentStat, ref val);
                }
            }

            //Pawn has apparels
            foreach (var apparel in pawn.apparel.WornApparel)
            {
                if (CompInfused.TryGetInfusedComp(apparel, out CompInfused inf))
                {
                    TransformValue(inf, parentStat, ref val);
                }
            }
        }
Exemplo n.º 4
0
        string ExplanationPartForThing(StatRequest req)
        {
            if (CompInfused.TryGetInfusedComp(req.Thing, out CompInfused comp))
            {
                return(WriteExplanation(req.Thing, comp));
            }

            return(null);
        }
Exemplo n.º 5
0
        string ExplanationPartForPawn(StatRequest req)
        {
            //Just in case
            var pawn = req.Thing as Pawn;

            if (pawn == null)
            {
                return(null);
            }

            var result = new StringBuilder();

            //Pawn has a primary weapon
            if ((pawn.equipment != null) && (pawn.equipment.Primary != null))
            {
                if (CompInfused.TryGetInfusedComp(pawn.equipment.Primary, out CompInfused comp))
                {
                    result.Append(WriteExplanation(pawn.equipment.Primary, comp));
                }
            }

            //Pawn has apparels
            if (pawn.apparel != null)
            {
                foreach (var apparel in pawn.apparel.WornApparel)
                {
                    if (CompInfused.TryGetInfusedComp(apparel, out CompInfused comp))
                    {
                        result.Append(WriteExplanation(apparel, comp));
                    }
                }
            }

            if (result.Length > 0)
            {
                return(ResourceBank.Strings.DescBonus + "\n" + result);
            }

            return(null);
        }
Exemplo n.º 6
0
        static void Postfix(Thing thing)
        {
            if (!CompInfused.TryGetInfusedComp(thing, out CompInfused comp))
            {
                return;
            }

            Text.Font   = GameFont.Tiny;
            Text.Anchor = TextAnchor.UpperCenter;
            GUI.color   = comp.InfusedLabelColor;

            string text      = comp.InfusedLabelShort;
            float  x         = Text.CalcSize(text).x;
            var    screenPos = GenMapUI.LabelDrawPosFor(thing, -0.66f);
            var    rect      = new Rect(screenPos.x - x / 2f, screenPos.y - 3f, x, 999f);

            Widgets.Label(rect, text);

            GUI.color   = Color.white;
            Text.Anchor = TextAnchor.UpperLeft;
            Text.Font   = GameFont.Small;
        }
Exemplo n.º 7
0
 public override bool Matches(Thing t) => CanEverMatch(t.def) && WantsInfused == CompInfused.TryGetInfusedComp(t, out CompInfused comp);