public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false) { Job result; if (!base.ShouldTakeCareOfPrisoner(pawn, t)) { result = null; } else { Pawn pawn2 = (Pawn)t; Thing thing; ThingDef thingDef; if (!pawn2.guest.CanBeBroughtFood) { result = null; } else if (!pawn2.Position.IsInPrisonCell(pawn2.Map)) { result = null; } else if (pawn2.needs.food.CurLevelPercentage >= pawn2.needs.food.PercentageThreshHungry + 0.02f) { result = null; } else if (WardenFeedUtility.ShouldBeFed(pawn2)) { result = null; } else if (!FoodUtility.TryFindBestFoodSourceFor(pawn, pawn2, pawn2.needs.food.CurCategory == HungerCategory.Starving, out thing, out thingDef, false, true, false, false, false, false, false)) { result = null; } else if (thing.GetRoom(RegionType.Set_Passable) == pawn2.GetRoom(RegionType.Set_Passable)) { result = null; } else if (WorkGiver_Warden_DeliverFood.FoodAvailableInRoomTo(pawn2)) { result = null; } else { float nutrition = FoodUtility.GetNutrition(thing, thingDef); result = new Job(JobDefOf.DeliverFood, thing, pawn2) { count = FoodUtility.WillIngestStackCountOf(pawn2, thingDef, nutrition), targetC = RCellFinder.SpotToChewStandingNear(pawn2, thing) }; } } return(result); }
public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false) { if (!base.ShouldTakeCareOfPrisoner(pawn, t)) { return(null); } Pawn pawn2 = (Pawn)t; if (!pawn2.guest.CanBeBroughtFood) { return(null); } if (!pawn2.Position.IsInPrisonCell(pawn2.Map)) { return(null); } if (pawn2.needs.food.CurLevelPercentage >= pawn2.needs.food.PercentageThreshHungry + 0.019999999552965164) { return(null); } if (WardenFeedUtility.ShouldBeFed(pawn2)) { return(null); } Thing thing = default(Thing); ThingDef def = default(ThingDef); if (!FoodUtility.TryFindBestFoodSourceFor(pawn, pawn2, pawn2.needs.food.CurCategory == HungerCategory.Starving, out thing, out def, false, true, false, false, false, false)) { return(null); } if (thing.GetRoom(RegionType.Set_Passable) == pawn2.GetRoom(RegionType.Set_Passable)) { return(null); } if (WorkGiver_Warden_DeliverFood.FoodAvailableInRoomTo(pawn2)) { return(null); } Job job = new Job(JobDefOf.DeliverFood, thing, pawn2); job.count = FoodUtility.WillIngestStackCountOf(pawn2, def); job.targetC = RCellFinder.SpotToChewStandingNear(pawn2, thing); return(job); }