isaacscript-common 12.5.1 → 12.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1665,6 +1665,12 @@ export declare class DefaultMap<Key, Value, Args extends unknown[] = []> extends
1665
1665
  getConstructorArg(): Value | FactoryFunction<Value, Args>;
1666
1666
  }
1667
1667
 
1668
+ /**
1669
+ * Helper function to get the value from a `DefaultMap` that corresponds to an entity, assuming that
1670
+ * the map uses `PtrHash` as an index.
1671
+ */
1672
+ export declare function defaultMapGetHash<V, A extends unknown[]>(map: DefaultMap<PtrHash, V, A>, entity: Entity, ...extraArgs: A): V;
1673
+
1668
1674
  /**
1669
1675
  * Helper function to make using default maps with an index of `PlayerIndex` easier. Use this
1670
1676
  * instead of the `DefaultMap.getAndSetDefault` method if you have a default map of this type.
@@ -1685,6 +1691,15 @@ export declare class DefaultMap<Key, Value, Args extends unknown[] = []> extends
1685
1691
  */
1686
1692
  export declare function defaultMapGetPlayer<V, A extends unknown[]>(map: DefaultMap<PlayerIndex, V, A>, player: EntityPlayer, ...extraArgs: A): V;
1687
1693
 
1694
+ /**
1695
+ * Helper function to set a value for a `DefaultMap` that corresponds to an entity, assuming that
1696
+ * the map uses `PtrHash` as an index.
1697
+ *
1698
+ * Since `Map` and `DefaultMap` set values in the same way, this function is simply an alias for the
1699
+ * `mapSetHash` helper function.
1700
+ */
1701
+ export declare function defaultMapSetHash<V>(map: Map<PtrHash, V>, entity: Entity, value: V): void;
1702
+
1688
1703
  /**
1689
1704
  * Helper function to make using maps with an index of `PlayerIndex` easier. Use this instead of the
1690
1705
  * `Map.set` method if you have a map of this type.
@@ -6996,6 +7011,12 @@ export declare function mapGetPlayer<V>(map: Map<PlayerIndex, V>, player: Entity
6996
7011
  */
6997
7012
  export declare function mapHasPlayer<V>(map: Map<PlayerIndex, V>, player: EntityPlayer): boolean;
6998
7013
 
7014
+ /**
7015
+ * Helper function to set a value for a `DefaultMap` that corresponds to an entity, assuming that
7016
+ * the map uses `PtrHash` as an index.
7017
+ */
7018
+ export declare function mapSetHash<V>(map: Map<PtrHash, V>, entity: Entity, value: V): void;
7019
+
6999
7020
  /**
7000
7021
  * Helper function to make using maps with an index of `PlayerIndex` easier. Use this instead of the
7001
7022
  * `Map.set` method if you have a map of this type.
@@ -1,6 +1,6 @@
1
1
  --[[
2
2
 
3
- isaacscript-common 12.5.1
3
+ isaacscript-common 12.5.2
4
4
 
5
5
  This is the "isaacscript-common" library, which was created with the IsaacScript tool.
6
6
 
@@ -9323,7 +9323,7 @@ ____exports.ClottyVariant.GRILLED_CLOTTY = 3
9323
9323
  ____exports.ClottyVariant[____exports.ClottyVariant.GRILLED_CLOTTY] = "GRILLED_CLOTTY"
9324
9324
  --- For `EntityType.MULLIGAN` (16).
9325
9325
  ____exports.MulliganVariant = {}
9326
- ____exports.MulliganVariant.MULLIGAN = 16
9326
+ ____exports.MulliganVariant.MULLIGAN = 0
9327
9327
  ____exports.MulliganVariant[____exports.MulliganVariant.MULLIGAN] = "MULLIGAN"
9328
9328
  ____exports.MulliganVariant.MULLIGOON = 1
9329
9329
  ____exports.MulliganVariant[____exports.MulliganVariant.MULLIGOON] = "MULLIGOON"
@@ -12533,6 +12533,8 @@ local ____exports = {}
12533
12533
  --
12534
12534
  -- The `gridspawn` console command accepts `GridEntityXMLType` instead of `GridEntityType`.
12535
12535
  ____exports.GridEntityXMLType = {}
12536
+ ____exports.GridEntityXMLType.DECORATION = 0
12537
+ ____exports.GridEntityXMLType[____exports.GridEntityXMLType.DECORATION] = "DECORATION"
12536
12538
  ____exports.GridEntityXMLType.ROCK = 1000
12537
12539
  ____exports.GridEntityXMLType[____exports.GridEntityXMLType.ROCK] = "ROCK"
12538
12540
  ____exports.GridEntityXMLType.ROCK_BOMB = 1001
@@ -41252,7 +41254,7 @@ local __TS__New = ____lualib.__TS__New
41252
41254
  local Map = ____lualib.Map
41253
41255
  local __TS__Iterator = ____lualib.__TS__Iterator
41254
41256
  local ____exports = {}
41255
- local preUseItemWeNeedToGoDeeper, postNewRoomReordered, setDecorationsInvisible, respawnPersistentEntities, removeSpecificNPCs, fillRoomWithDecorations, spawnAllEntities, spawnGridEntityForJSONRoom, spawnNormalEntityForJSONRoom, storePersistentEntity, fixPitGraphics, getPitMap, getPitFrame, FEATURE_NAME, NPC_TYPES_TO_NOT_REMOVE, PERSISTENT_ENTITY_TYPES, v
41257
+ local preUseItemWeNeedToGoDeeper, postNewRoomReordered, setDecorationsInvisible, respawnPersistentEntities, removeSpecificNPCs, fillRoomWithDecorations, spawnAllEntities, spawnGridEntityForJSONRoom, spawnNormalEntityForJSONRoom, storePersistentEntity, fixPitGraphics, getPitMap, getPitFrame, FEATURE_NAME, NPC_TYPES_TO_NOT_REMOVE, PERSISTENT_ENTITY_TYPES, GRID_ENTITY_XML_TYPE_SET, v
41256
41258
  local ____isaac_2Dtypescript_2Ddefinitions = require("lua_modules.isaac-typescript-definitions.dist.src.index")
41257
41259
  local CollectibleType = ____isaac_2Dtypescript_2Ddefinitions.CollectibleType
41258
41260
  local EffectVariant = ____isaac_2Dtypescript_2Ddefinitions.EffectVariant
@@ -41261,6 +41263,7 @@ local EntityFlag = ____isaac_2Dtypescript_2Ddefinitions.EntityFlag
41261
41263
  local EntityGridCollisionClass = ____isaac_2Dtypescript_2Ddefinitions.EntityGridCollisionClass
41262
41264
  local EntityType = ____isaac_2Dtypescript_2Ddefinitions.EntityType
41263
41265
  local GridEntityType = ____isaac_2Dtypescript_2Ddefinitions.GridEntityType
41266
+ local GridEntityXMLType = ____isaac_2Dtypescript_2Ddefinitions.GridEntityXMLType
41264
41267
  local ModCallback = ____isaac_2Dtypescript_2Ddefinitions.ModCallback
41265
41268
  local PickupVariant = ____isaac_2Dtypescript_2Ddefinitions.PickupVariant
41266
41269
  local PitfallVariant = ____isaac_2Dtypescript_2Ddefinitions.PitfallVariant
@@ -41284,6 +41287,8 @@ local ____entitiesSpecific = require("src.functions.entitiesSpecific")
41284
41287
  local getNPCs = ____entitiesSpecific.getNPCs
41285
41288
  local removeAllBombs = ____entitiesSpecific.removeAllBombs
41286
41289
  local removeAllPickups = ____entitiesSpecific.removeAllPickups
41290
+ local ____enums = require("src.functions.enums")
41291
+ local getEnumValues = ____enums.getEnumValues
41287
41292
  local ____gridEntities = require("src.functions.gridEntities")
41288
41293
  local convertXMLGridEntityType = ____gridEntities.convertXMLGridEntityType
41289
41294
  local getAllGridIndexes = ____gridEntities.getAllGridIndexes
@@ -41481,7 +41486,8 @@ function spawnAllEntities(self, jsonRoom, rng, verbose)
41481
41486
  if subType == nil then
41482
41487
  error("Failed to convert the entity sub-type to a number: " .. tostring(subType))
41483
41488
  end
41484
- if entityTypeNumber >= 1000 then
41489
+ local isGridEntity = GRID_ENTITY_XML_TYPE_SET:has(entityTypeNumber)
41490
+ if isGridEntity then
41485
41491
  local gridEntityXMLType = entityTypeNumber
41486
41492
  if verbose then
41487
41493
  log(
@@ -41705,6 +41711,8 @@ end
41705
41711
  FEATURE_NAME = "deployJSONRoom"
41706
41712
  NPC_TYPES_TO_NOT_REMOVE = __TS__New(Set, {EntityType.DARK_ESAU})
41707
41713
  PERSISTENT_ENTITY_TYPES = __TS__New(Set, {EntityType.WALL_HUGGER})
41714
+ local gridEntityXMLTypes = getEnumValues(nil, GridEntityXMLType)
41715
+ GRID_ENTITY_XML_TYPE_SET = __TS__New(Set, gridEntityXMLTypes)
41708
41716
  v = {
41709
41717
  level = {
41710
41718
  deployedRoomListIndexes = __TS__New(Set),
@@ -42793,6 +42801,10 @@ local ____array = require("src.functions.array")
42793
42801
  local sumArray = ____array.sumArray
42794
42802
  local ____string = require("src.functions.string")
42795
42803
  local getPartialMatch = ____string.getPartialMatch
42804
+ function ____exports.mapSetHash(self, map, entity, value)
42805
+ local hash = GetPtrHash(entity)
42806
+ map:set(hash, value)
42807
+ end
42796
42808
  function ____exports.copyMap(self, oldMap)
42797
42809
  local newMap = __TS__New(Map)
42798
42810
  for ____, ____value in __TS__Iterator(oldMap:entries()) do
@@ -42802,6 +42814,13 @@ function ____exports.copyMap(self, oldMap)
42802
42814
  end
42803
42815
  return newMap
42804
42816
  end
42817
+ function ____exports.defaultMapGetHash(self, map, entity, ...)
42818
+ local ptrHash = GetPtrHash(entity)
42819
+ return map:getAndSetDefault(ptrHash, ...)
42820
+ end
42821
+ function ____exports.defaultMapSetHash(self, map, entity, value)
42822
+ ____exports.mapSetHash(nil, map, entity, value)
42823
+ end
42805
42824
  function ____exports.getMapPartialMatch(self, searchText, map)
42806
42825
  local keys = {__TS__Spread(map:keys())}
42807
42826
  local matchingKey = getPartialMatch(nil, searchText, keys)
@@ -1 +1 @@
1
- {"version":3,"file":"deployJSONRoom.d.ts","sourceRoot":"","sources":["../../../src/features/deployJSONRoom.ts"],"names":[],"mappings":";;AAuDA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAuKvD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC,EACvC,SAAS,GAAE,IAAI,GAAG,GAAqB,EACvC,OAAO,UAAQ,GACd,IAAI,CAuBN;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,QAAQ,EAAE,GAAG,SAAS,QAAQ,EAAE,EAC3C,SAAS,GAAE,IAAI,GAAG,GAAqB,EACvC,OAAO,UAAQ,GACd,IAAI,CAaN;AAED;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,mBAAmB,EAAE,OAAO,GAAG,IAAI,CAwB5D"}
1
+ {"version":3,"file":"deployJSONRoom.d.ts","sourceRoot":"","sources":["../../../src/features/deployJSONRoom.ts"],"names":[],"mappings":";;AAwDA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AA4KvD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC,EACvC,SAAS,GAAE,IAAI,GAAG,GAAqB,EACvC,OAAO,UAAQ,GACd,IAAI,CAuBN;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,QAAQ,EAAE,GAAG,SAAS,QAAQ,EAAE,EAC3C,SAAS,GAAE,IAAI,GAAG,GAAqB,EACvC,OAAO,UAAQ,GACd,IAAI,CAaN;AAED;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,mBAAmB,EAAE,OAAO,GAAG,IAAI,CAwB5D"}
@@ -4,7 +4,7 @@ local __TS__New = ____lualib.__TS__New
4
4
  local Map = ____lualib.Map
5
5
  local __TS__Iterator = ____lualib.__TS__Iterator
6
6
  local ____exports = {}
7
- local preUseItemWeNeedToGoDeeper, postNewRoomReordered, setDecorationsInvisible, respawnPersistentEntities, removeSpecificNPCs, fillRoomWithDecorations, spawnAllEntities, spawnGridEntityForJSONRoom, spawnNormalEntityForJSONRoom, storePersistentEntity, fixPitGraphics, getPitMap, getPitFrame, FEATURE_NAME, NPC_TYPES_TO_NOT_REMOVE, PERSISTENT_ENTITY_TYPES, v
7
+ local preUseItemWeNeedToGoDeeper, postNewRoomReordered, setDecorationsInvisible, respawnPersistentEntities, removeSpecificNPCs, fillRoomWithDecorations, spawnAllEntities, spawnGridEntityForJSONRoom, spawnNormalEntityForJSONRoom, storePersistentEntity, fixPitGraphics, getPitMap, getPitFrame, FEATURE_NAME, NPC_TYPES_TO_NOT_REMOVE, PERSISTENT_ENTITY_TYPES, GRID_ENTITY_XML_TYPE_SET, v
8
8
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
9
9
  local CollectibleType = ____isaac_2Dtypescript_2Ddefinitions.CollectibleType
10
10
  local EffectVariant = ____isaac_2Dtypescript_2Ddefinitions.EffectVariant
@@ -13,6 +13,7 @@ local EntityFlag = ____isaac_2Dtypescript_2Ddefinitions.EntityFlag
13
13
  local EntityGridCollisionClass = ____isaac_2Dtypescript_2Ddefinitions.EntityGridCollisionClass
14
14
  local EntityType = ____isaac_2Dtypescript_2Ddefinitions.EntityType
15
15
  local GridEntityType = ____isaac_2Dtypescript_2Ddefinitions.GridEntityType
16
+ local GridEntityXMLType = ____isaac_2Dtypescript_2Ddefinitions.GridEntityXMLType
16
17
  local ModCallback = ____isaac_2Dtypescript_2Ddefinitions.ModCallback
17
18
  local PickupVariant = ____isaac_2Dtypescript_2Ddefinitions.PickupVariant
18
19
  local PitfallVariant = ____isaac_2Dtypescript_2Ddefinitions.PitfallVariant
@@ -36,6 +37,8 @@ local ____entitiesSpecific = require("src.functions.entitiesSpecific")
36
37
  local getNPCs = ____entitiesSpecific.getNPCs
37
38
  local removeAllBombs = ____entitiesSpecific.removeAllBombs
38
39
  local removeAllPickups = ____entitiesSpecific.removeAllPickups
40
+ local ____enums = require("src.functions.enums")
41
+ local getEnumValues = ____enums.getEnumValues
39
42
  local ____gridEntities = require("src.functions.gridEntities")
40
43
  local convertXMLGridEntityType = ____gridEntities.convertXMLGridEntityType
41
44
  local getAllGridIndexes = ____gridEntities.getAllGridIndexes
@@ -241,7 +244,8 @@ function spawnAllEntities(self, jsonRoom, rng, verbose)
241
244
  if subType == nil then
242
245
  error("Failed to convert the entity sub-type to a number: " .. tostring(subType))
243
246
  end
244
- if entityTypeNumber >= 1000 then
247
+ local isGridEntity = GRID_ENTITY_XML_TYPE_SET:has(entityTypeNumber)
248
+ if isGridEntity then
245
249
  local gridEntityXMLType = entityTypeNumber
246
250
  if verbose then
247
251
  log(
@@ -465,6 +469,8 @@ end
465
469
  FEATURE_NAME = "deployJSONRoom"
466
470
  NPC_TYPES_TO_NOT_REMOVE = __TS__New(Set, {EntityType.DARK_ESAU})
467
471
  PERSISTENT_ENTITY_TYPES = __TS__New(Set, {EntityType.WALL_HUGGER})
472
+ local gridEntityXMLTypes = getEnumValues(nil, GridEntityXMLType)
473
+ GRID_ENTITY_XML_TYPE_SET = __TS__New(Set, gridEntityXMLTypes)
468
474
  v = {
469
475
  level = {
470
476
  deployedRoomListIndexes = __TS__New(Set),
@@ -1,5 +1,21 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ /// <reference types="isaac-typescript-definitions" />
3
+ import { DefaultMap } from "../classes/DefaultMap";
1
4
  /** Helper function to copy a map. (You can also use a Map constructor to accomplish this task.) */
2
5
  export declare function copyMap<K, V>(oldMap: Map<K, V>): Map<K, V>;
6
+ /**
7
+ * Helper function to get the value from a `DefaultMap` that corresponds to an entity, assuming that
8
+ * the map uses `PtrHash` as an index.
9
+ */
10
+ export declare function defaultMapGetHash<V, A extends unknown[]>(map: DefaultMap<PtrHash, V, A>, entity: Entity, ...extraArgs: A): V;
11
+ /**
12
+ * Helper function to set a value for a `DefaultMap` that corresponds to an entity, assuming that
13
+ * the map uses `PtrHash` as an index.
14
+ *
15
+ * Since `Map` and `DefaultMap` set values in the same way, this function is simply an alias for the
16
+ * `mapSetHash` helper function.
17
+ */
18
+ export declare function defaultMapSetHash<V>(map: Map<PtrHash, V>, entity: Entity, value: V): void;
3
19
  /**
4
20
  * Helper function to get the closest value from a map based on partial search text. For the
5
21
  * purposes of this function, both search text and map keys are converted to lowercase before
@@ -20,6 +36,11 @@ export declare function copyMap<K, V>(oldMap: Map<K, V>): Map<K, V>;
20
36
  * ```
21
37
  */
22
38
  export declare function getMapPartialMatch<T>(searchText: string, map: ReadonlyMap<string, T>): [string, T] | undefined;
39
+ /**
40
+ * Helper function to set a value for a `DefaultMap` that corresponds to an entity, assuming that
41
+ * the map uses `PtrHash` as an index.
42
+ */
43
+ export declare function mapSetHash<V>(map: Map<PtrHash, V>, entity: Entity, value: V): void;
23
44
  /** Helper function to sum every value in a map together. */
24
45
  export declare function sumMap(map: Map<unknown, number> | ReadonlyMap<unknown, number>): number;
25
46
  //# sourceMappingURL=map.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../../src/functions/map.ts"],"names":[],"mappings":"AAGA,mGAAmG;AACnG,wBAAgB,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAO1D;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,GAC1B,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,SAAS,CAgBzB;AAED,4DAA4D;AAC5D,wBAAgB,MAAM,CACpB,GAAG,EAAE,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,GACvD,MAAM,CAGR"}
1
+ {"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../../src/functions/map.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAInD,mGAAmG;AACnG,wBAAgB,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAO1D;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,CAAC,SAAS,OAAO,EAAE,EACtD,GAAG,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,EAC9B,MAAM,EAAE,MAAM,EACd,GAAG,SAAS,EAAE,CAAC,GACd,CAAC,CAGH;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,GAAG,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,EACpB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,CAAC,GACP,IAAI,CAEN;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,GAC1B,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,SAAS,CAgBzB;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAC1B,GAAG,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,EACpB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,CAAC,GACP,IAAI,CAGN;AAED,4DAA4D;AAC5D,wBAAgB,MAAM,CACpB,GAAG,EAAE,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,GACvD,MAAM,CAGR"}
@@ -8,6 +8,12 @@ local ____array = require("src.functions.array")
8
8
  local sumArray = ____array.sumArray
9
9
  local ____string = require("src.functions.string")
10
10
  local getPartialMatch = ____string.getPartialMatch
11
+ --- Helper function to set a value for a `DefaultMap` that corresponds to an entity, assuming that
12
+ -- the map uses `PtrHash` as an index.
13
+ function ____exports.mapSetHash(self, map, entity, value)
14
+ local hash = GetPtrHash(entity)
15
+ map:set(hash, value)
16
+ end
11
17
  --- Helper function to copy a map. (You can also use a Map constructor to accomplish this task.)
12
18
  function ____exports.copyMap(self, oldMap)
13
19
  local newMap = __TS__New(Map)
@@ -18,6 +24,20 @@ function ____exports.copyMap(self, oldMap)
18
24
  end
19
25
  return newMap
20
26
  end
27
+ --- Helper function to get the value from a `DefaultMap` that corresponds to an entity, assuming that
28
+ -- the map uses `PtrHash` as an index.
29
+ function ____exports.defaultMapGetHash(self, map, entity, ...)
30
+ local ptrHash = GetPtrHash(entity)
31
+ return map:getAndSetDefault(ptrHash, ...)
32
+ end
33
+ --- Helper function to set a value for a `DefaultMap` that corresponds to an entity, assuming that
34
+ -- the map uses `PtrHash` as an index.
35
+ --
36
+ -- Since `Map` and `DefaultMap` set values in the same way, this function is simply an alias for the
37
+ -- `mapSetHash` helper function.
38
+ function ____exports.defaultMapSetHash(self, map, entity, value)
39
+ ____exports.mapSetHash(nil, map, entity, value)
40
+ end
21
41
  --- Helper function to get the closest value from a map based on partial search text. For the
22
42
  -- purposes of this function, both search text and map keys are converted to lowercase before
23
43
  -- attempting to find a match.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "12.5.1",
3
+ "version": "12.5.2",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -22,6 +22,6 @@
22
22
  "main": "dist/src/index",
23
23
  "types": "dist/src/index.d.ts",
24
24
  "dependencies": {
25
- "isaac-typescript-definitions": "^7.2.5"
25
+ "isaac-typescript-definitions": "^7.2.6"
26
26
  }
27
27
  }
@@ -36,6 +36,7 @@ import {
36
36
  removeAllBombs,
37
37
  removeAllPickups,
38
38
  } from "../functions/entitiesSpecific";
39
+ import { getEnumValues } from "../functions/enums";
39
40
  import {
40
41
  convertXMLGridEntityType,
41
42
  getAllGridIndexes,
@@ -74,6 +75,11 @@ const PERSISTENT_ENTITY_TYPES: ReadonlySet<EntityType> = new Set([
74
75
  EntityType.WALL_HUGGER,
75
76
  ]);
76
77
 
78
+ const gridEntityXMLTypes = getEnumValues(GridEntityXMLType);
79
+ const GRID_ENTITY_XML_TYPE_SET: ReadonlySet<number> = new Set(
80
+ gridEntityXMLTypes,
81
+ );
82
+
77
83
  const v = {
78
84
  level: {
79
85
  deployedRoomListIndexes: new Set<int>(),
@@ -492,8 +498,8 @@ function spawnAllEntities(
492
498
  error(`Failed to convert the entity sub-type to a number: ${subType}`);
493
499
  }
494
500
 
495
- // Note that XML entity type 1000 is a rock, not an effect.
496
- if (entityTypeNumber >= 1000) {
501
+ const isGridEntity = GRID_ENTITY_XML_TYPE_SET.has(entityTypeNumber);
502
+ if (isGridEntity) {
497
503
  const gridEntityXMLType = entityTypeNumber as GridEntityXMLType;
498
504
  if (verbose) {
499
505
  log(
@@ -1,3 +1,4 @@
1
+ import { DefaultMap } from "../classes/DefaultMap";
1
2
  import { sumArray } from "./array";
2
3
  import { getPartialMatch } from "./string";
3
4
 
@@ -11,6 +12,34 @@ export function copyMap<K, V>(oldMap: Map<K, V>): Map<K, V> {
11
12
  return newMap;
12
13
  }
13
14
 
15
+ /**
16
+ * Helper function to get the value from a `DefaultMap` that corresponds to an entity, assuming that
17
+ * the map uses `PtrHash` as an index.
18
+ */
19
+ export function defaultMapGetHash<V, A extends unknown[]>(
20
+ map: DefaultMap<PtrHash, V, A>,
21
+ entity: Entity,
22
+ ...extraArgs: A
23
+ ): V {
24
+ const ptrHash = GetPtrHash(entity);
25
+ return map.getAndSetDefault(ptrHash, ...extraArgs);
26
+ }
27
+
28
+ /**
29
+ * Helper function to set a value for a `DefaultMap` that corresponds to an entity, assuming that
30
+ * the map uses `PtrHash` as an index.
31
+ *
32
+ * Since `Map` and `DefaultMap` set values in the same way, this function is simply an alias for the
33
+ * `mapSetHash` helper function.
34
+ */
35
+ export function defaultMapSetHash<V>(
36
+ map: Map<PtrHash, V>,
37
+ entity: Entity,
38
+ value: V,
39
+ ): void {
40
+ mapSetHash(map, entity, value);
41
+ }
42
+
14
43
  /**
15
44
  * Helper function to get the closest value from a map based on partial search text. For the
16
45
  * purposes of this function, both search text and map keys are converted to lowercase before
@@ -51,6 +80,19 @@ export function getMapPartialMatch<T>(
51
80
  return [matchingKey, value];
52
81
  }
53
82
 
83
+ /**
84
+ * Helper function to set a value for a `DefaultMap` that corresponds to an entity, assuming that
85
+ * the map uses `PtrHash` as an index.
86
+ */
87
+ export function mapSetHash<V>(
88
+ map: Map<PtrHash, V>,
89
+ entity: Entity,
90
+ value: V,
91
+ ): void {
92
+ const hash = GetPtrHash(entity);
93
+ map.set(hash, value);
94
+ }
95
+
54
96
  /** Helper function to sum every value in a map together. */
55
97
  export function sumMap(
56
98
  map: Map<unknown, number> | ReadonlyMap<unknown, number>,