コード例 #1
0
        public void HookStuff()
        {
            if (stuffIsHooked)
            {
                return;
            }

            Logger.Log("ExtendedVariantMode/ExtendedVariantsModule", $"Loading variant common methods...");
            On.Celeste.AreaComplete.VersionNumberAndVariants += modVersionNumberAndVariants;
            Everest.Events.Level.OnExit                   += onLevelExit;
            On.Celeste.BadelineBoost.BoostRoutine         += modBadelineBoostRoutine;
            On.Celeste.CS00_Ending.OnBegin                += onPrologueEndingCutsceneBegin;
            Everest.Events.Level.OnCreatePauseMenuButtons += onCreatePauseMenuButtons;
            hookOnVersionNumberAndVariants                 = new ILHook(typeof(AreaComplete).GetMethod("orig_VersionNumberAndVariants"), ilModVersionNumberAndVariants);

            On.Celeste.Level.LoadLevel       += onLoadLevel;
            On.Celeste.Level.EndPauseEffects += onUnpause;
            On.Celeste.Level.End             += onLevelEnd;

            Logger.Log("ExtendedVariantMode/ExtendedVariantsModule", $"Loading variant randomizer...");
            Randomizer.Load();

            foreach (Variant variant in VariantHandlers.Keys)
            {
                Logger.Log("ExtendedVariantMode/ExtendedVariantsModule", $"Loading variant {variant}...");
                VariantHandlers[variant].Load();
            }

            LeakPreventionHack.Load();

            Logger.Log(LogLevel.Info, "ExtendedVariantMode/ExtendedVariantsModule", "Done hooking stuff.");

            stuffIsHooked = true;
        }
コード例 #2
0
        public void UnhookStuff()
        {
            if (!stuffIsHooked)
            {
                return;
            }

            Logger.Log("ExtendedVariantMode/ExtendedVariantsModule", $"Unloading variant common methods...");
            On.Celeste.AreaComplete.VersionNumberAndVariants -= modVersionNumberAndVariants;
            Everest.Events.Level.OnExit                   -= onLevelExit;
            On.Celeste.BadelineBoost.BoostRoutine         -= modBadelineBoostRoutine;
            On.Celeste.CS00_Ending.OnBegin                -= onPrologueEndingCutsceneBegin;
            Everest.Events.Level.OnCreatePauseMenuButtons -= onCreatePauseMenuButtons;
            hookOnVersionNumberAndVariants?.Dispose();
            hookOnVersionNumberAndVariants = null;

            On.Celeste.Level.LoadLevel       -= onLoadLevel;
            On.Celeste.Level.EndPauseEffects -= onUnpause;
            On.Celeste.Level.End             -= onLevelEnd;

            // unset flags
            onLevelExit();

            Logger.Log("ExtendedVariantMode/ExtendedVariantsModule", $"Unloading variant randomizer...");
            Randomizer.Unload();

            foreach (Variant variant in VariantHandlers.Keys)
            {
                Logger.Log("ExtendedVariantMode/ExtendedVariantsModule", $"Unloading variant {variant}...");
                VariantHandlers[variant].Unload();
            }

            LeakPreventionHack.Unload();

            Logger.Log(LogLevel.Info, "ExtendedVariantMode/ExtendedVariantsModule", "Done unhooking stuff.");

            stuffIsHooked = false;
        }