Level Grid
These functions have to do with the room grid index for the level (i.e. the position that the room is on the grid that represents the map for the level).
For functions having to do with the grid index inside of the room, see the “Room Grid” functions.
Functions
Section titled “Functions”getAdjacentExistingRoomGridIndexes()
Section titled “getAdjacentExistingRoomGridIndexes()”getAdjacentExistingRoomGridIndexes(
roomGridIndex?): readonlyint[]
Defined in: packages/isaacscript-common/src/functions/levelGrid.ts:60
Helper function to get only the adjacent room grid indexes that exist (i.e. have room data).
This is just a filtering of the results of the getAdjacentExistingRoomGridIndexes function. See
that function for more information.
Parameters
Section titled “Parameters”roomGridIndex?
Section titled “roomGridIndex?”int
Optional. Default is the current room index.
Returns
Section titled “Returns”readonly int[]
getAdjacentNonExistingRoomGridIndexes()
Section titled “getAdjacentNonExistingRoomGridIndexes()”getAdjacentNonExistingRoomGridIndexes(
roomGridIndex?): readonlyint[]
Defined in: packages/isaacscript-common/src/functions/levelGrid.ts:76
Helper function to get only the adjacent room grid indexes that do not exist (i.e. do not have room data).
This is just a filtering of the results of the getAdjacentExistingRoomGridIndexes function. See
that function for more information.
Parameters
Section titled “Parameters”roomGridIndex?
Section titled “roomGridIndex?”int
Returns
Section titled “Returns”readonly int[]
getAdjacentRoomGridIndexes()
Section titled “getAdjacentRoomGridIndexes()”getAdjacentRoomGridIndexes(
roomGridIndex?): readonlyint[]
Defined in: packages/isaacscript-common/src/functions/levelGrid.ts:100
Helper function to get all of the room grid indexes that are adjacent to a given room grid index (even if those room grid indexes do not have any rooms in them).
Adjacent room grid indexes that are outside of the grid will not be included in the returned array.
If a room grid index is provided that is outside of the grid, then an empty array will be returned.
Note that this function does not take the shape of the room into account; it only looks at a single room grid index.
Parameters
Section titled “Parameters”roomGridIndex?
Section titled “roomGridIndex?”int
Optional. Default is the current room index.
Returns
Section titled “Returns”readonly int[]
getAllRoomGridIndexes()
Section titled “getAllRoomGridIndexes()”getAllRoomGridIndexes(): readonly
int[]
Defined in: packages/isaacscript-common/src/functions/levelGrid.ts:124
Helper function to get the room safe grid index for every room on the entire floor. This includes off-grid rooms, such as the Devil Room.
Rooms without any data are assumed to be non-existent and are not included.
Returns
Section titled “Returns”readonly int[]
getNewRoomCandidate()
Section titled “getNewRoomCandidate()”getNewRoomCandidate(
seedOrRNG,ensureDeadEnd?): {adjacentRoomGridIndex:int;doorSlot:DoorSlot;newRoomGridIndex:int; } |undefined
Defined in: packages/isaacscript-common/src/functions/levelGrid.ts:146
Helper function to pick a random valid spot on the floor to insert a brand new room. Note that some floors will not have any valid spots. If this is the case, this function will return undefined.
If you want to get an unseeded room, you must explicitly pass undefined to the seedOrRNG
parameter.
Parameters
Section titled “Parameters”seedOrRNG
Section titled “seedOrRNG”RNG | Seed | undefined
The Seed or RNG object to use. If an RNG object is provided, the
RNG.Next method will be called. If undefined is provided, it will default to
a random seed.
ensureDeadEnd?
Section titled “ensureDeadEnd?”boolean = true
Optional. Whether to pick a valid dead end attached to a normal room. If false, the function will randomly pick from any valid location that would have a red door.
Returns
Section titled “Returns”{ adjacentRoomGridIndex: int; doorSlot: DoorSlot; newRoomGridIndex: int; } | undefined
Either a tuple of adjacent room grid index, DoorSlot, and new room grid index, or
undefined.
getNewRoomCandidatesBesideRoom()
Section titled “getNewRoomCandidatesBesideRoom()”getNewRoomCandidatesBesideRoom(
roomGridIndex?,ensureDeadEnd?): readonlyobject[]
Defined in: packages/isaacscript-common/src/functions/levelGrid.ts:174
Helper function to iterate through the possible doors for a room and see if any of them would be a valid spot to insert a brand new room on the floor.
Parameters
Section titled “Parameters”roomGridIndex?
Section titled “roomGridIndex?”int
Optional. Default is the current room index.
ensureDeadEnd?
Section titled “ensureDeadEnd?”boolean = true
Optional. Whether to only include doors that lead to a valid dead end attached to a normal room. If false, the function will include all doors that would have a red door.
Returns
Section titled “Returns”readonly object[]
A array of tuples of DoorSlot and room grid index.
getNewRoomCandidatesForLevel()
Section titled “getNewRoomCandidatesForLevel()”getNewRoomCandidatesForLevel(
ensureDeadEnd?): readonlyobject[]
Defined in: packages/isaacscript-common/src/functions/levelGrid.ts:237
Helper function to get all of the spots on the floor to insert a brand new room.
Parameters
Section titled “Parameters”ensureDeadEnd?
Section titled “ensureDeadEnd?”boolean = true
Optional. Whether to only include spots that are a valid dead end attached to a normal room. If false, the function will include all valid spots that have a red door.
Returns
Section titled “Returns”readonly object[]
A array of tuples containing the adjacent room grid index, the DoorSlot, and the new
room grid index.
getRoomAdjacentGridIndexes()
Section titled “getRoomAdjacentGridIndexes()”getRoomAdjacentGridIndexes(
roomGridIndex?):ReadonlyMap<DoorSlot,int>
Defined in: packages/isaacscript-common/src/functions/levelGrid.ts:291
Helper function to get the grid indexes of all the rooms connected to the given room index, taking the shape of the room into account. (This will only include rooms with valid data.)
Returns an empty map if the provided room grid index is out of bounds or has no associated room data.
Parameters
Section titled “Parameters”roomGridIndex?
Section titled “roomGridIndex?”int
Optional. Default is the current room index.
Returns
Section titled “Returns”ReadonlyMap<DoorSlot, int>
A map of DoorSlot to the corresponding room grid index.
getRoomDescriptorsForType()
Section titled “getRoomDescriptorsForType()”getRoomDescriptorsForType(…
roomTypes): readonlyRoomDescriptor[]
Defined in: packages/isaacscript-common/src/functions/levelGrid.ts:320
Helper function to get an array of all of the room descriptors for rooms that match the specified room type.
This function only searches through rooms in the current dimension and rooms inside the grid.
This function is variadic, meaning that you can specify N arguments to get the combined room descriptors for N room types.
Parameters
Section titled “Parameters”roomTypes
Section titled “roomTypes”…readonly RoomType[]
Returns
Section titled “Returns”readonly RoomDescriptor[]
getRoomGridIndexesForType()
Section titled “getRoomGridIndexesForType()”getRoomGridIndexesForType(…
roomTypes): readonlyint[]
Defined in: packages/isaacscript-common/src/functions/levelGrid.ts:342
Helper function to get an array of all of the safe grid indexes for rooms that match the specified room type.
This function only searches through rooms in the current dimension.
This function is variadic, meaning that you can specify N arguments to get the combined grid indexes for N room types.
Parameters
Section titled “Parameters”roomTypes
Section titled “roomTypes”…readonly RoomType[]
Returns
Section titled “Returns”readonly int[]
getRoomShapeAdjacentExistingGridIndexes()
Section titled “getRoomShapeAdjacentExistingGridIndexes()”getRoomShapeAdjacentExistingGridIndexes(
safeRoomGridIndex,roomShape):ReadonlyMap<DoorSlot,int>
Defined in: packages/isaacscript-common/src/functions/levelGrid.ts:356
Helper function to get only the adjacent room grid indexes for a room shape that exist (i.e. have room data).
This is just a filtering of the results of the getRoomShapeAdjacentGridIndexes function. See
that function for more information.
Parameters
Section titled “Parameters”safeRoomGridIndex
Section titled “safeRoomGridIndex”int
roomShape
Section titled “roomShape”RoomShape
Returns
Section titled “Returns”ReadonlyMap<DoorSlot, int>
getRoomShapeAdjacentGridIndexDeltas()
Section titled “getRoomShapeAdjacentGridIndexDeltas()”getRoomShapeAdjacentGridIndexDeltas(
roomShape):ReadonlyMap<DoorSlot,int>
Defined in: packages/isaacscript-common/src/functions/levelGrid.ts:382
Helper function to get the room grid index delta that each hypothetical door in a given room shape would go to.
This is used by the getRoomShapeAdjacentGridIndexes function.
Parameters
Section titled “Parameters”roomShape
Section titled “roomShape”RoomShape
Returns
Section titled “Returns”ReadonlyMap<DoorSlot, int>
A map of DoorSlot to the corresponding room grid index delta.
getRoomShapeAdjacentGridIndexes()
Section titled “getRoomShapeAdjacentGridIndexes()”getRoomShapeAdjacentGridIndexes(
safeRoomGridIndex,roomShape):ReadonlyMap<DoorSlot,int>
Defined in: packages/isaacscript-common/src/functions/levelGrid.ts:397
Helper function to get the room grid index that each hypothetical door in a given room shape would go to. (This will not include room grid indexes that are outside of the grid.)
Parameters
Section titled “Parameters”safeRoomGridIndex
Section titled “safeRoomGridIndex”int
This must be the room safe grid index (i.e. the top-left room grid index for the respective room).
roomShape
Section titled “roomShape”RoomShape
The shape of the hypothetical room.
Returns
Section titled “Returns”ReadonlyMap<DoorSlot, int>
A map of DoorSlot to the corresponding room grid index.
getRoomShapeAdjacentNonExistingGridIndexes()
Section titled “getRoomShapeAdjacentNonExistingGridIndexes()”getRoomShapeAdjacentNonExistingGridIndexes(
safeRoomGridIndex,roomShape):ReadonlyMap<DoorSlot,int>
Defined in: packages/isaacscript-common/src/functions/levelGrid.ts:422
Helper function to get only the adjacent room grid indexes for a room shape that do not exist (i.e. do not have room data).
This is just a filtering of the results of the getRoomShapeAdjacentGridIndexes function. See
that function for more information.
Parameters
Section titled “Parameters”safeRoomGridIndex
Section titled “safeRoomGridIndex”int
roomShape
Section titled “roomShape”RoomShape
Returns
Section titled “Returns”ReadonlyMap<DoorSlot, int>
inGrid()
Section titled “inGrid()”inGrid():
boolean
Defined in: packages/isaacscript-common/src/functions/levelGrid.ts:446
Helper function to determine if the current room grid index is inside of the normal 13x13 level grid.
For example, Devil Rooms and the Mega Satan room are not considered to be inside the grid.
Returns
Section titled “Returns”boolean
inRedKeyRoom()
Section titled “inRedKeyRoom()”inRedKeyRoom():
boolean
Defined in: packages/isaacscript-common/src/functions/levelGrid.ts:456
Helper function to detect if the current room was created by the Red Key item.
Under the hood, this checks for the RoomDescriptorFlag.FLAG_RED_ROOM flag.
Returns
Section titled “Returns”boolean
isDeadEnd()
Section titled “isDeadEnd()”isDeadEnd(
roomGridIndex?):boolean
Defined in: packages/isaacscript-common/src/functions/levelGrid.ts:473
Helper function to check if the given room grid index is a dead end. Specifically, this is defined as having only one adjacent room that exists.
Note that this function does not take the shape of the room into account; it only looks at a single room grid index.
This function does not care if the given room grid index actually exists, so you can use it to check if a hypothetical room would be a dead end.
Parameters
Section titled “Parameters”roomGridIndex?
Section titled “roomGridIndex?”int
Optional. Default is the current room index.
Returns
Section titled “Returns”boolean
isDoorSlotValidAtGridIndex()
Section titled “isDoorSlotValidAtGridIndex()”isDoorSlotValidAtGridIndex(
doorSlot,roomGridIndex):boolean
Defined in: packages/isaacscript-common/src/functions/levelGrid.ts:480
Parameters
Section titled “Parameters”doorSlot
Section titled “doorSlot”DoorSlot
roomGridIndex
Section titled “roomGridIndex”int
Returns
Section titled “Returns”boolean
isDoorSlotValidAtGridIndexForRedRoom()
Section titled “isDoorSlotValidAtGridIndexForRedRoom()”isDoorSlotValidAtGridIndexForRedRoom(
doorSlot,roomGridIndex):boolean
Defined in: packages/isaacscript-common/src/functions/levelGrid.ts:488
Parameters
Section titled “Parameters”doorSlot
Section titled “doorSlot”DoorSlot
roomGridIndex
Section titled “roomGridIndex”int
Returns
Section titled “Returns”boolean
isRedKeyRoom()
Section titled “isRedKeyRoom()”isRedKeyRoom(
roomGridIndex):boolean
Defined in: packages/isaacscript-common/src/functions/levelGrid.ts:521
Helper function to detect if the provided room was created by the Red Key item.
Under the hood, this checks for the RoomDescriptorFlag.FLAG_RED_ROOM flag.
Parameters
Section titled “Parameters”roomGridIndex
Section titled “roomGridIndex”int
Optional. Default is the current room index.
Returns
Section titled “Returns”boolean
isRoomInsideGrid()
Section titled “isRoomInsideGrid()”isRoomInsideGrid(
roomGridIndex?):boolean
Defined in: packages/isaacscript-common/src/functions/levelGrid.ts:533
Helper function to determine if a given room grid index is inside of the normal 13x13 level grid.
For example, Devil Rooms and the Mega Satan room are not considered to be inside the grid.
Parameters
Section titled “Parameters”roomGridIndex?
Section titled “roomGridIndex?”int
Optional. Default is the current room index.
Returns
Section titled “Returns”boolean
newRoom()
Section titled “newRoom()”newRoom(
seedOrRNG,ensureDeadEnd?,customRoomData?):int|undefined
Defined in: packages/isaacscript-common/src/functions/levelGrid.ts:561
Helper function to generate a new room on the floor.
If you want to generate an unseeded room, you must explicitly pass undefined to the seedOrRNG
parameter.
Under the hood, this function uses the Level.MakeRedRoomDoor method to create the room.
Parameters
Section titled “Parameters”seedOrRNG
Section titled “seedOrRNG”RNG | Seed | undefined
The Seed or RNG object to use. If an RNG object is provided, the
RNG.Next method will be called. Default is Level.GetDungeonPlacementSeed.
Note that the RNG is only used to select the random location to put the room on
the floor; it does not influence the randomly chosen room contents. (That is
performed by the game and can not be manipulated prior to its generation.)
ensureDeadEnd?
Section titled “ensureDeadEnd?”boolean = true
Optional. Whether to place the room at a valid dead end attached to a normal room. If false, it will randomly appear at any valid location that would have a red door.
customRoomData?
Section titled “customRoomData?”RoomConfig
Optional. By default, the newly created room will have data corresponding to the game’s randomly generated red room. If you provide this function with room data, it will be used to override the vanilla data.
Returns
Section titled “Returns”int | undefined
The room grid index of the new room or undefined if the floor had no valid dead ends to place a room.
roomExists()
Section titled “roomExists()”roomExists(
roomGridIndex):boolean
Defined in: packages/isaacscript-common/src/functions/levelGrid.ts:620
Helper function to check if a room exists at the given room grid index. (A room will exist if it has non-undefined data in the room descriptor.)
Parameters
Section titled “Parameters”roomGridIndex
Section titled “roomGridIndex”int
Returns
Section titled “Returns”boolean
roomGridIndexToVector()
Section titled “roomGridIndexToVector()”roomGridIndexToVector(
roomGridIndex):Readonly<Vector>
Defined in: packages/isaacscript-common/src/functions/levelGrid.ts:636
Helper function to get the coordinates of a given room grid index. The floor is represented by a 13x13 grid.
- Since the starting room is in the center, the starting room grid index of 84 is equal to coordinates of (6, 6).
- The top-left grid index of 0 is equal to coordinates of: (12, 0)
- The top-right grid index of 12 is equal to coordinates of: (0, 0)
- The bottom-left grid index of 156 is equal to coordinates of: (0, 12)
- The bottom-right grid index of 168 is equal to coordinates of: (12, 12)
Parameters
Section titled “Parameters”roomGridIndex
Section titled “roomGridIndex”int
Returns
Section titled “Returns”Readonly<Vector>
vectorToRoomGridIndex()
Section titled “vectorToRoomGridIndex()”vectorToRoomGridIndex(
roomVector):int
Defined in: packages/isaacscript-common/src/functions/levelGrid.ts:648
Helper function to convert a room grid index expressed as a vector back into an integer.
Also see the roomGridIndexToVector helper function.
Parameters
Section titled “Parameters”roomVector
Section titled “roomVector”Vector
Returns
Section titled “Returns”int
