isaacscript-common
Version:
Helper functions and features for IsaacScript mods.
83 lines • 3.72 kB
TypeScript
import type { LevelStage, StageType } from "isaac-typescript-definitions";
import { Feature } from "../../private/Feature";
/**
* By default, callbacks fire in the following order:
* - `POST_NEW_ROOM` --> `POST_NEW_LEVEL` --> `POST_GAME_STARTED`
*
* It is easier to write mod code if the callbacks run in a more logical order:
* - `POST_GAME_STARTED` --> `POST_NEW_LEVEL` --> `POST_NEW_ROOM`
*
* `isaacscript-common` provides three new callbacks that change the order to this:
* - `POST_GAME_STARTED_REORDERED`
* - `POST_NEW_LEVEL_REORDERED`
* - `POST_NEW_ROOM_REORDERED`
*
* Additionally, there are some helper functions listed below that can deal with some edge cases
* that you may run into with these callbacks.
*/
export declare class GameReorderedCallbacks extends Feature {
/** Used to detect a player resuming a saved run. */
private renderFrameRunStarted;
private currentStage;
private currentStageType;
private usedGlowingHourGlass;
private forceNewLevel;
private forceNewRoom;
private readonly postGameStartedReordered;
private readonly postNewLevelReordered;
private readonly postNewRoomReordered;
private readonly postGameStartedReorderedLast;
private readonly postUseItemGlowingHourGlass;
private readonly postPlayerInit;
private readonly postGameStarted;
private readonly preGameExit;
private readonly postNewLevel;
private readonly postNewRoom;
private recordCurrentStage;
/**
* Helper function to tell the `POST_NEW_LEVEL_REORDERED` callback that it should always fire on
* the next `POST_NEW_LEVEL`.
*
* If some specific cases, mods can change the current level during run initialization on the 0th
* frame. (For example, if you had a mod that made the player start the run in Caves instead of
* Basement.) However, due to how the callback reordering works, the `POST_NEW_LEVEL_REORDERED`
* callback will never fire on the 0th frame. To get around this, call this function before
* changing levels to temporarily force the callback to fire.
*
* In order to use this function, you must upgrade your mod with
* `ISCFeature.GAME_REORDERED_CALLBACKS`.
*
* @public
*/
forceNewLevelCallback(): void;
/**
* Helper function to tell the `POST_NEW_ROOM_REORDERED` callback that it should always fire on
* the next `POST_NEW_ROOM`.
*
* If some specific cases, mods can change the current room during run initialization on the 0th
* frame. (For example, if you had a mod that made the player start the Treasure Room of Basement
* 1 instead of the normal starting room.) However, due to how the callback reordering works, the
* `POST_NEW_ROOM_REORDERED` callback will never fire on the 0th frame. To get around this, call
* this function before changing rooms to temporarily force the callback to fire.
*
* In order to use this function, you must upgrade your mod with
* `ISCFeature.GAME_REORDERED_CALLBACKS`.
*
* @public
*/
forceNewRoomCallback(): void;
/**
* Helper function to manually set the variables that the reordered callback logic uses to track
* the current stage and stage type.
*
* This is useful because if the stage is changed with the `Game.SetStage` method (or the
* `setStage` helper function), the reordered callbacks will stop working.
*
* In order to use this function, you must upgrade your mod with
* `ISCFeature.GAME_REORDERED_CALLBACKS`.
*
* @public
*/
reorderedCallbacksSetStage(stage: LevelStage, stageType: StageType): void;
}
//# sourceMappingURL=GameReorderedCallbacks.d.ts.map