isaacscript-common
Version:
Helper functions and features for IsaacScript mods.
51 lines • 2.6 kB
TypeScript
import type { EntityType } from "isaac-typescript-definitions";
import { Feature } from "../../private/Feature";
export declare class PersistentEntities extends Feature {
private readonly roomHistory;
private readonly postEntityRemove;
/**
* The persistent entity is despawning because the player is in the process of leaving the room.
* Keep track of the position for later.
*/
private trackDespawningPickupPosition;
private readonly postNewRoomReordered;
private spawnAndTrack;
/**
* 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`.
*
* @param persistentEntityIndex The index that was returned by the `spawnPersistentEntity`
* function.
* @param removeEntity Optional. 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.
* @public
*/
removePersistentEntity(persistentEntityIndex: int, removeEntity?: boolean): void;
/**
* 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`.
*
* @returns An object containing the entity and the persistent entity index. You can use the index
* with the `removePersistentEntity` function.
* @public
*/
spawnPersistentEntity(entityType: EntityType, variant: int, subType: int, position: Vector): {
entity: Entity;
persistentIndex: int;
};
}
//# sourceMappingURL=PersistentEntities.d.ts.map