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)
            });
        }
Esempio n. 2
0
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            Pawn warden   = pawn;
            Pawn prisoner = t as Pawn;

            // 世話が必要でない
            if (!base.ShouldTakeCareOfPrisoner(warden, prisoner))
            {
                return(null);
            }

            // 囚人が食事を持って来てもらえる扱いではない
            if (!prisoner.guest.CanBeBroughtFood)
            {
                return(null);
            }

            // 囚人は牢屋にいない
            if (!prisoner.Position.IsInPrisonCell(prisoner.Map))
            {
                return(null);
            }

            Need_Water need_water = prisoner.needs.water();

            // 水分要求がない
            if (need_water == null)
            {
                return(null);
            }

            // 喉が渇いていない
            if (need_water.CurLevelPercentage >= need_water.PercentageThreshThirsty + 0.02f)
            {
                return(null);
            }

            // (囚人が病人だから)食事を与えられるべき状態である(部屋に運ばれたものを自分で食べることができない)
            if (WardenFeedUtility.ShouldBeFed(prisoner))
            {
                return(null);
            }

            // 水が見つからない
            Thing thing = MizuUtility.TryFindBestWaterSourceFor(warden, prisoner, false, false);

            if (thing == null)
            {
                return(null);
            }

            // 見つかった水アイテムは既に囚人がいる部屋の中にある
            if (thing.GetRoom(RegionType.Set_Passable) == prisoner.GetRoom(RegionType.Set_Passable))
            {
                return(null);
            }

            // 部屋の中に十分な量の水がある
            if (WorkGiver_Warden_DeliverWater.WaterAvailableInRoomTo(prisoner))
            {
                return(null);
            }

            // 水を運んでくるジョブを発行
            return(new Job(MizuDef.Job_DeliverWater, thing, prisoner)
            {
                count = MizuUtility.WillGetStackCountOf(prisoner, thing),
                targetC = RCellFinder.SpotToChewStandingNear(prisoner, thing)
            });
        }
 public static bool ShouldBeFedBySomeone(Pawn pawn)
 {
     return(FeedPatientUtility.ShouldBeFed(pawn) || WardenFeedUtility.ShouldBeFed(pawn));
 }