Example #1
0
        public static bool Prefix_PlayerActor_ElapseTime(PlayerActor __instance,
                                                         Func <bool> conditionBefore,
                                                         Func <bool> conditionAfter = null)
        {
            if (sleepPatch)
            {
                sleepPatch = false;

                return(true);
            }

            sleepPatch = true;

            __instance.ElapseTime(
                () =>
            {
                bool flag = true;

                if (conditionBefore != null)
                {
                    flag = conditionBefore();
                }

                if (flag)
                {
                    Sleep.asleep = true;

                    Sleep.SetSleepThresholds(Sleep.thresholdsNew);
                    Sleep.SetWakeTime();
                }

                return(flag);
            },
                () =>
            {
                Sleep.asleep = false;

                Sleep.SetSleepThresholds(Sleep.thresholdsBackup);
                Sleep.ResetWakeTime();

                if (conditionAfter != null)
                {
                    return(conditionAfter());
                }

                return(true);
            }
                );

            return(false);
        }
Example #2
0
        public static bool Prefix_PlayerActor_ElapseTime(PlayerActor __instance,
                                                         Action action,
                                                         bool fadeOut = true)
        {
            __instance.ElapseTime(
                () =>
            {
                action?.Invoke();

                return(true);
            },
                null
                );

            return(false);
        }