Skip to content

Commit

Permalink
Merge pull request #2885 from CombatExtended-Continued/Loadouts-meal-fix
Browse files Browse the repository at this point in the history
Loadouts meal fix
  • Loading branch information
N7Huntsman authored Nov 14, 2023
2 parents dd94181 + 308e328 commit b7921ed
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ private static void FindPickup(Pawn pawn, LoadoutSlot curSlot, int findCount, ou
{
findItem = t => t.GetInnerIfMinified().def == curSlot.thingDef;
}
Predicate<Thing> search = t => findItem(t) && !t.IsForbidden(pawn) && pawn.CanReserve(t, 10, 1) && !isFoodInPrison(t) && AllowedByBiocode(t, pawn);
Predicate<Thing> search = t => findItem(t) && !t.IsForbidden(pawn) && pawn.CanReserve(t, 10, 1) && !isFoodInPrison(t) && AllowedByBiocode(t, pawn) && AllowedByFoodRestriction(t, pawn);

// look for a thing near the pawn.
curThing = GenClosest.ClosestThingReachable(
Expand Down Expand Up @@ -278,6 +278,18 @@ private static bool AllowedByBiocode(Thing thing, Pawn pawn)
return (compBiocoded == null || !compBiocoded.Biocoded || compBiocoded.CodedPawn == pawn);
}

private static bool AllowedByFoodRestriction(Thing thing, Pawn pawn)
{
if (thing != null && thing.def.IsNutritionGivingIngestible)
{
return pawn.foodRestriction.GetCurrentRespectedRestriction(pawn).Allows(thing);
}
else
{
return true;
}
}

/// <summary>
/// Tries to give the pawn a job related to picking up or dropping an item from their inventory.
/// </summary>
Expand Down

0 comments on commit b7921ed

Please sign in to comment.