UNPKG

isaacscript-common

Version:

Helper functions and features for IsaacScript mods.

416 lines • 21.1 kB
import type { BackdropType, BossID, ItemPoolType, MinibossID, RoomShape } from "isaac-typescript-definitions"; import { Dimension, RoomType } from "isaac-typescript-definitions"; /** * Helper function for quickly switching to a new room without playing a particular animation. Use * this helper function over invoking the `Game.ChangeRoom` method directly to ensure that you do * not forget to set the `LeaveDoor` field and to prevent crashing on invalid room grid indexes. */ export declare function changeRoom(roomGridIndex: int): void; /** * Helper function to get the number of rooms that are currently on the floor layout. This does not * include off-grid rooms, like the Devil Room. */ export declare function getNumRooms(): int; /** * Helper function to get a read-only copy of the room descriptor for every room on the level. This * includes off-grid rooms, such as the Devil Room, and extra-dimensional rooms, if they are * generated and exist. * * Room descriptors without any data are assumed to be non-existent and are not included. * * Under the hood, this is performed by iterating over the `RoomList` from the `Level.GetRooms` * method. This is the best way to see if off-grid rooms have been initialized, since it is possible * for mods to insert room data at non-official negative room grid indexes. */ export declare function getReadOnlyRooms(): ReadonlyArray<Readonly<RoomDescriptor>>; /** * Helper function to get the room data for a specific room type and variant combination. This is * accomplished by using the "goto" console command to load the specified room into the * `GridRoom.DEBUG` slot. * * Returns undefined if the provided room type and variant combination were not found. (A warning * message will also appear on the console, since the "goto" command will fail.) * * Note that the side effect of using the "goto" console command is that it will trigger a room * transition after a short delay. By default, this function cancels the incoming room transition by * using the `Game.StartRoomTransition` method to travel to the same room. * * @param roomType The type of room to retrieve. * @param roomVariant The room variant to retrieve. (The room variant is the "ID" of the room in * Basement Renovator.) * @param cancelRoomTransition Optional. Whether to cancel the room transition by using the * `Game.StartRoomTransition` method to travel to the same room. Default * is true. Set this to false if you are getting the data for many rooms * at the same time, and then use the `teleport` helper function when * you are finished. * @param useSpecialRoomsForRoomTypeDefault Optional. Whether to use `s.default` as the prefix for * the `goto` command (instead of `d`) if the room type is * `RoomType.DEFAULT` (1). False by default. */ export declare function getRoomDataForTypeVariant(roomType: RoomType, roomVariant: int, cancelRoomTransition?: boolean, useSpecialRoomsForRoomTypeDefault?: boolean): Readonly<RoomConfig> | undefined; /** * Helper function to get the item pool type for the current room. For example, this returns * `ItemPoolType.ItemPoolType.POOL_ANGEL` if you are in an Angel Room. */ export declare function getRoomItemPoolType(): ItemPoolType; /** * Helper function to get the proper name of a room type. * * For example, `RoomType.TREASURE` will return "Treasure Room". */ export declare function getRoomTypeName(roomType: RoomType): string; /** * Helper function to get the room descriptor for every room on the level. This includes off-grid * rooms, such as the Devil Room. * * Room without any data are assumed to be non-existent and are not included. * * - If you want just the rooms inside of the grid, use the `getRoomsInsideGrid` helper function. * - If you want just the rooms outside of the grid, use the `getRoomsOutsideGrid` helper function. * * @param includeExtraDimensionalRooms Optional. On some floors (e.g. Downpour 2, Mines 2), * extra-dimensional rooms are automatically generated. Default is * false. */ export declare function getRooms(includeExtraDimensionalRooms?: boolean): readonly RoomDescriptor[]; /** * Helper function to get the room descriptor for every room on the level that is on the grid. (For * example, Devil Rooms are excluded.) * * Room descriptors without any data are assumed to be non-existent and are not included. * * @param includeExtraDimensionalRooms Optional. On some floors (e.g. Downpour 2, Mines 2), * extra-dimensional rooms will be generated. Default is false. */ export declare function getRoomsInsideGrid(includeExtraDimensionalRooms?: boolean): readonly RoomDescriptor[]; /** * Helper function to get the room descriptor for every room on the level in a specific dimension. * This will not include any off-grid rooms, such as the Devil Room. * * Room descriptors without any data are assumed to be non-existent and are not included. */ export declare function getRoomsOfDimension(dimension: Dimension): readonly RoomDescriptor[]; /** * Helper function to get the room descriptor for every room on the level that is outside of the * grid (like a Devil Room). * * Room descriptors without any data are assumed to be non-existent and are not included. */ export declare function getRoomsOutsideGrid(): readonly RoomDescriptor[]; /** * Helper function to determine if the current room shape is equal to `RoomShape.1x2` or * `RoomShape.2x1`. */ export declare function in2x1Room(): boolean; /** * Helper function to check to see if the current room is an angel shop. * * Under the hood, this checks the room type being equal to `RoomType.ANGEL` (15) and the sub-type * being equal to `AngelRoomSubType.SHOP` (1). */ export declare function inAngelShop(): boolean; /** * Helper function to check to see if the current room is the Boss Room for The Beast. * * This function is useful because the `Room.GetBossID` method returns 0 for The Beast room. * * Under the hood, this checks the room type being equal to `RoomType.DUNGEON` (16) and the sub-type * being equal to `DungeonSubType.BEAST_ROOM` (4). */ export declare function inBeastRoom(): boolean; /** * Helper function to detect if the current room is big. Specifically, this is all 1x2 rooms, 2x2 * rooms, and L rooms. */ export declare function inBigRoom(): boolean; /** * Helper function to check if the current room is the Boss Room for a particular boss. This will * only work for bosses that have dedicated boss rooms in the "00.special rooms.stb" file. */ export declare function inBossRoomOf(bossID: BossID): boolean; /** * Helper function for determining whether the current room is a crawl space. Use this function over * comparing to `RoomType.DUNGEON` or `GridRoom.DUNGEON_IDX` since there is a special case of the * player being in a boss fight that takes place in a dungeon. */ export declare function inCrawlSpace(): boolean; /** * Helper function for checking whether the current room is a crawl space with a door corresponding * to `DoorSlotFlag.RIGHT_0` (1 << 2). */ export declare function inCrawlSpaceWithBlackMarketEntrance(): boolean; /** * Helper function to detect if the current room is one of the rooms in the Death Certificate area. */ export declare function inDeathCertificateArea(): boolean; /** * Helper function to detect if the current room is a Treasure Room created when entering with a * Devil's Crown trinket. * * Under the hood, this checks for `RoomDescriptorFlag.DEVIL_TREASURE`. */ export declare function inDevilsCrownTreasureRoom(): boolean; /** * Helper function to check to see if the current room is the Boss Room for Dogma. * * This function is useful because the `Room.GetBossID` method returns 0 for the Dogma room. * * Note that the "living room" on the Home floor with the TV at the top of the room is not the Dogma * Boss Room, as the player is teleported to a different room after watching the TV cutscene. * * Under the hood, this checks the stage ID being equal to `StageID.HOME` (35) and the room type * being equal to `RoomType.DEFAULT` (1) and the variant being equal to 1000 (which is the only * Dogma Boss Room that exists in vanilla) and the sub-type being equal to * `HomeRoomSubType.LIVING_ROOM` (3). */ export declare function inDogmaRoom(): boolean; /** * Helper function to detect if the current room is a Double Trouble Boss Room. * * This is performed by checking for the string "Double Trouble" inside of the room name. The * vanilla game uses this convention for every Double Trouble Boss Room. Note that this method might * fail for mods that add extra Double Trouble rooms but do not follow the convention. * * Internally, the game is coded to detect Double Trouble Boss Rooms by checking for the variant * range of 3700 through 3850. We intentionally do not use this method since it may not work as well * with modded rooms. */ export declare function inDoubleTrouble(): boolean; /** Helper function to determine if the current room index is equal to `GridRoom.GENESIS`. */ export declare function inGenesisRoom(): boolean; /** * Helper function to check if the current room is either the left Home closet (behind the red door) * or the right Home closet (with one random pickup). * * Home closets have a unique shape that is different from any other room in the game. */ export declare function inHomeCloset(): boolean; /** Helper function to determine if the current room shape is one of the four L room shapes. */ export declare function inLRoom(): boolean; /** Helper function to determine if the current room index is equal to `GridRoom.MEGA_SATAN`. */ export declare function inMegaSatanRoom(): boolean; /** * Helper function to determine if the current room is part of the Repentance "escape sequence" in * the Mines/Ashpit. */ export declare function inMineShaft(): boolean; /** * Helper function to check if the current room is a miniboss room for a particular miniboss. This * will only work for mini-bosses that have dedicated boss rooms in the "00.special rooms.stb" file. */ export declare function inMinibossRoomOf(minibossID: MinibossID): boolean; /** * Helper function to check if the current room is a "mirror room" in Downpour or Dross. (These * rooms are marked with a specific sub-type.) */ export declare function inMirrorRoom(): boolean; /** * Helper function to check if the current room shape matches one of the given room shapes. * * This function is variadic, which means you can pass as many room shapes as you want to match for. */ export declare function inRoomShape(...roomShapes: readonly RoomShape[]): boolean; /** * Helper function to check if the current room matches one of the given room types. * * This function is variadic, which means you can pass as many room types as you want to match for. */ export declare function inRoomType(...roomTypes: readonly RoomType[]): boolean; /** * Helper function for checking if the current room is a secret exit that leads to a Repentance * floor. */ export declare function inSecretExit(): boolean; /** * Helper function for checking if the current room is a secret shop (from the Member Card * collectible). * * Secret shops are simply copies of normal shops, but with the backdrop of a secret room. In other * words, they will have the same room type, room variant, and room sub-type of a normal shop. Thus, * the only way to detect them is by using the grid index. */ export declare function inSecretShop(): boolean; /** * Helper function to determine whether the current room is the starting room of a floor. It only * returns true for the starting room of the primary dimension (meaning that being in the starting * room of the mirror world does not count). */ export declare function inStartingRoom(): boolean; /** * Helper function to determine if the provided room is equal to `RoomShape.1x2` or `RoomShape.2x1`. */ export declare function is2x1Room(roomData: RoomConfig): boolean; /** * Helper function to loop through every room on the floor and see if it has been cleared. * * This function will only check rooms inside the grid and inside the current dimension. * * @param onlyCheckRoomTypes Optional. A whitelist of room types. If specified, room types not in * the array will be ignored. If not specified, then all rooms will be * checked. Undefined by default. * @param includeSecretRoom Optional. Whether to include the Secret Room. Default is false. * @param includeSuperSecretRoom Optional. Whether to include the Super Secret Room. Default is * false. * @param includeUltraSecretRoom Optional. Whether to include the Ultra Secret Room. Default is * false. * @allowEmptyVariadic */ export declare function isAllRoomsClear(onlyCheckRoomTypes?: readonly RoomType[], includeSecretRoom?: boolean, includeSuperSecretRoom?: boolean, includeUltraSecretRoom?: boolean): boolean; /** * Helper function to check to see if the current room is an angel shop. * * Under the hood, this checks the room type being equal to `RoomType.ANGEL` (15) and the sub-type * being equal to `AngelRoomSubType.SHOP` (1). */ export declare function isAngelShop(roomData: RoomConfig): boolean; /** * Helper function to check to see if the provided room is the Boss Room for The Beast. * * This function is useful because the `Room.GetBossID` method returns 0 for The Beast room. * * Under the hood, this checks the room type being equal to `RoomType.DUNGEON` (16) and the sub-type * being equal to `DungeonSubType.BEAST_ROOM` (4). */ export declare function isBeastRoom(roomData: RoomConfig): boolean; /** * Helper function to detect if the provided room is big. Specifically, this is all 1x2 rooms, 2x2 * rooms, and L rooms. */ export declare function isBigRoom(roomData: RoomConfig): boolean; /** * Helper function to check if the provided room is the Boss Room for a particular boss. This will * only work for bosses that have dedicated boss rooms in the "00.special rooms.stb" file. */ export declare function isBossRoomOf(roomData: RoomConfig, bossID: BossID): boolean; /** * Helper function for determining whether the provided room is a crawl space. Use this function * over comparing to `RoomType.DUNGEON` or `GridRoom.DUNGEON_IDX` since there is a special case of * the player being in a boss fight that takes place in a dungeon. */ export declare function isCrawlSpace(roomData: RoomConfig): boolean; /** * Helper function for checking whether the provided room is a crawl space with a door corresponding * to `DoorSlotFlag.RIGHT_0` (1 << 2). */ export declare function isCrawlSpaceWithBlackMarketEntrance(roomData: RoomConfig): boolean; /** * Helper function to detect if the provided room is one of the rooms in the Death Certificate area. */ export declare function isDeathCertificateArea(roomData: RoomConfig): boolean; /** * Helper function to detect if the provided room is a Treasure Room created when entering with a * Devil's Crown trinket. * * Under the hood, this checks for `RoomDescriptorFlag.DEVIL_TREASURE`. */ export declare function isDevilsCrownTreasureRoom(roomDescriptor: RoomDescriptor): boolean; /** * Helper function to check to see if the provided room is the Boss Room for Dogma. * * This function is useful because the `Room.GetBossID` method returns 0 for the Dogma room. * * Note that the "living room" on the Home floor with the TV at the top of the room is not the Dogma * Boss Room, as the player is teleported to a different room after watching the TV cutscene. * * Under the hood, this checks the stage ID being equal to `StageID.HOME` (35) and the room type * being equal to `RoomType.DEFAULT` (1) and the variant being equal to 1000 (which is the only * Dogma Boss Room that exists in vanilla) and the sub-type being equal to * `HomeRoomSubType.LIVING_ROOM` (3). */ export declare function isDogmaRoom(roomData: RoomConfig): boolean; /** * Helper function to detect if the provided room is a Double Trouble Boss Room. * * This is performed by checking for the string "Double Trouble" inside of the room name. The * vanilla game uses this convention for every Double Trouble Boss Room. Note that this method might * fail for mods that add extra Double Trouble rooms but do not follow the convention. * * Internally, the game is coded to detect Double Trouble Boss Rooms by checking for the variant * range of 3700 through 3850. We intentionally do not use this method since it may not work as well * with modded rooms. */ export declare function isDoubleTrouble(roomData: RoomConfig): boolean; /** * Helper function to determine if the index of the provided room is equal to `GridRoom.GENESIS`. */ export declare function isGenesisRoom(roomGridIndex: int): boolean; /** * Helper function to check if the provided room is either the left Home closet (behind the red * door) or the right Home closet (with one random pickup). * * Home closets have a unique shape that is different from any other room in the game. */ export declare function isHomeCloset(roomData: RoomConfig): boolean; /** Helper function to determine if the provided room is one of the four L room shapes. */ export declare function isLRoom(roomData: RoomConfig): boolean; /** * Helper function to determine if the index of the provided room is equal to `GridRoom.MEGA_SATAN`. */ export declare function isMegaSatanRoom(roomGridIndex: int): boolean; /** * Helper function to determine if the provided room is part of the Repentance "escape sequence" in * the Mines/Ashpit. */ export declare function isMineShaft(roomData: RoomConfig): boolean; /** * Helper function to check if the provided room is a miniboss room for a particular miniboss. This * will only work for mini-bosses that have dedicated boss rooms in the "00.special rooms.stb" file. */ export declare function isMinibossRoomOf(roomData: RoomConfig, minibossID: MinibossID): boolean; /** * Helper function to check if the provided room is a "mirror room" in Downpour or Dross. (These * rooms are marked with a specific sub-type.) */ export declare function isMirrorRoom(roomData: RoomConfig): boolean; /** * Helper function to check if the provided room matches one of the given room shapes. * * This function is variadic, which means you can pass as many room shapes as you want to match for. */ export declare function isRoomShape(roomData: RoomConfig, ...roomShapes: readonly RoomShape[]): boolean; /** * Helper function to check if the provided room matches one of the given room types. * * This function is variadic, which means you can pass as many room types as you want to match for. */ export declare function isRoomType(roomData: RoomConfig, ...roomTypes: readonly RoomType[]): boolean; /** * Helper function for checking if the provided room is a secret exit that leads to a Repentance * floor. */ export declare function isSecretExit(roomGridIndex: int): boolean; /** * Helper function to detect if a room type is a Secret Room, a Super Secret Room, or an Ultra * Secret Room. */ export declare function isSecretRoomType(roomType: RoomType): boolean; /** * Helper function for checking if the provided room is a secret shop (from the Member Card * collectible). * * Secret shops are simply copies of normal shops, but with the backdrop of a secret room. In other * words, they will have the same room type, room variant, and room sub-type of a normal shop. Thus, * the only way to detect them is by using the grid index. */ export declare function isSecretShop(roomGridIndex: int): boolean; /** * If the `Room.Update` method is called in a `POST_NEW_ROOM` callback, then some entities will * slide around (such as the player). Since those entity velocities are already at zero, setting * them to zero will have no effect. Thus, a generic solution is to record all of the entity * positions/velocities before updating the room, and then restore those positions/velocities. */ export declare function roomUpdateSafe(): void; /** Helper function to set the backdrop (i.e. background) of the current room. */ export declare function setBackdrop(backdropType: BackdropType): void; /** * Helper function to convert an uncleared room to a cleared room in the `POST_NEW_ROOM` callback. * This is useful because if enemies are removed in this callback, a room drop will be awarded and * the doors will start closed and then open. */ export declare function setRoomCleared(): void; /** * Helper function to emulate what happens when you bomb an Angel Statue or push a Reward Plate that * spawns an NPC. */ export declare function setRoomUncleared(): void; //# sourceMappingURL=rooms.d.ts.map