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()); }
void TransformValueForThing(StatRequest req, ref float val) { if (CompInfused.TryGetInfusedComp(req.Thing, out CompInfused inf)) { TransformValue(inf, parentStat, ref val); } }
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); } } }
string ExplanationPartForThing(StatRequest req) { if (CompInfused.TryGetInfusedComp(req.Thing, out CompInfused comp)) { return(WriteExplanation(req.Thing, comp)); } return(null); }
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); }
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; }
public override bool Matches(Thing t) => CanEverMatch(t.def) && WantsInfused == CompInfused.TryGetInfusedComp(t, out CompInfused comp);