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);
        }
        private static bool FoodAvailableInRoomTo(Pawn prisoner)
        {
            bool result;

            if (prisoner.carryTracker.CarriedThing != null && WorkGiver_Warden_DeliverFood.NutritionAvailableForFrom(prisoner, prisoner.carryTracker.CarriedThing) > 0f)
            {
                result = true;
            }
            else
            {
                float num  = 0f;
                float num2 = 0f;
                Room  room = prisoner.GetRoom(RegionType.Set_Passable);
                if (room == null)
                {
                    result = false;
                }
                else
                {
                    for (int i = 0; i < room.RegionCount; i++)
                    {
                        Region       region = room.Regions[i];
                        List <Thing> list   = region.ListerThings.ThingsInGroup(ThingRequestGroup.FoodSourceNotPlantOrTree);
                        for (int j = 0; j < list.Count; j++)
                        {
                            Thing thing = list[j];
                            if (!thing.def.IsIngestible || thing.def.ingestible.preferability > FoodPreferability.DesperateOnlyForHumanlikes)
                            {
                                num2 += WorkGiver_Warden_DeliverFood.NutritionAvailableForFrom(prisoner, thing);
                            }
                        }
                        List <Thing> list2 = region.ListerThings.ThingsInGroup(ThingRequestGroup.Pawn);
                        for (int k = 0; k < list2.Count; k++)
                        {
                            Pawn pawn = list2[k] as Pawn;
                            if (pawn.IsPrisonerOfColony && pawn.needs.food.CurLevelPercentage < pawn.needs.food.PercentageThreshHungry + 0.02f && (pawn.carryTracker.CarriedThing == null || !pawn.RaceProps.WillAutomaticallyEat(pawn.carryTracker.CarriedThing)))
                            {
                                num += pawn.needs.food.NutritionWanted;
                            }
                        }
                    }
                    result = (num2 + 0.5f >= num);
                }
            }
            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);
        }