UNPKG

isaacscript-common

Version:

Helper functions and features for IsaacScript mods.

61 lines (60 loc) 2.34 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.RunNextRun = void 0; const decorators_1 = require("../../../decorators"); const ModCallbackCustom_1 = require("../../../enums/ModCallbackCustom"); const array_1 = require("../../../functions/array"); const Feature_1 = require("../../private/Feature"); const v = { persistent: { queuedFunctions: [], }, }; class RunNextRun extends Feature_1.Feature { /** @internal */ v = v; vConditionalFunc = () => false; /** @internal */ constructor() { super(); this.customCallbacksUsed = [ [ ModCallbackCustom_1.ModCallbackCustom.POST_GAME_STARTED_REORDERED, this.postGameStartedReorderedFalse, [false], ], ]; } // ModCallbackCustom.POST_GAME_STARTED_REORDERED // false postGameStartedReorderedFalse = () => { for (const func of v.persistent.queuedFunctions) { func(); } (0, array_1.emptyArray)(v.persistent.queuedFunctions); }; /** * Supply a function to run on the next `POST_GAME_STARTED` callback. * * Note that this function will not handle saving and quitting. If a player saving and quitting * before the deferred function fires would cause a bug in your mod, then you should handle * deferred functions manually using serializable data. * * In order to use this function, you must upgrade your mod with `ISCFeature.RUN_NEXT_ROOM`. * * @public */ runNextRun(func) { v.persistent.queuedFunctions.push(func); } } exports.RunNextRun = RunNextRun; __decorate([ decorators_1.Exported ], RunNextRun.prototype, "runNextRun", null);