protected override bool Satisfied(Pawn pawn)
 {
     if (pawn.CurJob != null && pawn.jobs.curDriver.layingDown != 0)
     {
         if (!pawn.Downed)
         {
             if (RestUtility.DisturbancePreventsLyingDown(pawn))
             {
                 return(false);
             }
             if (!pawn.CurJob.restUntilHealed || !HealthAIUtility.ShouldSeekMedicalRest(pawn))
             {
                 if (!pawn.jobs.curDriver.asleep)
                 {
                     return(false);
                 }
                 if (!pawn.CurJob.playerForced && RestUtility.TimetablePreventsLayDown(pawn))
                 {
                     return(false);
                 }
             }
         }
         return(true);
     }
     return(false);
 }
        public override ThinkResult TryIssueJobPackage(Pawn pawn, JobIssueParams jobParams)
        {
            ThinkResult result;

            if (!HealthAIUtility.ShouldSeekMedicalRest(pawn))
            {
                result = ThinkResult.NoJob;
            }
            else if (this.respectTimetable && RestUtility.TimetablePreventsLayDown(pawn) && !HealthAIUtility.ShouldHaveSurgeryDoneNow(pawn) && !HealthAIUtility.ShouldBeTendedNowByPlayer(pawn))
            {
                result = ThinkResult.NoJob;
            }
            else if (RestUtility.DisturbancePreventsLyingDown(pawn))
            {
                result = ThinkResult.NoJob;
            }
            else
            {
                Thing thing = RestUtility.FindPatientBedFor(pawn);
                if (thing == null)
                {
                    result = ThinkResult.NoJob;
                }
                else
                {
                    Job job = new Job(JobDefOf.LayDown, thing);
                    result = new ThinkResult(job, this, null, false);
                }
            }
            return(result);
        }
        protected override Job TryGiveJob(Pawn pawn)
        {
            Need_Rest rest = pawn.needs.rest;

            if (rest == null || rest.CurCategory < this.minCategory)
            {
                return(null);
            }
            if (RestUtility.DisturbancePreventsLyingDown(pawn))
            {
                return(null);
            }
            Lord         lord = pawn.GetLord();
            Building_Bed building_Bed;

            if ((lord != null && lord.CurLordToil != null && !lord.CurLordToil.AllowRestingInBed) || pawn.IsWildMan())
            {
                building_Bed = null;
            }
            else
            {
                building_Bed = RestUtility.FindBedFor(pawn);
            }
            if (building_Bed != null)
            {
                return(new Job(JobDefOf.LayDown, building_Bed));
            }
            return(new Job(JobDefOf.LayDown, this.FindGroundSleepSpotFor(pawn)));
        }
Beispiel #4
0
        protected override bool Satisfied(Pawn pawn)
        {
            bool result;

            if (pawn.CurJob == null || !pawn.GetPosture().Laying())
            {
                result = false;
            }
            else
            {
                if (!pawn.Downed)
                {
                    if (RestUtility.DisturbancePreventsLyingDown(pawn))
                    {
                        return(false);
                    }
                    if (!pawn.CurJob.restUntilHealed || !HealthAIUtility.ShouldSeekMedicalRest(pawn))
                    {
                        if (!pawn.jobs.curDriver.asleep)
                        {
                            return(false);
                        }
                        if (!pawn.CurJob.playerForced)
                        {
                            if (RestUtility.TimetablePreventsLayDown(pawn))
                            {
                                return(false);
                            }
                        }
                    }
                }
                result = true;
            }
            return(result);
        }
Beispiel #5
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            Need_Rest rest = pawn.needs.rest;

            if (rest == null || (int)rest.CurCategory < (int)minCategory || rest.CurLevelPercentage > maxLevelPercentage)
            {
                return(null);
            }
            if (RestUtility.DisturbancePreventsLyingDown(pawn))
            {
                return(null);
            }
            Lord         lord         = pawn.GetLord();
            Building_Bed building_Bed = (((lord == null || lord.CurLordToil == null || lord.CurLordToil.AllowRestingInBed) && !pawn.IsWildMan()) ? RestUtility.FindBedFor(pawn) : null);

            if (building_Bed != null)
            {
                return(JobMaker.MakeJob(JobDefOf.LayDown, building_Bed));
            }
            return(JobMaker.MakeJob(JobDefOf.LayDown, FindGroundSleepSpotFor(pawn)));
        }
Beispiel #6
0
        public override ThinkResult TryIssueJobPackage(Pawn pawn, JobIssueParams jobParams)
        {
            if (!HealthAIUtility.ShouldSeekMedicalRest(pawn))
            {
                return(ThinkResult.NoJob);
            }
            if (respectTimetable && RestUtility.TimetablePreventsLayDown(pawn) && !HealthAIUtility.ShouldHaveSurgeryDoneNow(pawn) && !HealthAIUtility.ShouldBeTendedNowByPlayer(pawn))
            {
                return(ThinkResult.NoJob);
            }
            if (RestUtility.DisturbancePreventsLyingDown(pawn))
            {
                return(ThinkResult.NoJob);
            }
            Thing thing = RestUtility.FindPatientBedFor(pawn);

            if (thing == null)
            {
                return(ThinkResult.NoJob);
            }
            return(new ThinkResult(JobMaker.MakeJob(JobDefOf.LayDown, thing), this));
        }
Beispiel #7
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            Need_Rest    rest = pawn.needs.rest;
            Building_Bed building_Bed;

            if (rest != null && (int)rest.CurCategory >= (int)this.minCategory)
            {
                if (RestUtility.DisturbancePreventsLyingDown(pawn))
                {
                    return(null);
                }
                Lord lord = pawn.GetLord();
                if (lord != null && lord.CurLordToil != null && !lord.CurLordToil.AllowRestingInBed)
                {
                    goto IL_0065;
                }
                if (pawn.IsWildMan())
                {
                    goto IL_0065;
                }
                building_Bed = RestUtility.FindBedFor(pawn);
                goto IL_0073;
            }
            return(null);

IL_0073:
            if (building_Bed != null)
            {
                return(new Job(JobDefOf.LayDown, building_Bed));
            }
            return(new Job(JobDefOf.LayDown, this.FindGroundSleepSpotFor(pawn)));

IL_0065:
            building_Bed = null;
            goto IL_0073;
        }