Npc Data Structures
Functions
Section titled “Functions”defaultMapGetNPC()
Section titled “defaultMapGetNPC()”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.)
Type Parameters
Section titled “Type Parameters”V
Args extends unknown[]
Parameters
Section titled “Parameters”DefaultMap<PtrHash, V, Args>
EntityNPC
extraArgs
Section titled “extraArgs”…Args
Returns
Section titled “Returns”V
defaultMapSetNPC()
Section titled “defaultMapSetNPC()”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.
Type Parameters
Section titled “Type Parameters”V
Parameters
Section titled “Parameters”Map<PtrHash, V>
EntityNPC
V
Returns
Section titled “Returns”void
mapDeleteNPC()
Section titled “mapDeleteNPC()”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.
Parameters
Section titled “Parameters”Map<PtrHash, unknown>
EntityNPC
Returns
Section titled “Returns”boolean
mapGetNPC()
Section titled “mapGetNPC()”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);}Type Parameters
Section titled “Type Parameters”V
Parameters
Section titled “Parameters”ReadonlyMap<PtrHash, V>
EntityNPC
Returns
Section titled “Returns”V | undefined
mapHasNPC()
Section titled “mapHasNPC()”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.
Type Parameters
Section titled “Type Parameters”V
Parameters
Section titled “Parameters”ReadonlyMap<PtrHash, V>
EntityNPC
Returns
Section titled “Returns”boolean
mapSetNPC()
Section titled “mapSetNPC()”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);}Type Parameters
Section titled “Type Parameters”V
Parameters
Section titled “Parameters”Map<PtrHash, V>
EntityNPC
V
Returns
Section titled “Returns”void
setAddNPC()
Section titled “setAddNPC()”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.
Parameters
Section titled “Parameters”Set<PtrHash>
EntityNPC
Returns
Section titled “Returns”void
setDeleteNPC()
Section titled “setDeleteNPC()”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.
Parameters
Section titled “Parameters”Set<PtrHash>
EntityNPC
Returns
Section titled “Returns”boolean
setHasNPC()
Section titled “setHasNPC()”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.
Parameters
Section titled “Parameters”ReadonlySet<PtrHash>
EntityNPC
Returns
Section titled “Returns”boolean
