public static void DrawStockUpButton(Pawn pawn, ref float y, float width) { if (!Settings.Get().stockUp) { return; } GUI.color = ThingLabelColor; Rect rect = new Rect(width / 4, y, width / 2, 28f); if (Widgets.ButtonText(rect, "TD.StockUpSettings".Translate())) { Find.WindowStack.Add(new Dialog_StockUp(pawn)); } Rect iconRect = rect.RightPartPixels(28f); if (pawn.StockingUpOnAnything()) { iconRect.x += 28f; TooltipHandler.TipRegion(iconRect, "TD.ClearStockUp".Translate()); if (Widgets.ButtonImage(iconRect, TexButton.Abandon)) { pawn.StockUpClearSettings(); } } iconRect.x = rect.x - 28f; if (StockUpUtility.CopiedPawn() == pawn) { TooltipHandler.TipRegion(iconRect, String.Format("TD.CancelCopyStockUp".Translate(), pawn.Name.ToStringShort)); if (Widgets.ButtonImage(iconRect, TexButton.Ignore)) { StockUpUtility.StockUpCopySettings(null); } } else { if (StockUpUtility.CopiedPawn() != null) { TooltipHandler.TipRegion(iconRect, String.Format("TD.CopyStockUpFrom".Translate(), StockUpUtility.CopiedPawn().Name.ToStringShort)); if (Widgets.ButtonImage(iconRect, TexButton.Paste)) { pawn.StockUpPasteSettings(); } } iconRect.x -= 28f; if (pawn.StockingUpOnAnything() && Widgets.ButtonImage(iconRect, TexButton.Copy)) { pawn.StockUpCopySettings(); } } y += 28f; }
public static void Prefix(Pawn_JobTracker __instance, Pawn ___pawn) { if (__instance.curJob?.def == JobDefOf.TendPatient) { Pawn pawn = ___pawn; if (!pawn.Destroyed && pawn.carryTracker != null && pawn.carryTracker.CarriedThing != null) { if (StockUpUtility.StockingUpOn(pawn, pawn.carryTracker.CarriedThing)) { pawn.inventory.innerContainer.TryAddOrTransfer(pawn.carryTracker.CarriedThing); } } } }
public static void Prefix(Pawn_JobTracker __instance) { if (__instance.curJob?.def == JobDefOf.TendPatient) { FieldInfo pawnField = AccessTools.Field(typeof(Pawn_JobTracker), "pawn"); Pawn pawn = (Pawn)pawnField.GetValue(__instance); if (!pawn.Destroyed && pawn.carryTracker != null && pawn.carryTracker.CarriedThing != null) { if (StockUpUtility.StockingUpOn(pawn, pawn.carryTracker.CarriedThing)) { pawn.inventory.innerContainer.TryAddOrTransfer(pawn.carryTracker.CarriedThing); } } } }
public static string AddStockTip(string text, Pawn pawn, ThingDef thingDef) { if (!pawn.IsFreeColonist || pawn.Dead) { return(text); } string addedText = ""; if (pawn.StockUpWants(thingDef) > 0 && !StockUpUtility.EnoughAvailable(thingDef, pawn.Map)) { addedText = "TD.NotEnoughStockUp".Translate(); } if (text != "" && addedText != "") { return(addedText + "\n\n" + text); } return(addedText + text); }
public static string AddStockText(string text, Pawn pawn, ThingDef thingDef) { if (!pawn.IsFreeColonist || pawn.Dead) { return(text); } if (!pawn.StockingUpOn(thingDef)) { return(text); } string addedText = String.Format(" / {0}", pawn.StockUpCount(thingDef)); if (pawn.StockUpWants(thingDef) > 0 && !StockUpUtility.EnoughAvailable(thingDef, pawn.Map)) { addedText += " (" + "TD.Paused".Translate() + ")"; } return(text + addedText); }