public static bool CanHaulAndInPrisonCell(Pawn p, Thing t, bool forced) { var unfinishedThing = t as UnfinishedThing; if (unfinishedThing != null && unfinishedThing.BoundBill != null) { return(false); } if (!p.CanReach(t, PathEndMode.ClosestTouch, p.NormalMaxDanger(), false, TraverseMode.ByPawn)) { return(false); } if (!p.CanReserve(t, 1, -1, null, forced)) { return(false); } if (t.def.IsNutritionGivingIngestible && t.def.ingestible.HumanEdible && !t.IsSociallyProper(p, false, true)) { if (PrisonerFoodReservation.IsReserved(t)) { JobFailReason.Is("ReservedForPrisoners".Translate()); return(false); } } if (t.IsBurning()) { JobFailReason.Is("BurningLower".Translate()); return(false); } return(true); }
public static bool CustomForbidConditions(Thing thing, Pawn pawn) { if (PrisonerFoodReservation.IsReserved(thing) && !pawn.IsPrisoner) { return(true); } if (pawn.IsWatched() && ForbidUtility.IsForbidden(thing, Faction.OfPlayer)) { return(true); } return(false); }
static void Postfix(ref IEnumerable <Toil> __result, JobDriver_FoodDeliver __instance) { __result = new List <Toil>(__result); var lastToil = ((List <Toil>)__result).Last(); lastToil.initAction = delegate { Thing thing; __instance.pawn.carryTracker.TryDropCarriedThing(lastToil.actor.jobs.curJob.targetC.Cell, ThingPlaceMode.Direct, out thing, null); PrisonerFoodReservation.reserve(thing, (Pawn)lastToil.actor.jobs.curJob.targetB.Thing); }; }
public static Predicate <Thing> AddContitionToPredicate(Predicate <Thing> predicate, Pawn getter, Pawn eater, bool desperate) { return(new Predicate <Thing>(target => { if (PrisonerFoodReservation.IsReserved(target) && (eater != getter || !eater.IsPrisoner) && !desperate) { return false; } else { return predicate.Invoke(target); } } )); }