public static TimeAssignmentDef TimeAssignmentFor(Pawn pawn) { int hour = GenLocalDate.HourOfDay(pawn); ExtendedRaceProperties extendedRaceProps = pawn.def.GetModExtension <ExtendedRaceProperties>(); if (extendedRaceProps != null && extendedRaceProps.bodyClock == BodyClock.Crepuscular) { return(hour > 3 && hour < 16 ? TimeAssignmentDefOf.Sleep : TimeAssignmentDefOf.Anything); } else if (extendedRaceProps != null && extendedRaceProps.bodyClock == BodyClock.Nocturnal) { return(hour > 9 && hour < 19 ? TimeAssignmentDefOf.Sleep : TimeAssignmentDefOf.Anything); } return((hour >= 7 && hour <= 21) ? TimeAssignmentDefOf.Anything : TimeAssignmentDefOf.Sleep); }
public static bool SleepHourFor(int hour, Pawn pawn) { var extendedRaceProps = ExtendedRaceProperties.Get(pawn.def); if (extendedRaceProps != null) { switch (extendedRaceProps.bodyClock) { case BodyClock.Diurnal: return(hour < 7 || hour > 21); case BodyClock.Crepuscular: return(hour > 21 || hour < 2 || (hour > 10 && hour < 15)); case BodyClock.Nocturnal: return(hour > 10 && hour < 19); default: throw new NotImplementedException(); } } return(hour < 7 || hour > 21); }
public static void Postfix(ThingDef parentDef, ref IEnumerable <StatDrawEntry> __result) { // Body clock __result = __result.AddItem(new StatDrawEntry(StatCategoryDefOf.BasicsPawn, "NocturnalAnimals.BodyClock".Translate(), $"NocturnalAnimals.BodyClock_{ExtendedRaceProperties.Get(parentDef).bodyClock}".Translate(), "NocturnalAnimals.BodyClock_Description".Translate(), 2500)); }