Skip to content

Npc Data Structures

defaultMapGetNPC<V, Args>(map, npc, …extraArgs): V

Defined in: packages/isaacscript-common/src/functions/npcDataStructures.ts:27

Helper function to make using default maps with an index of PtrHash easier. Use this instead of the DefaultMap.getAndSetDefault method if you have a default map of this type.

For example:

const v = {
run: {
npcsSpeedBoost: new DefaultMap<PtrHash, int>(0),
},
};
function npcUpdate(npc: EntityNPC) {
const speedBoost = defaultMapGetNPC(v.run.npcsSpeedBoost, npc);
// Do something with the speed boost.
}

Note that not all NPCs should be stored in a map with a PtrHash as an index, so only use this in the situations where that would be okay. (For example, Dark Esau should never be stored in a map like this, because the scope of PtrHash is per room and Dark Esau is persistent between rooms.)

V

Args extends unknown[]

DefaultMap<PtrHash, V, Args>

EntityNPC

Args

V


defaultMapSetNPC<V>(map, npc, value): void

Defined in: packages/isaacscript-common/src/functions/npcDataStructures.ts:43

Helper function to make using maps with an index of PtrHash easier. Use this instead of the Map.set method if you have a map of this type.

Since Map and DefaultMap set values in the same way, this function is simply an alias for the mapSetNPC helper function.

V

Map<PtrHash, V>

EntityNPC

V

void


mapDeleteNPC(map, npc): boolean

Defined in: packages/isaacscript-common/src/functions/npcDataStructures.ts:56

Helper function to make using maps with an type of PtrHash easier. Use this instead of the Map.delete method if you have a set of this type.

Map<PtrHash, unknown>

EntityNPC

boolean


mapGetNPC<V>(map, npc): V | undefined

Defined in: packages/isaacscript-common/src/functions/npcDataStructures.ts:85

Helper function to make using maps with an index of PtrHash easier. Use this instead of the Map.get method if you have a map of this type.

For example:

const v = {
run: {
npcsSpeedBoost: new Map<PtrHash, int>(),
},
};
function incrementSpeedBoost(npc: EntityNPC) {
const oldSpeedBoost = mapGetNPC(v.run.npcsSpeedBoost, npc);
const newSpeedBoost = oldSpeedBoost + 0.1;
mapSetNPC(v.run.npcsSpeedBoost, npc);
}

V

ReadonlyMap<PtrHash, V>

EntityNPC

V | undefined


mapHasNPC<V>(map, npc): boolean

Defined in: packages/isaacscript-common/src/functions/npcDataStructures.ts:97

Helper function to make using maps with an index of PtrHash easier. Use this instead of the Map.has method if you have a map of this type.

V

ReadonlyMap<PtrHash, V>

EntityNPC

boolean


mapSetNPC<V>(map, npc, value): void

Defined in: packages/isaacscript-common/src/functions/npcDataStructures.ts:125

Helper function to make using maps with an index of PtrHash easier. Use this instead of the Map.set method if you have a map of this type.

For example:

const v = {
run: {
npcsSpeedBoost: new Map<PtrHash, int>(),
},
};
function incrementSpeedBoost(npc: EntityNPC) {
const oldSpeedBoost = mapGetNPC(v.run.npcsSpeedBoost, npc);
const newSpeedBoost = oldSpeedBoost + 0.1;
mapSetNPC(v.run.npcsSpeedBoost, npc);
}

V

Map<PtrHash, V>

EntityNPC

V

void


setAddNPC(set, npc): void

Defined in: packages/isaacscript-common/src/functions/npcDataStructures.ts:140

Helper function to make using sets with an type of PtrHash easier. Use this instead of the Set.add method if you have a set of this type.

Set<PtrHash>

EntityNPC

void


setDeleteNPC(set, npc): boolean

Defined in: packages/isaacscript-common/src/functions/npcDataStructures.ts:150

Helper function to make using sets with an type of PtrHash easier. Use this instead of the Set.delete method if you have a set of this type.

Set<PtrHash>

EntityNPC

boolean


setHasNPC(set, npc): boolean

Defined in: packages/isaacscript-common/src/functions/npcDataStructures.ts:159

Helper function to make using sets with an type of PtrHash easier. Use this instead of the Set.has method if you have a set of this type.

ReadonlySet<PtrHash>

EntityNPC

boolean