Skip to main content

Persistent Entities

Hierarchy

  • Feature

    PersistentEntities

Methods

removePersistentEntity

removePersistentEntity(persistentEntityIndex, removeEntity?): void

Helper function to stop an entity spawned with the spawnPersistentEntity helper function from respawning.

In order to use this function, you must upgrade your mod with ISCFeature.PERSISTENT_ENTITIES.

Parameters

NameTypeDefault valueDescription
persistentEntityIndexintundefinedThe index that was returned by the spawnPersistentEntity function.
removeEntitybooleantrueOptional. True by default. Set to false if you want to stop an entity from being persistent but you don't want to actually remove the currently-spawned entity from the room.

Returns

void

Defined in

packages/isaacscript-common/src/classes/features/other/PersistentEntities.ts:166


spawnPersistentEntity

spawnPersistentEntity(entityType, variant, subType, position): Object

Helper function to spawn an entity that will have persistence similar to a pickup.

By default, as soon as you leave a room, any spawned entities will be despawned and will not return if the player revisits the room. This means that if you want to have an entity like a pickup, you have to manually respawn it when the player re-enters the room. Use this helper function to avoid having to do any tracking on your own.

Conventionally, the word "persistent" refers to EntityFlag.FLAG_PERSISTENT, which is used on e.g. familiars to make them appear in every room. On the other hand, pickups are also persistent, but they are not present in every room, only one specific room. This function spawns entities like pickups, not familiars.

In order to use this function, you must upgrade your mod with ISCFeature.PERSISTENT_ENTITIES.

Parameters

NameType
entityTypeEntityType
variantint
subTypeint
positionVector

Returns

Object

An object containing the entity and the persistent entity index. You can use the index with the removePersistentEntity function.

NameType
entityEntity
persistentIndexint

Defined in

packages/isaacscript-common/src/classes/features/other/PersistentEntities.ts:206