Ejemplo n.º 1
0
        private float RestMultiplier(RestCategory fatigue)
        {
            float result;

            switch (fatigue)
            {
            case RestCategory.Rested:
                result = this.factorRested;
                break;

            case RestCategory.Tired:
                result = this.factorTired;
                break;

            case RestCategory.VeryTired:
                result = this.factorVeryTired;
                break;

            case RestCategory.Exhausted:
                result = this.factorExhausted;
                break;

            default:
                throw new InvalidOperationException();
            }
            return(result);
        }
Ejemplo n.º 2
0
        public static string GetLabel(this RestCategory fatigue)
        {
            string result;

            switch (fatigue)
            {
            case RestCategory.Rested:
                result = "HungerLevel_Rested".Translate();
                break;

            case RestCategory.Tired:
                result = "HungerLevel_Tired".Translate();
                break;

            case RestCategory.VeryTired:
                result = "HungerLevel_VeryTired".Translate();
                break;

            case RestCategory.Exhausted:
                result = "HungerLevel_Exhausted".Translate();
                break;

            default:
                throw new InvalidOperationException();
            }
            return(result);
        }
        private static bool Prefix(RestCategory ___minCategory, float ___maxLevelPercentage, ref float __result,
                                   Pawn pawn)
        {
            var rest = pawn.needs.rest;

            if (rest == null)
            {
                __result = 0f;
                return(false);
            }

            if (rest.CurCategory < ___minCategory)
            {
                __result = 0f;
                return(false);
            }

            if (rest.CurLevelPercentage > ___maxLevelPercentage)
            {
                __result = 0f;
                return(false);
            }

            if (Find.TickManager.TicksGame < pawn.mindState.canSleepTick)
            {
                __result = 0f;
                return(false);
            }

            var humanlike = pawn.RaceProps.Humanlike;

            if (!humanlike)
            {
                return(true);
            }

            var timeAssignmentDef = pawn.timetable == null
                ? TimeAssignmentDefOf.Anything
                : pawn.timetable.CurrentAssignment;

            if (timeAssignmentDef != TimeAssignmentDefDinner.DinnerDef)
            {
                return(true);
            }

            var lord = pawn.GetLord();

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

            var curLevel = rest.CurLevel;

            __result = curLevel < 0.3f ? 8f : 0f;
            return(false);
        }
Ejemplo n.º 4
0
 public static string GetLabel(this RestCategory fatigue)
 {
     return(fatigue switch
     {
         RestCategory.Exhausted => "HungerLevel_Exhausted".Translate(),
         RestCategory.VeryTired => "HungerLevel_VeryTired".Translate(),
         RestCategory.Tired => "HungerLevel_Tired".Translate(),
         RestCategory.Rested => "HungerLevel_Rested".Translate(),
         _ => throw new InvalidOperationException(),
     });
Ejemplo n.º 5
0
 private float RestMultiplier(RestCategory fatigue)
 {
     return(fatigue switch
     {
         RestCategory.Exhausted => factorExhausted,
         RestCategory.VeryTired => factorVeryTired,
         RestCategory.Tired => factorTired,
         RestCategory.Rested => factorRested,
         _ => throw new InvalidOperationException(),
     });
Ejemplo n.º 6
0
        public override void HandleTick(SkillRecord sk, Pawn pawn)
        {
            SkillDef sd = InterestBase.GetActiveSkill(pawn);

            if (sd == null)
            {
                return;
            }
            SkillRecord skill = pawn.skills.GetSkill(sd);

            if (skill != sk)
            {
                return;
            }

            Need_Rest restNeed = pawn.needs.TryGetNeed(NeedDefOf.Rest) as Need_Rest;

            if (restNeed == null)
            {
                Log.Error("Got null rest need, wat");
                return;
            }

            // Rest fall per 150 ticks is 150f*1.58333332E-05f * RestFallFactor * (modifier based on tiredness level);
            // Perfect equilibrium is 200f* 1.58333332E-05f
            RestCategory rc = restNeed.CurCategory;
            float        factor;

            switch (rc)
            {
            case RestCategory.Rested:
                factor = 1.0f;
                break;

            case RestCategory.Tired:
                factor = 0.7f;
                break;

            case RestCategory.VeryTired:
                factor = 0.3f;
                break;

            case RestCategory.Exhausted:
                factor = 0.6f;
                break;

            default:
                factor = 999f;
                break;
            }
            float restGain = (200f / 2.0f) * 1.58333332E-05f * factor;

            restNeed.CurLevel += restGain;
        }
        static bool Prefix(RestCategory ___minCategory, float ___maxLevelPercentage, ref float __result, Pawn pawn)
        {
            Need_Rest rest = pawn.needs.rest;

            if (rest == null)
            {
                __result = 0f; return(false);
            }
            if (rest.CurCategory < ___minCategory)
            {
                __result = 0f; return(false);
            }
            if (rest.CurLevelPercentage > ___maxLevelPercentage)
            {
                __result = 0f; return(false);
            }
            if (Find.TickManager.TicksGame < pawn.mindState.canSleepTick)
            {
                __result = 0f; return(false);
            }
            TimeAssignmentDef timeAssignmentDef;

            if (pawn.RaceProps.Humanlike)
            {
                timeAssignmentDef = ((pawn.timetable == null) ? TimeAssignmentDefOf.Anything : pawn.timetable.CurrentAssignment);
                if (timeAssignmentDef != TimeAssignmentDefDinner.DinnerDef)
                {
                    return(true);
                }

                Lord lord = pawn.GetLord();
                if (lord != null && !lord.CurLordToil.AllowSatisfyLongNeeds)
                {
                    __result = 0f; return(false);
                }
                float curLevel = rest.CurLevel;
                if (curLevel < 0.3f)
                {
                    __result = 8f;
                }
                else
                {
                    __result = 0f;
                }
                //Log.Message("{0} rest priority = {1}".Translate(pawn.Label, __result));

                return(false);
            }
            else
            {
                return(true);
            }
        }
Ejemplo n.º 8
0
        private float RestMultiplier(RestCategory fatigue)
        {
            switch (fatigue)
            {
            case RestCategory.Rested:
                return(this.factorRested);

            case RestCategory.Tired:
                return(this.factorTired);

            case RestCategory.VeryTired:
                return(this.factorVeryTired);

            case RestCategory.Exhausted:
                return(this.factorExhausted);

            default:
                throw new InvalidOperationException();
            }
        }