Пример #1
0
        public static void Postfix(Job newJob, Pawn ___pawn, Pawn_JobTracker __instance)
        {
            if (newJob.def == JobDefOf.HaulToCell)
            {
                if (newJob.targetA.HasThing)
                {
                    Thing     thing     = newJob.targetA.Thing;
                    SlotGroup slotGroup = ___pawn.Map.haulDestinationManager.SlotGroupAt(newJob.targetB.Cell);

                    int stackCount = newJob.targetA.Thing.stackCount;
                    if (stackCount < 1)
                    {
                        stackCount = int.MaxValue;
                    }
                    int amountCarrying = Math.Min(newJob.count, stackCount);
                    amountCarrying = Math.Min(amountCarrying, ___pawn.carryTracker.AvailableStackSpace(newJob.targetA.Thing.def));

                    //int amountCarrying = newJob.count < 0 ? newJob.targetA.Thing.stackCount : newJob.count;
#if DEBUG
                    Log.Message($"{___pawn} is hauling {newJob.targetA}, count = {amountCarrying}");
#endif

                    PendingHaulJobsTracker.AddNewJob(___pawn, amountCarrying, slotGroup);
                }
            }
            else
            {
                PendingHaulJobsTracker.ClearJobForPawn(___pawn);
            }
        }
Пример #2
0
 public static void Postfix(bool startNewJob, Pawn ___pawn)
 {
     if (!startNewJob)
     {
         PendingHaulJobsTracker.ClearJobForPawn(___pawn);
     }
 }
Пример #3
0
        public static int TotalPrecalculatedItemsStack(this SlotGroup slotGroup, bool usePending = true)
        {
            if (slotGroup == null)
            {
                return(0);
            }

            int pending     = usePending ? PendingHaulJobsTracker.GetPendingStack(slotGroup) : 0;
            int inSlotGroup = HeldItemsCounter.GetTotalItemsStack(slotGroup);

            return(pending + inSlotGroup);
        }
        public static void TestOutput()
        {
#if DEBUG
            if (heldItems.Count != 0)
            {
                var x = heldItems.ElementAt(0).Value;
                foreach (var y in x)
                {
                    Log.Message($"{y.Key} : {y.Value} held, and an extra {PendingHaulJobsTracker.GetPendingStack(y.Key)} is pending");
                }
            }
#endif
        }