Example #1
0
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            if (!base.ShouldTakeCareOfPrisoner(pawn, t))
            {
                return(null);
            }
            Pawn pawn2 = (Pawn)t;

            if (!WardenFeedUtility.ShouldBeFed(pawn2))
            {
                return(null);
            }
            if (pawn2.needs.food.CurLevelPercentage >= pawn2.needs.food.PercentageThreshHungry + 0.019999999552965164)
            {
                return(null);
            }
            Thing    t2  = default(Thing);
            ThingDef def = default(ThingDef);

            if (!FoodUtility.TryFindBestFoodSourceFor(pawn, pawn2, pawn2.needs.food.CurCategory == HungerCategory.Starving, out t2, out def, false, true, false, false, false, false))
            {
                JobFailReason.Is("NoFood".Translate());
                return(null);
            }
            Job job = new Job(JobDefOf.FeedPatient, t2, pawn2);

            job.count = FoodUtility.WillIngestStackCountOf(pawn2, def);
            return(job);
        }
Example #2
0
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            if (!ShouldTakeCareOfPrisoner(pawn, t))
            {
                return(null);
            }
            Pawn pawn2 = (Pawn)t;

            if (!WardenFeedUtility.ShouldBeFed(pawn2))
            {
                return(null);
            }
            if (pawn2.needs.food.CurLevelPercentage >= pawn2.needs.food.PercentageThreshHungry + 0.02f)
            {
                return(null);
            }
            if (!FoodUtility.TryFindBestFoodSourceFor(pawn, pawn2, pawn2.needs.food.CurCategory == HungerCategory.Starving, out Thing foodSource, out ThingDef foodDef, canRefillDispenser: false, canUseInventory: true, allowForbidden: false, allowCorpse: false))
            {
                JobFailReason.Is("NoFood".Translate());
                return(null);
            }
            float nutrition = FoodUtility.GetNutrition(foodSource, foodDef);
            Job   job       = new Job(JobDefOf.FeedPatient, foodSource, pawn2);

            job.count = FoodUtility.WillIngestStackCountOf(pawn2, foodDef, nutrition);
            return(job);
        }
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            if (!base.ShouldTakeCareOfPrisoner(pawn, t))
            {
                return(null);
            }
            Pawn pawn2 = (Pawn)t;

            if (!WardenFeedUtility.ShouldBeFed(pawn2))
            {
                return(null);
            }
            if (pawn2.needs.food.CurLevelPercentage >= pawn2.needs.food.PercentageThreshHungry + 0.02f)
            {
                return(null);
            }
            Thing    thing;
            ThingDef thingDef;

            if (!FoodUtility.TryFindBestFoodSourceFor(pawn, pawn2, pawn2.needs.food.CurCategory == HungerCategory.Starving, out thing, out thingDef, false, true, false, false, false, false, false))
            {
                JobFailReason.Is("NoFood".Translate(), null);
                return(null);
            }
            float nutrition = FoodUtility.GetNutrition(thing, thingDef);

            return(new Job(JobDefOf.FeedPatient, thing, pawn2)
            {
                count = FoodUtility.WillIngestStackCountOf(pawn2, thingDef, nutrition)
            });
        }
Example #4
0
 public static bool ShouldBeFedBySomeone(Pawn pawn)
 {
     if (!FeedPatientUtility.ShouldBeFed(pawn))
     {
         return(WardenFeedUtility.ShouldBeFed(pawn));
     }
     return(true);
 }
        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);
        }
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            if (!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.02f)
            {
                return(null);
            }
            if (WardenFeedUtility.ShouldBeFed(pawn2))
            {
                return(null);
            }
            if (!FoodUtility.TryFindBestFoodSourceFor(pawn, pawn2, pawn2.needs.food.CurCategory == HungerCategory.Starving, out Thing foodSource, out ThingDef foodDef, canRefillDispenser: false, canUseInventory: true, allowForbidden: false, allowCorpse: false))
            {
                return(null);
            }
            if (foodSource.GetRoom() == pawn2.GetRoom())
            {
                return(null);
            }
            if (FoodAvailableInRoomTo(pawn2))
            {
                return(null);
            }
            float nutrition = FoodUtility.GetNutrition(foodSource, foodDef);
            Job   job       = new Job(JobDefOf.DeliverFood, foodSource, pawn2);

            job.count   = FoodUtility.WillIngestStackCountOf(pawn2, foodDef, nutrition);
            job.targetC = RCellFinder.SpotToChewStandingNear(pawn2, foodSource);
            return(job);
        }
 public static bool ShouldBeFedBySomeone(Pawn pawn)
 {
     return(FeedPatientUtility.ShouldBeFed(pawn) || WardenFeedUtility.ShouldBeFed(pawn));
 }