public static Job HaulToStorageJob(Pawn p, Thing t) { StoragePriority currentPriority = HaulAIUtility.StoragePriorityAtFor(t.Position, t); IntVec3 storeCell = default(IntVec3); if (!StoreUtility.TryFindBestBetterStoreCellFor(t, p, p.Map, currentPriority, p.Faction, out storeCell, true)) { JobFailReason.Is(HaulAIUtility.NoEmptyPlaceLowerTrans); return(null); } return(HaulAIUtility.HaulMaxNumToCellJob(p, t, storeCell, false)); }
public static bool PawnCanAutomaticallyHaulFast(Pawn p, Thing t, bool forced) { UnfinishedThing unfinishedThing = t as UnfinishedThing; bool result; if (unfinishedThing != null && unfinishedThing.BoundBill != null) { result = false; } else { Profiler.BeginSample("CanReach"); if (!p.CanReach(t, PathEndMode.ClosestTouch, p.NormalMaxDanger(), false, TraverseMode.ByPawn)) { Profiler.EndSample(); result = false; } else { Profiler.EndSample(); LocalTargetInfo target = t; if (!p.CanReserve(target, 1, -1, null, forced)) { result = false; } else { if (t.def.IsNutritionGivingIngestible && t.def.ingestible.HumanEdible) { if (!t.IsSociallyProper(p, false, true)) { JobFailReason.Is(HaulAIUtility.ReservedForPrisonersTrans, null); return(false); } } if (t.IsBurning()) { JobFailReason.Is(HaulAIUtility.BurningLowerTrans, null); result = false; } else { result = true; } } } } return(result); }
public static bool PawnCanAutomaticallyHaul(Pawn p, Thing t, bool forced) { if (!t.def.EverHaulable) { return(false); } if (t.IsForbidden(p)) { if (!t.Position.InAllowedArea(p)) { JobFailReason.Is(HaulAIUtility.ForbiddenOutsideAllowedAreaLowerTrans, null); } else { JobFailReason.Is(HaulAIUtility.ForbiddenLowerTrans, null); } return(false); } return((t.def.alwaysHaulable || t.Map.designationManager.DesignationOn(t, DesignationDefOf.Haul) != null || t.IsInValidStorage()) && HaulAIUtility.PawnCanAutomaticallyHaulFast(p, t, forced)); }
public static Job HaulToStorageJob(Pawn p, Thing t) { StoragePriority currentPriority = StoreUtility.CurrentStoragePriorityOf(t); if (!StoreUtility.TryFindBestBetterStorageFor(t, p, p.Map, currentPriority, p.Faction, out IntVec3 foundCell, out IHaulDestination haulDestination)) { JobFailReason.Is(NoEmptyPlaceLowerTrans); return(null); } if (haulDestination is ISlotGroupParent) { return(HaulToCellStorageJob(p, t, foundCell, fitInStoreCell: false)); } Thing thing = haulDestination as Thing; if (thing != null && thing.TryGetInnerInteractableThingOwner() != null) { return(HaulToContainerJob(p, t, thing)); } Log.Error("Don't know how to handle HaulToStorageJob for storage " + haulDestination.ToStringSafe() + ". thing=" + t.ToStringSafe()); return(null); }