Exemplo n.º 1
0
        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)));
        }
Exemplo n.º 2
0
 private void BindDirectNeedFields()
 {
     this.mood    = this.TryGetNeed <Need_Mood>();
     this.food    = this.TryGetNeed <Need_Food>();
     this.rest    = this.TryGetNeed <Need_Rest>();
     this.joy     = this.TryGetNeed <Need_Joy>();
     this.beauty  = this.TryGetNeed <Need_Beauty>();
     this.comfort = this.TryGetNeed <Need_Comfort>();
     this.space   = this.TryGetNeed <Need_Space>();
 }
Exemplo n.º 3
0
 private void BindDirectNeedFields()
 {
     mood     = TryGetNeed <Need_Mood>();
     food     = TryGetNeed <Need_Food>();
     rest     = TryGetNeed <Need_Rest>();
     joy      = TryGetNeed <Need_Joy>();
     beauty   = TryGetNeed <Need_Beauty>();
     comfort  = TryGetNeed <Need_Comfort>();
     roomsize = TryGetNeed <Need_RoomSize>();
     outdoors = TryGetNeed <Need_Outdoors>();
 }
Exemplo n.º 4
0
 private void BindDirectNeedFields()
 {
     this.mood     = this.TryGetNeed <Need_Mood>();
     this.food     = this.TryGetNeed <Need_Food>();
     this.rest     = this.TryGetNeed <Need_Rest>();
     this.joy      = this.TryGetNeed <Need_Joy>();
     this.beauty   = this.TryGetNeed <Need_Beauty>();
     this.comfort  = this.TryGetNeed <Need_Comfort>();
     this.roomsize = this.TryGetNeed <Need_RoomSize>();
     this.outdoors = this.TryGetNeed <Need_Outdoors>();
 }
 private void BindDirectNeedFields()
 {
     mood        = TryGetNeed <Need_Mood>();
     food        = TryGetNeed <Need_Food>();
     rest        = TryGetNeed <Need_Rest>();
     joy         = TryGetNeed <Need_Joy>();
     beauty      = TryGetNeed <Need_Beauty>();
     comfort     = TryGetNeed <Need_Comfort>();
     roomsize    = TryGetNeed <Need_RoomSize>();
     outdoors    = TryGetNeed <Need_Outdoors>();
     drugsDesire = TryGetNeed <Need_Chemical_Any>();
     authority   = null;
 }
Exemplo n.º 6
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)));
        }
Exemplo n.º 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;
        }
        public override float GetPriority(Pawn pawn)
        {
            Need_Rest rest = pawn.needs.rest;
            float     result;

            if (rest == null)
            {
                result = 0f;
            }
            else if (rest.CurCategory < this.minCategory)
            {
                result = 0f;
            }
            else if (Find.TickManager.TicksGame < pawn.mindState.canSleepTick)
            {
                result = 0f;
            }
            else
            {
                Lord lord = pawn.GetLord();
                if (lord != null && !lord.CurLordToil.AllowSatisfyLongNeeds)
                {
                    result = 0f;
                }
                else
                {
                    TimeAssignmentDef timeAssignmentDef;
                    if (pawn.RaceProps.Humanlike)
                    {
                        timeAssignmentDef = ((pawn.timetable != null) ? pawn.timetable.CurrentAssignment : TimeAssignmentDefOf.Anything);
                    }
                    else
                    {
                        int num = GenLocalDate.HourOfDay(pawn);
                        if (num < 7 || num > 21)
                        {
                            timeAssignmentDef = TimeAssignmentDefOf.Sleep;
                        }
                        else
                        {
                            timeAssignmentDef = TimeAssignmentDefOf.Anything;
                        }
                    }
                    float curLevel = rest.CurLevel;
                    if (timeAssignmentDef == TimeAssignmentDefOf.Anything)
                    {
                        if (curLevel < 0.3f)
                        {
                            result = 8f;
                        }
                        else
                        {
                            result = 0f;
                        }
                    }
                    else if (timeAssignmentDef == TimeAssignmentDefOf.Work)
                    {
                        result = 0f;
                    }
                    else if (timeAssignmentDef == TimeAssignmentDefOf.Joy)
                    {
                        if (curLevel < 0.3f)
                        {
                            result = 8f;
                        }
                        else
                        {
                            result = 0f;
                        }
                    }
                    else
                    {
                        if (timeAssignmentDef != TimeAssignmentDefOf.Sleep)
                        {
                            throw new NotImplementedException();
                        }
                        if (curLevel < RestUtility.FallAsleepMaxLevel(pawn))
                        {
                            result = 8f;
                        }
                        else
                        {
                            result = 0f;
                        }
                    }
                }
            }
            return(result);
        }
Exemplo n.º 9
0
        public override float GetPriority(Pawn pawn)
        {
            Need_Rest rest = pawn.needs.rest;

            if (rest == null)
            {
                return(0f);
            }
            if ((int)rest.CurCategory < (int)minCategory)
            {
                return(0f);
            }
            if (rest.CurLevelPercentage > maxLevelPercentage)
            {
                return(0f);
            }
            if (Find.TickManager.TicksGame < pawn.mindState.canSleepTick)
            {
                return(0f);
            }
            Lord lord = pawn.GetLord();

            if (lord != null && !lord.CurLordToil.AllowSatisfyLongNeeds)
            {
                return(0f);
            }
            TimeAssignmentDef timeAssignmentDef;

            if (pawn.RaceProps.Humanlike)
            {
                timeAssignmentDef = ((pawn.timetable == null) ? TimeAssignmentDefOf.Anything : pawn.timetable.CurrentAssignment);
            }
            else
            {
                int num = GenLocalDate.HourOfDay(pawn);
                timeAssignmentDef = ((num >= 7 && num <= 21) ? TimeAssignmentDefOf.Anything : TimeAssignmentDefOf.Sleep);
            }
            float curLevel = rest.CurLevel;

            if (timeAssignmentDef == TimeAssignmentDefOf.Anything)
            {
                if (curLevel < 0.3f)
                {
                    return(8f);
                }
                return(0f);
            }
            if (timeAssignmentDef == TimeAssignmentDefOf.Work)
            {
                return(0f);
            }
            if (timeAssignmentDef == TimeAssignmentDefOf.Meditate)
            {
                if (curLevel < 0.16f)
                {
                    return(8f);
                }
                return(0f);
            }
            if (timeAssignmentDef == TimeAssignmentDefOf.Joy)
            {
                if (curLevel < 0.3f)
                {
                    return(8f);
                }
                return(0f);
            }
            if (timeAssignmentDef == TimeAssignmentDefOf.Sleep)
            {
                if (curLevel < RestUtility.FallAsleepMaxLevel(pawn))
                {
                    return(8f);
                }
                return(0f);
            }
            throw new NotImplementedException();
        }