Grid Entities
Functions
Section titled “Functions”convertXMLGridEntityType()
Section titled “convertXMLGridEntityType()”convertXMLGridEntityType(
gridEntityXMLType,gridEntityXMLVariant): [GridEntityType,int] |undefined
Defined in: packages/isaacscript-common/src/functions/gridEntities.ts:70
Helper function to convert the grid entity type found in a room XML file to the corresponding
grid entity type and variant normally used by the game. For example, GridEntityXMLType.ROCK is
1000 (in a room XML file), but GridEntityType.ROCK is equal to 2 (in-game).
Parameters
Section titled “Parameters”gridEntityXMLType
Section titled “gridEntityXMLType”GridEntityXMLType
gridEntityXMLVariant
Section titled “gridEntityXMLVariant”int
Returns
Section titled “Returns”[GridEntityType, int] | undefined
doesGridEntityExist()
Section titled “doesGridEntityExist()”doesGridEntityExist(
gridEntityType,variant?):boolean
Defined in: packages/isaacscript-common/src/functions/gridEntities.ts:97
Helper function to check if one or more of a specific kind of grid entity is present in the current room.
Parameters
Section titled “Parameters”gridEntityType
Section titled “gridEntityType”GridEntityType
The grid entity type to match.
variant?
Section titled “variant?”number = -1
Optional. Default is -1, which matches every variant.
Returns
Section titled “Returns”boolean
getAllGridIndexes()
Section titled “getAllGridIndexes()”getAllGridIndexes(): readonly
int[]
Defined in: packages/isaacscript-common/src/functions/gridEntities.ts:124
Helper function to get every legal grid index for the current room.
Under the hood, this uses the Room.GetGridSize method.
Returns
Section titled “Returns”readonly int[]
getCollidingEntitiesWithGridEntity()
Section titled “getCollidingEntitiesWithGridEntity()”getCollidingEntitiesWithGridEntity(
gridEntity): readonlyEntity[]
Defined in: packages/isaacscript-common/src/functions/gridEntities.ts:141
Gets the entities that have a hitbox that overlaps with any part of the square that the grid entity is on.
This function is useful because the vanilla collision callbacks do not work with grid entities.
This is used by POST_GRID_ENTITY_COLLISION custom callback.
Note that this function will not work properly in the POST_NEW_ROOM callback since entities do
not have collision yet in that callback.
Parameters
Section titled “Parameters”gridEntity
Section titled “gridEntity”GridEntity
Returns
Section titled “Returns”readonly Entity[]
getConstituentsFromGridEntityID()
Section titled “getConstituentsFromGridEntityID()”getConstituentsFromGridEntityID(
gridEntityID): [GridEntityType,int]
Defined in: packages/isaacscript-common/src/functions/gridEntities.ts:166
Helper function to get the grid entity type and variant from a GridEntityID.
Parameters
Section titled “Parameters”gridEntityID
Section titled “gridEntityID”Returns
Section titled “Returns”[GridEntityType, int]
getGridEntities()
Section titled “getGridEntities()”getGridEntities(…
gridEntityTypes): readonlyGridEntity[]
Defined in: packages/isaacscript-common/src/functions/gridEntities.ts:229
Helper function to get every grid entity in the current room.
Use this function with no arguments to get every grid entity, or specify a variadic amount of arguments to match specific grid entity types.
For example:
for (const gridEntity of getGridEntities()) { print(gridEntity.GetType())}For example:
const rocks = getGridEntities( GridEntityType.ROCK, GridEntityType.BLOCK, GridEntityType.ROCK_TINTED,);Parameters
Section titled “Parameters”gridEntityTypes
Section titled “gridEntityTypes”…readonly GridEntityType[]
Returns
Section titled “Returns”readonly GridEntity[]
Allow Empty Variadic
Section titled “Allow Empty Variadic”getGridEntitiesExcept()
Section titled “getGridEntitiesExcept()”getGridEntitiesExcept(…
gridEntityTypes): readonlyGridEntity[]
Defined in: packages/isaacscript-common/src/functions/gridEntities.ts:251
Helper function to get every grid entity in the current room except for certain specific types.
This function is variadic, meaning that you can specify as many grid entity types as you want to exclude.
Parameters
Section titled “Parameters”gridEntityTypes
Section titled “gridEntityTypes”…readonly GridEntityType[]
Returns
Section titled “Returns”readonly GridEntity[]
getGridEntitiesInRadius()
Section titled “getGridEntitiesInRadius()”getGridEntitiesInRadius(
targetPosition,radius): readonlyGridEntity[]
Defined in: packages/isaacscript-common/src/functions/gridEntities.ts:268
Helper function to get all grid entities in a given radius around a given point.
Parameters
Section titled “Parameters”targetPosition
Section titled “targetPosition”Vector
radius
Section titled “radius”number
Returns
Section titled “Returns”readonly GridEntity[]
getGridEntitiesMap()
Section titled “getGridEntitiesMap()”getGridEntitiesMap(…
gridEntityTypes):ReadonlyMap<int,GridEntity>
Defined in: packages/isaacscript-common/src/functions/gridEntities.ts:323
Helper function to get a map of every grid entity in the current room. The indexes of the map are equal to the grid index. The values of the map are equal to the grid entities.
Use this function with no arguments to get every grid entity, or specify a variadic amount of arguments to match specific grid entity types.
Parameters
Section titled “Parameters”gridEntityTypes
Section titled “gridEntityTypes”…readonly GridEntityType[]
Returns
Section titled “Returns”ReadonlyMap<int, GridEntity>
Allow Empty Variadic
Section titled “Allow Empty Variadic”getGridEntityANM2Path()
Section titled “getGridEntityANM2Path()”getGridEntityANM2Path(
gridEntityType):string|undefined
Defined in: packages/isaacscript-common/src/functions/gridEntities.ts:338
Helper function to get the ANM2 path for a grid entity type.
Parameters
Section titled “Parameters”gridEntityType
Section titled “gridEntityType”GridEntityType
Returns
Section titled “Returns”string | undefined
getGridEntityCollisionPoints()
Section titled “getGridEntityCollisionPoints()”getGridEntityCollisionPoints(
gridEntity):object
Defined in: packages/isaacscript-common/src/functions/gridEntities.ts:346
Helper function to get the top left and bottom right corners of a given grid entity.
Parameters
Section titled “Parameters”gridEntity
Section titled “gridEntity”GridEntity
Returns
Section titled “Returns”object
topLeft
Section titled “topLeft”topLeft:
Vector
bottomRight
Section titled “bottomRight”bottomRight:
Vector
getGridEntityID()
Section titled “getGridEntityID()”getGridEntityID(
gridEntity):GridEntityID
Defined in: packages/isaacscript-common/src/functions/gridEntities.ts:366
Helper function to get a string containing the grid entity’s type and variant.
Parameters
Section titled “Parameters”gridEntity
Section titled “gridEntity”GridEntity
Returns
Section titled “Returns”getGridEntityIDFromConstituents()
Section titled “getGridEntityIDFromConstituents()”getGridEntityIDFromConstituents(
gridEntityType,variant):GridEntityID
Defined in: packages/isaacscript-common/src/functions/gridEntities.ts:376
Helper function to get a formatted string in the format returned by the getGridEntityID
function.
Parameters
Section titled “Parameters”gridEntityType
Section titled “gridEntityType”GridEntityType
variant
Section titled “variant”int
Returns
Section titled “Returns”getMatchingGridEntities()
Section titled “getMatchingGridEntities()”getMatchingGridEntities(
gridEntityType,variant): readonlyGridEntity[]
Defined in: packages/isaacscript-common/src/functions/gridEntities.ts:389
Helper function to get all of the grid entities in the room that specifically match the type and variant provided.
If you want to match every variant, use the getGridEntities function instead.
Parameters
Section titled “Parameters”gridEntityType
Section titled “gridEntityType”GridEntityType
variant
Section titled “variant”int
Returns
Section titled “Returns”readonly GridEntity[]
getRockPNGPath()
Section titled “getRockPNGPath()”getRockPNGPath():
string
Defined in: packages/isaacscript-common/src/functions/gridEntities.ts:405
Helper function to get the PNG path for a rock. This depends on the current room’s backdrop. The values are taken from the “backdrops.xml” file.
All of the rock PNGs are in the “gfx/grid” directory.
Returns
Section titled “Returns”string
getSurroundingGridEntities()
Section titled “getSurroundingGridEntities()”getSurroundingGridEntities(
gridEntity): readonlyGridEntity[]
Defined in: packages/isaacscript-common/src/functions/gridEntities.ts:416
Helper function to get the grid entities on the surrounding tiles from the provided grid entity.
For example, if a rock was surrounded by rocks on all sides, this would return an array of 8 rocks (e.g. top-left + top + top-right + left + right + bottom-left + bottom + right).
Parameters
Section titled “Parameters”gridEntity
Section titled “gridEntity”GridEntity
Returns
Section titled “Returns”readonly GridEntity[]
getSurroundingGridIndexes()
Section titled “getSurroundingGridIndexes()”getSurroundingGridIndexes(
gridIndex): [int,int,int,int,int,int,int,int]
Defined in: packages/isaacscript-common/src/functions/gridEntities.ts:442
Helper function to get the grid indexes on the surrounding tiles from the provided grid index.
There are always 8 grid indexes returned (e.g. top-left + top + top-right + left + right + bottom-left + bottom + right), even if the computed values would be negative or otherwise invalid.
Parameters
Section titled “Parameters”gridIndex
Section titled “gridIndex”int
Returns
Section titled “Returns”[int, int, int, int, int, int, int, int]
getTopLeftWall()
Section titled “getTopLeftWall()”getTopLeftWall():
GridEntity|undefined
Defined in: packages/isaacscript-common/src/functions/gridEntities.ts:476
Helper function to get the top left wall in the current room.
This function can be useful in certain situations to determine if the room is currently loaded.
Returns
Section titled “Returns”GridEntity | undefined
getTopLeftWallGridIndex()
Section titled “getTopLeftWallGridIndex()”getTopLeftWallGridIndex():
int
Defined in: packages/isaacscript-common/src/functions/gridEntities.ts:488
Helper function to get the grid index of the top left wall. (This will depend on what the current room shape is.)
This function can be useful in certain situations to determine if the room is currently loaded.
Returns
Section titled “Returns”int
isGridEntityBreakableByExplosion()
Section titled “isGridEntityBreakableByExplosion()”isGridEntityBreakableByExplosion(
gridEntity):boolean
Defined in: packages/isaacscript-common/src/functions/gridEntities.ts:503
Helper function to detect if a particular grid entity would “break” if it was touched by an explosion.
For example, rocks and pots are breakable by explosions, but blocks are not.
Parameters
Section titled “Parameters”gridEntity
Section titled “gridEntity”GridEntity
Returns
Section titled “Returns”boolean
isGridEntityBroken()
Section titled “isGridEntityBroken()”isGridEntityBroken(
gridEntity):boolean
Defined in: packages/isaacscript-common/src/functions/gridEntities.ts:525
Helper function to see if the provided grid entity is in its respective broken state. See the
GRID_ENTITY_TYPE_TO_BROKEN_STATE_MAP constant for more details.
Note that in the case of GridEntityType.LOCK (11), the state will turn to being broken before
the actual collision for the entity is removed.
Parameters
Section titled “Parameters”gridEntity
Section titled “gridEntity”GridEntity
Returns
Section titled “Returns”boolean
isGridEntityXMLType()
Section titled “isGridEntityXMLType()”isGridEntityXMLType(
num):num is GridEntityXMLType
Defined in: packages/isaacscript-common/src/functions/gridEntities.ts:535
Helper function to see if an arbitrary number is a valid GridEntityXMLType. This is useful in
the PRE_ROOM_ENTITY_SPAWN callback for narrowing the type of the first argument.
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”num is GridEntityXMLType
isGridIndexAdjacentToDoor()
Section titled “isGridIndexAdjacentToDoor()”isGridIndexAdjacentToDoor(
gridIndex):boolean
Defined in: packages/isaacscript-common/src/functions/gridEntities.ts:543
Helper function to check if the provided grid index has a door on it or if the surrounding 8 grid indexes have a door on it.
Parameters
Section titled “Parameters”gridIndex
Section titled “gridIndex”int
Returns
Section titled “Returns”boolean
isPoopGridEntityXMLType()
Section titled “isPoopGridEntityXMLType()”isPoopGridEntityXMLType(
gridEntityXMLType):boolean
Defined in: packages/isaacscript-common/src/functions/gridEntities.ts:562
Helper function to see if a GridEntityXMLType is some kind of poop.
Parameters
Section titled “Parameters”gridEntityXMLType
Section titled “gridEntityXMLType”GridEntityXMLType
Returns
Section titled “Returns”boolean
isPostBossVoidPortal()
Section titled “isPostBossVoidPortal()”isPostBossVoidPortal(
gridEntity):boolean
Defined in: packages/isaacscript-common/src/functions/gridEntities.ts:576
Helper function to detect whether a given Void Portal is one that randomly spawns after a boss is defeated or is one that naturally spawns in the room after Hush.
Under the hood, this is determined by looking at the VarData of the entity:
- The
VarDataof Void Portals that are spawned after bosses will be equal to 1. - The
VarDataof the Void Portal in the room after Hush is equal to 0.
Parameters
Section titled “Parameters”gridEntity
Section titled “gridEntity”GridEntity
Returns
Section titled “Returns”boolean
removeAllGridEntitiesExcept()
Section titled “removeAllGridEntitiesExcept()”removeAllGridEntitiesExcept(…
gridEntityTypes): readonlyGridEntity[]
Defined in: packages/isaacscript-common/src/functions/gridEntities.ts:605
Helper function to all grid entities in the room except for ones matching the grid entity types provided.
Note that this function will automatically update the room. (This means that you can spawn new grid entities on the same tile on the same frame, if needed.)
For example:
removeAllGridEntitiesExcept( GridEntityType.WALL, GridEntityType.DOOR,);Parameters
Section titled “Parameters”gridEntityTypes
Section titled “gridEntityTypes”…readonly GridEntityType[]
Returns
Section titled “Returns”readonly GridEntity[]
The grid entities that were removed.
removeAllMatchingGridEntities()
Section titled “removeAllMatchingGridEntities()”removeAllMatchingGridEntities(…
gridEntityType): readonlyGridEntity[]
Defined in: packages/isaacscript-common/src/functions/gridEntities.ts:645
Helper function to remove all of the grid entities in the room that match the grid entity types provided.
Note that this function will automatically update the room. (This means that you can spawn new grid entities on the same tile on the same frame, if needed.)
For example:
removeAllMatchingGridEntities( GridEntityType.ROCK, GridEntityType.BLOCK, GridEntityType.ROCK_TINTED,);Parameters
Section titled “Parameters”gridEntityType
Section titled “gridEntityType”…readonly GridEntityType[]
Returns
Section titled “Returns”readonly GridEntity[]
An array of the grid entities removed.
removeEntitiesSpawnedFromGridEntity()
Section titled “removeEntitiesSpawnedFromGridEntity()”removeEntitiesSpawnedFromGridEntity(
entities,gridEntity):void
Defined in: packages/isaacscript-common/src/functions/gridEntities.ts:668
Helper function to remove all entities that just spawned from a grid entity breaking. Specifically, this is any entities that overlap with the position of a grid entity and are on frame 0.
You must specify an array of entities to look through.
Parameters
Section titled “Parameters”entities
Section titled “entities”readonly Entity[]
gridEntity
Section titled “gridEntity”GridEntity
Returns
Section titled “Returns”void
removeGridEntities()
Section titled “removeGridEntities()”removeGridEntities<
T>(gridEntities,updateRoom,cap?): readonlyT[]
Defined in: packages/isaacscript-common/src/functions/gridEntities.ts:692
Helper function to remove all of the grid entities in the supplied array.
Type Parameters
Section titled “Type Parameters”T extends AnyGridEntity
Parameters
Section titled “Parameters”gridEntities
Section titled “gridEntities”readonly T[]
The array of grid entities to remove.
updateRoom
Section titled “updateRoom”boolean
Whether to update the room after the grid entities are removed. This is
generally a good idea because if the room is not updated, you will be unable to
spawn another grid entity on the same tile until a frame has passed. However,
doing this is expensive, since it involves a call to Isaac.GetRoomEntities,
so set this to false if you need to run this function multiple times.
int
Optional. If specified, will only remove the given amount of entities.
Returns
Section titled “Returns”readonly T[]
An array of the entities that were removed.
removeGridEntity()
Section titled “removeGridEntity()”removeGridEntity(
gridEntityOrGridIndex,updateRoom):void
Defined in: packages/isaacscript-common/src/functions/gridEntities.ts:732
Helper function to remove a grid entity by providing the grid entity object or the grid index inside of the room.
If removing a Devil Statue or an Angel Statue, this will also remove the associated effect
(EffectVariant.DEVIL (6) or EffectVariant.ANGEL (9), respectively.)
Parameters
Section titled “Parameters”gridEntityOrGridIndex
Section titled “gridEntityOrGridIndex”int | GridEntity
The grid entity or grid index to remove.
updateRoom
Section titled “updateRoom”boolean
Whether to update the room after the grid entity is removed. This is generally
a good idea because if the room is not updated, you will be unable to spawn
another grid entity on the same tile until a frame has passed. However, doing
this is expensive, since it involves a call to Isaac.GetRoomEntities, so set
this to false if you need to run this function multiple times.
Returns
Section titled “Returns”void
setGridEntityInvisible()
Section titled “setGridEntityInvisible()”setGridEntityInvisible(
gridEntity):void
Defined in: packages/isaacscript-common/src/functions/gridEntities.ts:782
Helper function to make a grid entity invisible. This is accomplished by resetting the sprite.
Note that this function is destructive such that once you make a grid entity invisible, it can no longer become visible. (This is because the information about the sprite is lost when it is reset.)
Parameters
Section titled “Parameters”gridEntity
Section titled “gridEntity”GridEntity
Returns
Section titled “Returns”void
setGridEntityType()
Section titled “setGridEntityType()”setGridEntityType(
gridEntity,gridEntityType):void
Defined in: packages/isaacscript-common/src/functions/gridEntities.ts:794
Helper function to change the type of a grid entity to another type. Use this instead of the
GridEntity.SetType method since that does not properly handle updating the sprite of the grid
entity after the type is changed.
Setting the new type to GridEntityType.NULL (0) will have no effect.
Parameters
Section titled “Parameters”gridEntity
Section titled “gridEntity”GridEntity
gridEntityType
Section titled “gridEntityType”GridEntityType
Returns
Section titled “Returns”void
spawnGiantPoop()
Section titled “spawnGiantPoop()”spawnGiantPoop(
topLeftGridIndex):boolean
Defined in: packages/isaacscript-common/src/functions/gridEntities.ts:824
Helper function to spawn a giant poop. This is performed by spawning each of the four quadrant grid entities in the appropriate positions.
Parameters
Section titled “Parameters”topLeftGridIndex
Section titled “topLeftGridIndex”int
Returns
Section titled “Returns”boolean
Whether spawning the four quadrants was successful.
spawnGridEntity()
Section titled “spawnGridEntity()”spawnGridEntity(
gridEntityType,gridIndexOrPosition,shouldRemoveExistingGridEntity?):GridEntity|undefined
Defined in: packages/isaacscript-common/src/functions/gridEntities.ts:906
Helper function to spawn a grid entity with a specific type.
This function assumes you want to give the grid entity a variant of 0. If you want to specify a
variant, use the spawnGridEntityWithVariant helper function instead.
Use this instead of the Isaac.GridSpawn method since it:
- handles giving pits collision
- removes existing grid entities on the same tile, if any
- allows you to specify either the grid index or the position
Parameters
Section titled “Parameters”gridEntityType
Section titled “gridEntityType”GridEntityType
The GridEntityType to use.
gridIndexOrPosition
Section titled “gridIndexOrPosition”int | Vector
The grid index or position in the room that you want to spawn the grid entity at. If a position is specified, the closest grid index will be used.
shouldRemoveExistingGridEntity?
Section titled “shouldRemoveExistingGridEntity?”boolean = true
Optional. Whether to remove the existing grid entity on the same tile, if it exists. Defaults to true. If false, this function will do nothing, since spawning a grid entity on top of another grid entity will not replace it.
Returns
Section titled “Returns”GridEntity | undefined
spawnGridEntityWithVariant()
Section titled “spawnGridEntityWithVariant()”spawnGridEntityWithVariant(
gridEntityType,variant,gridIndexOrPosition,shouldRemoveExistingGridEntity?):GridEntity|undefined
Defined in: packages/isaacscript-common/src/functions/gridEntities.ts:937
Helper function to spawn a grid entity with a specific variant.
Use this instead of the Isaac.GridSpawn method since it:
- handles giving pits collision
- removes existing grid entities on the same tile, if any
- allows you to specify the grid index or the position
Parameters
Section titled “Parameters”gridEntityType
Section titled “gridEntityType”GridEntityType
The GridEntityType to use.
variant
Section titled “variant”int
The variant to use.
gridIndexOrPosition
Section titled “gridIndexOrPosition”int | Vector
The grid index or position in the room that you want to spawn the grid entity at. If a position is specified, the closest grid index will be used.
shouldRemoveExistingGridEntity?
Section titled “shouldRemoveExistingGridEntity?”boolean = true
Optional. Whether to remove the existing grid entity on the same tile, if it exists. Defaults to true. If false, this function will do nothing, since spawning a grid entity on top of another grid entity will not replace it.
Returns
Section titled “Returns”GridEntity | undefined
spawnVoidPortal()
Section titled “spawnVoidPortal()”spawnVoidPortal(
gridIndex):GridEntity|undefined
Defined in: packages/isaacscript-common/src/functions/gridEntities.ts:996
Helper function to spawn a Void Portal. This is more complicated than simply spawning a trapdoor with the appropriate variant, as the game does not give it the correct sprite automatically.
Parameters
Section titled “Parameters”gridIndex
Section titled “gridIndex”int
Returns
Section titled “Returns”GridEntity | undefined
