static Job _HaulBeforeSupply(Pawn pawn, Thing constructible, Thing th)
 {
     if (!haulBeforeSupply.Value || !enabled.Value)
     {
         return(null);
     }
     return(Hauling.HaulBeforeCarry(pawn, constructible.Position, th));
 }
예제 #2
0
                static Job HaulBeforeSupply(Pawn pawn, Thing constructible, Thing th)
                {
                    if (!haulBeforeSupply.Value || !enabled.Value)
                    {
                        return(null);
                    }
                    if (JooStoreUtility.PuahHasThingsHauled(pawn))
                    {
                        Debug.WriteLine($"{RealTime.frameCount} {pawn} Aborting {MethodBase.GetCurrentMethod().Name}() already holding items.");
                        return(null);
                    }

                    return(Helper.CatchStanding(pawn, Hauling.HaulBeforeCarry(pawn, constructible.Position, th)));
                }
            static Job TryOpportunisticJob(Pawn_JobTracker jobTracker, Job job)
            {
//                Debug.WriteLine($"Opportunity checking {job}");
                var pawn = Traverse.Create(jobTracker).Field("pawn").GetValue <Pawn>();

                if (JooStoreUtility.PuahHasThingsHauled(pawn))
                {
                    Debug.WriteLine($"{RealTime.frameCount} {pawn} Aborting {MethodBase.GetCurrentMethod().Name}() during {job}; already holding items.");
                    return(null);
                }

                var jobCell = job.targetA.Cell;

                if (job.def == JobDefOf.DoBill && haulBeforeBill.Value && enabled.Value)
                {
//                    Debug.WriteLine($"Bill: '{job.bill}' label: '{job.bill.Label}'");
//                    Debug.WriteLine($"Recipe: '{job.bill.recipe}' workerClass: '{job.bill.recipe.workerClass}'");
                    foreach (var localTargetInfo in job.targetQueueB)
                    {
                        if (localTargetInfo.Thing == null)
                        {
                            continue;
                        }

                        if (HaulAIUtility.PawnCanAutomaticallyHaulFast(pawn, localTargetInfo.Thing, false))
                        {
                            // permitted when bleeding because facilitates whatever bill is important enough to do while bleeding
                            //  may save precious time going back for ingredients... unless we want only 1 medicine ASAP; it's a trade-off
                            var storeJob = Hauling.HaulBeforeCarry(pawn, jobCell, localTargetInfo.Thing);
                            if (storeJob != null)
                            {
                                return(Helper.CatchStanding(pawn, storeJob));
                            }
                        }
                    }
                }

                if (skipIfBleeding.Value && pawn.health.hediffSet.BleedRateTotal > 0.001f)
                {
                    return(null);
                }
//                return Helper.CatchStanding(pawn, Hauling.TryHaul(pawn, jobCell) ?? Cleaning.TryClean(pawn, jobCell));
                return(Helper.CatchStanding(pawn, Hauling.TryHaul(pawn, jobCell)));
            }
예제 #4
0
            static Job TryOpportunisticJob(Pawn_JobTracker __instance, Job job)
            {
                Debug.WriteLine($"Opportunity checking {job}");
                var pawn    = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>();
                var jobCell = job.targetA.Cell;

                if (haulBeforeBill.Value && haveCommonSense && (bool)CsHaulingOverBillsSetting.GetValue(csSettings))
                {
                    haulBeforeBill.Value = false;
                    haulBeforeBill.ForceSaveChanges();
                }

                if (job.def == JobDefOf.DoBill && haulBeforeBill.Value && enabled.Value)
                {
                    foreach (var localTargetInfo in job.targetQueueB)
                    {
                        if (localTargetInfo.Thing == null)
                        {
                            continue;
                        }

                        if (HaulAIUtility.PawnCanAutomaticallyHaulFast(pawn, localTargetInfo.Thing, false))
                        {
                            // permitted when bleeding because facilitates whatever bill is important enough to do while bleeding
                            //  may save precious time going back for ingredients... unless we only want 1 medicine ASAP; it's a trade-off
                            var storeJob = Hauling.HaulBeforeCarry(pawn, jobCell, localTargetInfo.Thing);
                            if (storeJob != null)
                            {
                                return(storeJob);
                            }
                        }
                    }
                }

                if (skipIfBleeding.Value && pawn.health.hediffSet.BleedRateTotal > 0.001f)
                {
                    return(null);
                }
                return(Hauling.TryHaul(pawn, jobCell)); // ?? Cleaning.TryClean(pawn, jobCell);
            }