Example #1
0
        public static void MultipliedAgeTick(ref int interval, Pawn_AgeTracker __instance)
        {
            //Find the pawn this tracker belongs to
            Pawn      pawn          = null;
            FieldInfo pawnFieldInfo = AccessTools.Field(__instance.GetType(), "pawn");

            if (pawnFieldInfo != null && pawnFieldInfo.FieldType.Equals(typeof(Verse.Pawn)))
            {
                pawn = (Verse.Pawn)pawnFieldInfo.GetValue(__instance);
            }

            if (pawn != null)
            {
                //Determine multiplier
                int multiplier = FasterAging.GetPawnAgingMultiplier(pawn);


                //Experimental Chronological age modification
                //I judge this too likely to cause issues and too practically insignificant to include as a default feature.
                if (FasterAging.modifyChronologicalAge)
                {
                    __instance.BirthAbsTicks -= (multiplier - 1) * interval; //Similar system to how the AgeTick patch works, just on the scale of the base interval rather than single ticks. Moves the pawn's birthday to correctly account for modified age rate.
                }


                //Edit the referenced interval value to take the multiplier into account.
                //The game will now run AgeTickMothballed() with this edited interval, accelerating or halting aging.
                interval = multiplier * interval;
            }
        }
Example #2
0
 public static void DailyRecalc(Pawn_AgeTracker __instance)
 {
     if (Find.TickManager.TicksGame % 60000 == 0)
     {
         //Log.Message("I have performed a daily check");
         MethodInfo info = AccessTools.Method(__instance.GetType(), "RecalculateLifeStageIndex", null, null);
         info.Invoke(__instance, null);
     }
 }