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"));
         }
     }
 }
Пример #3
0
        public static bool CanRefill(Pawn pawn, Thing t, bool forced = false)
        {
            CompRefillable compRefill = t.TryGetComp <CompRefillable>();

            if (compRefill is null || compRefill.IsFull())
            {
                return(false);
            }
            bool flag = !forced;

            if (flag && !compRefill.ShouldAutoRefill)
            {
                return(false);
            }
            if (!t.IsForbidden(pawn))
            {
                LocalTargetInfo target = t;
                if (pawn.CanReserve(target, 1, -1, null, forced))
                {
                    if (t.Faction != pawn.Faction)
                    {
                        return(false);
                    }
                    if (RefillWorkGiverUtility.FindNextFuelItem(pawn, t) is null)
                    {
                        JobFailReason.Is("No items available to refill", null);
                        return(false);
                    }
                    return(true);
                }
            }
            return(false);
        }
Пример #4
0
 public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
 {
     return(RefillWorkGiverUtility.RefillJob(pawn, t, forced));
 }
Пример #5
0
 public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
 {
     return(RefillWorkGiverUtility.CanRefill(pawn, t, forced));
 }
Пример #6
0
        public static Job RefillJob(Pawn pawn, Thing t, bool forced = false)
        {
            Thing t2 = RefillWorkGiverUtility.FindNextFuelItem(pawn, t);

            return(new Job(JobDefOfCuisine.Refill, t, t2));
        }