示例#1
0
        public override float GetPriority(Pawn pawn)
        {
            var food = pawn.needs.food;

            if (food == null)
            {
                return(0f);
            }
            if (pawn.needs.food.CurCategory < HungerCategory.Starving && FoodUtility_Tweak.ShouldBeFedBySomeone(pawn))
            {
                return(0f);
            }
            if (food.CurCategory < minCategory)
            {
                return(0f);
            }
            if (food.CurCategory <= stopWorkingCat)
            {
                return(11f);
            }
            if (food.CurLevelPercentage < pawn.RaceProps.FoodLevelPercentageWantEat)
            {
                return(7f);
            }
            return(0f);
        }
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            if (!ShouldTakeCareOfPrisoner(pawn, t))
            {
                return(null);
            }
            var pawn2 = (Pawn)t;

            if (!pawn2.guest.CanBeBroughtFood)
            {
                return(null);
            }
            //if (pawn2.Position.IsInPrisonCell(pawn2.Map) || RCellFinder.TryFindBestExitSpot((Pawn)t, out c, TraverseMode.ByPawn))
            if (pawn2.needs.food.CurLevelPercentage >= pawn2.needs.food.PercentageThreshHungry + 0.02f)
            {
                return(null);
            }
            if (WardenFeedUtility.ShouldBeFed(pawn2))
            {
                return(null);
            }
            Thing    thing;
            ThingDef def;

            //Tweak: changes way of finding food
            if (!FoodUtility_Tweak.TryFindBestFoodSourceFor(pawn, pawn2,
                                                            pawn2.needs.food.CurCategory == HungerCategory.Starving, out thing, out def, false, true, false, false,
                                                            false))
            {
                return(null);
            }
            if (thing.GetRoom(RegionType.Set_Passable) == pawn2.GetRoom(RegionType.Set_Passable))
            {
                return(null);
            }
            if (FoodAvailableInRoomTo(pawn2))
            {
                return(null);
            }
            return(new Job(DefDatabase <JobDef> .GetNamed("PrisonLabor_DeliverFood_Tweak"), thing, pawn2)
            {
                count = FoodUtility_Tweak.WillIngestStackCountOf(pawn2, def),
                targetC = RCellFinder.SpotToChewStandingNear(pawn2, thing)
            });
        }
示例#3
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            var food = pawn.needs.food;

            if (food == null || food.CurCategory < minCategory)
            {
                return(null);
            }
            var need = pawn.needs.TryGetNeed <Need_Motivation>();

            if (need != null)
            {
                need.Enabled = false;
            }
            bool flag;

            if (pawn.RaceProps.Animal)
            {
                flag = true;
            }
            else
            {
                var firstHediffOfDef = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.Malnutrition, false);
                flag = firstHediffOfDef != null && firstHediffOfDef.Severity > 0.4f;
            }
            var      desperate   = pawn.needs.food.CurCategory == HungerCategory.Starving;
            var      allowCorpse = flag;
            Thing    thing;
            ThingDef def;

            if (!FoodUtility_Tweak.TryFindBestFoodSourceFor(pawn, pawn, desperate, out thing, out def, true, true, true,
                                                            allowCorpse, false))
            {
                return(null);
            }
            var pawn2 = thing as Pawn;

            if (pawn2 != null)
            {
                return new Job(JobDefOf.PredatorHunt, pawn2)
                       {
                           killIncappedTarget = true
                       }
            }
            ;
            var building_NutrientPasteDispenser = thing as Building_NutrientPasteDispenser;

            if (building_NutrientPasteDispenser != null &&
                !building_NutrientPasteDispenser.HasEnoughFeedstockInHoppers())
            {
                var building = building_NutrientPasteDispenser.AdjacentReachableHopper(pawn);

                if (building != null)
                {
                    var hopperSgp = building as ISlotGroupParent;
                    var job       = WorkGiver_CookFillHopper.HopperFillFoodJob(pawn, hopperSgp);
                    if (job != null)
                    {
                        return(job);
                    }
                }
                thing = FoodUtility_Tweak.BestFoodSourceOnMap(pawn, pawn, desperate, FoodPreferability.MealLavish,
                                                              false, !pawn.IsTeetotaler(), false, false, false, false, false);
                if (thing == null)
                {
                    return(null);
                }
                def = thing.def;
            }
            return(new Job(JobDefOf.Ingest, thing)
            {
                count = FoodUtility_Tweak.WillIngestStackCountOf(pawn, def)
            });
        }
    }