UNPKG

isaacscript-common

Version:

Helper functions and features for IsaacScript mods.

68 lines (67 loc) 2.59 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.FadeInRemover = void 0; const cachedClasses_1 = require("../../../core/cachedClasses"); const decorators_1 = require("../../../decorators"); const ModCallbackCustom_1 = require("../../../enums/ModCallbackCustom"); const Feature_1 = require("../../private/Feature"); const INSTANT_FADE_IN_SPEED = 1; class FadeInRemover extends Feature_1.Feature { enabled = false; /** @internal */ constructor() { super(); this.customCallbacksUsed = [ [ ModCallbackCustom_1.ModCallbackCustom.POST_GAME_STARTED_REORDERED, this.postGameStartedReordered, [undefined], ], ]; } // ModCallbackCustom.POST_GAME_STARTED_REORDERED postGameStartedReordered = () => { if (this.enabled) { cachedClasses_1.game.Fadein(INSTANT_FADE_IN_SPEED); } }; /** * Removes the fade-in that occurs at the beginning of a run. If this behavior is desired, call * this function once at the beginning of your mod. * * This is useful for debugging, when you are resetting the game often. * * You can restore the vanilla behavior with the `restoreFadeIn` function. * * In order to use this function, you must upgrade your mod with `ISCFeature.FADE_IN_REMOVER`. * * @public */ removeFadeIn() { this.enabled = true; } /** * Disables the fade-in remover. Only useful if you have previously called the `removeFadeIn` * function. * * In order to use this function, you must upgrade your mod with `ISCFeature.FADE_IN_REMOVER`. * * @public */ restoreFadeIn() { this.enabled = false; } } exports.FadeInRemover = FadeInRemover; __decorate([ decorators_1.Exported ], FadeInRemover.prototype, "removeFadeIn", null); __decorate([ decorators_1.Exported ], FadeInRemover.prototype, "restoreFadeIn", null);