public static void JobOnThingRefill(Pawn pawn, Thing thing, ref Job __result, WorkGiver_DoBill __instance, bool forced = false)
 {
     if (__result is null)
     {
         IBillGiver billGiver = thing as IBillGiver;
         if (!(billGiver is null) && __instance.ThingIsUsableBillGiver(thing) && billGiver.BillStack.AnyShouldDoNow && billGiver.UsableForBillsAfterFueling())
         {
             LocalTargetInfo target = thing;
             if (pawn.CanReserve(target, 1, -1, null, forced) && !thing.IsBurning() && !thing.IsForbidden(pawn))
             {
                 CompRefillable compRefillable = thing.TryGetComp <CompRefillable>();
                 if (compRefillable is null || compRefillable.IsFull())
                 {
                     billGiver.BillStack.RemoveIncompletableBills();
                     __result = (Job)AccessTools.Method(type: typeof(WorkGiver_DoBill), name: "StartOrResumeBillJob").Invoke(__instance, new object[] { pawn, billGiver });
                     return;
                 }
                 if (!RefillWorkGiverUtility.CanRefill(pawn, thing, forced))
                 {
                     __result = null;
                     return;
                 }
                 __result = RefillWorkGiverUtility.RefillJob(pawn, thing, forced);
             }
         }
         return;
     }
 }
 public override IEnumerable <FloatMenuOption> CompFloatMenuOptions(Pawn pawn)
 {
     if (items.Any(x => x < this.Props.itemCapacity))
     {
         if (!pawn.CanReach(this.parent, PathEndMode.InteractionCell, Danger.Deadly, false, TraverseMode.ByPawn))
         {
             FloatMenuOption failer = new FloatMenuOption("CannotUseNoPath".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null);
             yield return(failer);
         }
         else if (this.IsFull())
         {
             FloatMenuOption failer = new FloatMenuOption("Does not need to be refilled", null, MenuOptionPriority.Default, null, null, 0f, null, null);
             yield return(failer);
         }
         else
         {
             string jobStr    = "Filling Machine";
             Action jobAction = delegate()
             {
                 Job job = RefillWorkGiverUtility.RefillJob(pawn, this.parent, true);
                 pawn.jobs.TryTakeOrderedJob(job, JobTag.Misc);
             };
             yield return(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(jobStr, jobAction, MenuOptionPriority.Default, null, null, 0f, null, null), pawn, this.parent, "ReservedBy"));
         }
     }
 }
Beispiel #3
0
 public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
 {
     return(RefillWorkGiverUtility.RefillJob(pawn, t, forced));
 }