isaacscript-common 81.0.4 → 81.0.5

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.
Files changed (149) hide show
  1. package/dist/classes/ModFeature.d.ts +1 -1
  2. package/dist/classes/ModFeature.d.ts.map +1 -1
  3. package/dist/classes/features/other/CustomItemPools.d.ts +1 -1
  4. package/dist/classes/features/other/CustomItemPools.d.ts.map +1 -1
  5. package/dist/classes/features/other/CustomItemPools.lua +4 -2
  6. package/dist/classes/features/other/DisableInputs.d.ts +1 -1
  7. package/dist/classes/features/other/DisableInputs.d.ts.map +1 -1
  8. package/dist/classes/features/other/ModdedElementSets.d.ts +4 -4
  9. package/dist/classes/features/other/ModdedElementSets.d.ts.map +1 -1
  10. package/dist/classes/features/other/ModdedElementSets.lua +7 -2
  11. package/dist/classes/features/other/SaveDataManager.d.ts +1 -1
  12. package/dist/classes/features/other/SaveDataManager.d.ts.map +1 -1
  13. package/dist/functions/array.d.ts +5 -5
  14. package/dist/functions/array.d.ts.map +1 -1
  15. package/dist/functions/arrayLua.d.ts +14 -14
  16. package/dist/functions/arrayLua.d.ts.map +1 -1
  17. package/dist/functions/arrayLua.lua +7 -7
  18. package/dist/functions/benchmark.d.ts +1 -1
  19. package/dist/functions/benchmark.d.ts.map +1 -1
  20. package/dist/functions/bitwise.d.ts +1 -1
  21. package/dist/functions/bitwise.d.ts.map +1 -1
  22. package/dist/functions/cards.d.ts +1 -1
  23. package/dist/functions/cards.d.ts.map +1 -1
  24. package/dist/functions/challenges.d.ts +1 -1
  25. package/dist/functions/challenges.d.ts.map +1 -1
  26. package/dist/functions/curses.d.ts +1 -1
  27. package/dist/functions/curses.d.ts.map +1 -1
  28. package/dist/functions/doors.d.ts +5 -5
  29. package/dist/functions/doors.d.ts.map +1 -1
  30. package/dist/functions/external.d.ts +1 -1
  31. package/dist/functions/external.d.ts.map +1 -1
  32. package/dist/functions/flag.d.ts +5 -4
  33. package/dist/functions/flag.d.ts.map +1 -1
  34. package/dist/functions/gridEntities.d.ts +5 -5
  35. package/dist/functions/gridEntities.d.ts.map +1 -1
  36. package/dist/functions/input.d.ts +5 -5
  37. package/dist/functions/input.d.ts.map +1 -1
  38. package/dist/functions/itemPool.d.ts +2 -2
  39. package/dist/functions/itemPool.d.ts.map +1 -1
  40. package/dist/functions/jsonRoom.d.ts +1 -1
  41. package/dist/functions/jsonRoom.d.ts.map +1 -1
  42. package/dist/functions/level.d.ts +2 -2
  43. package/dist/functions/level.d.ts.map +1 -1
  44. package/dist/functions/levelGrid.d.ts +2 -2
  45. package/dist/functions/levelGrid.d.ts.map +1 -1
  46. package/dist/functions/logEntities.d.ts +3 -3
  47. package/dist/functions/logEntities.d.ts.map +1 -1
  48. package/dist/functions/logMisc.d.ts +2 -1
  49. package/dist/functions/logMisc.d.ts.map +1 -1
  50. package/dist/functions/map.d.ts.map +1 -1
  51. package/dist/functions/merge.d.ts +1 -1
  52. package/dist/functions/merge.d.ts.map +1 -1
  53. package/dist/functions/npcDataStructures.d.ts +3 -3
  54. package/dist/functions/npcDataStructures.d.ts.map +1 -1
  55. package/dist/functions/playerCollectibles.d.ts +7 -7
  56. package/dist/functions/playerCollectibles.d.ts.map +1 -1
  57. package/dist/functions/playerDataStructures.d.ts +3 -3
  58. package/dist/functions/playerDataStructures.d.ts.map +1 -1
  59. package/dist/functions/playerTrinkets.d.ts +2 -2
  60. package/dist/functions/playerTrinkets.d.ts.map +1 -1
  61. package/dist/functions/players.d.ts +4 -4
  62. package/dist/functions/players.d.ts.map +1 -1
  63. package/dist/functions/rng.d.ts +3 -2
  64. package/dist/functions/rng.d.ts.map +1 -1
  65. package/dist/functions/rooms.d.ts +4 -4
  66. package/dist/functions/rooms.d.ts.map +1 -1
  67. package/dist/functions/run.d.ts +2 -2
  68. package/dist/functions/run.d.ts.map +1 -1
  69. package/dist/functions/set.d.ts.map +1 -1
  70. package/dist/functions/sort.d.ts +1 -1
  71. package/dist/functions/sort.d.ts.map +1 -1
  72. package/dist/functions/stage.d.ts +3 -3
  73. package/dist/functions/stage.d.ts.map +1 -1
  74. package/dist/functions/string.d.ts +3 -2
  75. package/dist/functions/string.d.ts.map +1 -1
  76. package/dist/functions/table.d.ts +4 -4
  77. package/dist/functions/table.d.ts.map +1 -1
  78. package/dist/functions/trinketGive.d.ts +1 -1
  79. package/dist/functions/trinketGive.d.ts.map +1 -1
  80. package/dist/functions/utils.d.ts +1 -1
  81. package/dist/functions/utils.d.ts.map +1 -1
  82. package/dist/functions/vector.d.ts +1 -1
  83. package/dist/functions/vector.d.ts.map +1 -1
  84. package/dist/functions/weighted.d.ts +2 -2
  85. package/dist/functions/weighted.d.ts.map +1 -1
  86. package/dist/index.d.ts +1 -0
  87. package/dist/index.d.ts.map +1 -1
  88. package/dist/index.rollup.d.ts +109 -107
  89. package/dist/indexLua.d.ts +1 -0
  90. package/dist/indexLua.d.ts.map +1 -1
  91. package/dist/isaacscript-common.lua +23 -12
  92. package/dist/types/AnyFunction.d.ts +1 -1
  93. package/dist/types/AnyFunction.d.ts.map +1 -1
  94. package/dist/types/ReadonlyRecord.d.ts +2 -0
  95. package/dist/types/ReadonlyRecord.d.ts.map +1 -0
  96. package/dist/types/ReadonlyRecord.lua +2 -0
  97. package/package.json +1 -1
  98. package/src/classes/ModFeature.ts +4 -4
  99. package/src/classes/ModUpgraded.ts +1 -1
  100. package/src/classes/features/callbackLogic/PlayerReorderedCallbacks.ts +1 -0
  101. package/src/classes/features/other/CustomItemPools.ts +10 -3
  102. package/src/classes/features/other/DisableInputs.ts +4 -1
  103. package/src/classes/features/other/ItemPoolDetection.ts +2 -2
  104. package/src/classes/features/other/ModdedElementSets.ts +6 -6
  105. package/src/classes/features/other/PickupIndexCreation.ts +1 -1
  106. package/src/classes/features/other/RunInNFrames.ts +2 -0
  107. package/src/classes/features/other/SaveDataManager.ts +3 -1
  108. package/src/core/upgradeMod.ts +4 -1
  109. package/src/functions/array.ts +18 -5
  110. package/src/functions/arrayLua.ts +20 -20
  111. package/src/functions/benchmark.ts +1 -1
  112. package/src/functions/bitwise.ts +1 -1
  113. package/src/functions/cards.ts +1 -1
  114. package/src/functions/challenges.ts +1 -1
  115. package/src/functions/curses.ts +1 -1
  116. package/src/functions/deepCopy.ts +6 -6
  117. package/src/functions/doors.ts +7 -5
  118. package/src/functions/external.ts +1 -1
  119. package/src/functions/flag.ts +5 -4
  120. package/src/functions/gridEntities.ts +5 -5
  121. package/src/functions/input.ts +5 -5
  122. package/src/functions/itemPool.ts +4 -2
  123. package/src/functions/jsonRoom.ts +1 -1
  124. package/src/functions/level.ts +2 -2
  125. package/src/functions/levelGrid.ts +2 -2
  126. package/src/functions/logEntities.ts +6 -3
  127. package/src/functions/logMisc.ts +2 -1
  128. package/src/functions/map.ts +2 -0
  129. package/src/functions/merge.ts +4 -3
  130. package/src/functions/npcDataStructures.ts +11 -3
  131. package/src/functions/playerCollectibles.ts +7 -7
  132. package/src/functions/playerDataStructures.ts +8 -3
  133. package/src/functions/playerTrinkets.ts +2 -2
  134. package/src/functions/players.ts +6 -4
  135. package/src/functions/rng.ts +8 -2
  136. package/src/functions/rooms.ts +4 -4
  137. package/src/functions/run.ts +6 -2
  138. package/src/functions/set.ts +3 -0
  139. package/src/functions/sort.ts +5 -1
  140. package/src/functions/stage.ts +5 -3
  141. package/src/functions/string.ts +3 -2
  142. package/src/functions/table.ts +4 -4
  143. package/src/functions/trinketGive.ts +1 -1
  144. package/src/functions/utils.ts +1 -1
  145. package/src/functions/vector.ts +1 -1
  146. package/src/functions/weighted.ts +2 -2
  147. package/src/index.ts +1 -0
  148. package/src/types/AnyFunction.ts +1 -1
  149. package/src/types/ReadonlyRecord.ts +3 -0
@@ -31,7 +31,7 @@ export function getCurseIDByName(name: string): LevelCurse {
31
31
  *
32
32
  * Under the hood, this function uses the `Level.GetCurses` method.
33
33
  */
34
- export function hasCurse(...curses: LevelCurse[]): boolean {
34
+ export function hasCurse(...curses: readonly LevelCurse[]): boolean {
35
35
  const level = game.GetLevel();
36
36
  const levelCurses = level.GetCurses();
37
37
 
@@ -245,7 +245,7 @@ function deepCopyDefaultMap(
245
245
  traversalDescription: string,
246
246
  classConstructors: LuaMap<string, AnyClass>,
247
247
  insideMap: boolean,
248
- ): Readonly<LuaMap<AnyNotNil, unknown>> | ReadonlyMap<AnyNotNil, unknown> {
248
+ ): ReadonlyMap<AnyNotNil, unknown> | Readonly<LuaMap<AnyNotNil, unknown>> {
249
249
  if (SAVE_DATA_MANAGER_DEBUG) {
250
250
  log("deepCopy is copying a DefaultMap.");
251
251
  }
@@ -373,12 +373,12 @@ function getNewDefaultMap(
373
373
  }
374
374
 
375
375
  function deepCopyMap(
376
- map: Map<AnyNotNil, unknown> | LuaMap<AnyNotNil, unknown>,
376
+ map: ReadonlyMap<AnyNotNil, unknown> | Readonly<LuaMap<AnyNotNil, unknown>>,
377
377
  serializationType: SerializationType,
378
378
  traversalDescription: string,
379
379
  classConstructors: LuaMap<string, AnyClass>,
380
380
  insideMap: boolean,
381
- ): Readonly<LuaMap<AnyNotNil, unknown>> | ReadonlyMap<AnyNotNil, unknown> {
381
+ ): ReadonlyMap<AnyNotNil, unknown> | Readonly<LuaMap<AnyNotNil, unknown>> {
382
382
  if (SAVE_DATA_MANAGER_DEBUG) {
383
383
  log("deepCopy is copying a Map.");
384
384
  }
@@ -427,12 +427,12 @@ function deepCopyMap(
427
427
  }
428
428
 
429
429
  function deepCopySet(
430
- set: Set<AnyNotNil> | LuaMap<AnyNotNil, unknown>,
430
+ set: ReadonlySet<AnyNotNil> | Readonly<LuaMap<AnyNotNil, unknown>>,
431
431
  serializationType: SerializationType,
432
432
  traversalDescription: string,
433
433
  classConstructors: LuaMap<string, AnyClass>,
434
434
  insideMap: boolean,
435
- ): Readonly<LuaMap<AnyNotNil, string>> | ReadonlySet<AnyNotNil> {
435
+ ): ReadonlySet<AnyNotNil> | Readonly<LuaMap<AnyNotNil, string>> {
436
436
  if (SAVE_DATA_MANAGER_DEBUG) {
437
437
  log("deepCopy is copying a Set.");
438
438
  }
@@ -555,7 +555,7 @@ function deepCopyTSTLClass(
555
555
  }
556
556
 
557
557
  function deepCopyArray(
558
- array: unknown[],
558
+ array: readonly unknown[],
559
559
  serializationType: SerializationType,
560
560
  traversalDescription: string,
561
561
  classConstructors: LuaMap<string, AnyClass>,
@@ -203,7 +203,9 @@ export function getDoorSlotsForRoomShape(
203
203
  *
204
204
  * @allowEmptyVariadic
205
205
  */
206
- export function getDoors(...roomTypes: RoomType[]): readonly GridEntityDoor[] {
206
+ export function getDoors(
207
+ ...roomTypes: readonly RoomType[]
208
+ ): readonly GridEntityDoor[] {
207
209
  const room = game.GetRoom();
208
210
  const roomShape = room.GetRoomShape();
209
211
  const roomTypesSet = new ReadonlySet(roomTypes);
@@ -240,7 +242,7 @@ export function getDoors(...roomTypes: RoomType[]): readonly GridEntityDoor[] {
240
242
  * that match any of the N room grid indexes.
241
243
  */
242
244
  export function getDoorsToRoomIndex(
243
- ...roomGridIndex: int[]
245
+ ...roomGridIndex: readonly int[]
244
246
  ): readonly GridEntityDoor[] {
245
247
  const roomGridIndexesSet = new ReadonlySet(roomGridIndex);
246
248
  const doors = getDoors();
@@ -351,7 +353,7 @@ export function getVoidDoor(): GridEntityDoor | undefined {
351
353
  * This function is variadic, meaning that you can supply as many door types as you want to check
352
354
  * for. This function will return true if one or more room types match.
353
355
  */
354
- export function hasDoorType(...roomTypes: RoomType[]): boolean {
356
+ export function hasDoorType(...roomTypes: readonly RoomType[]): boolean {
355
357
  const doors = getDoors();
356
358
  const doorsOfThisRoomType = doors.filter((door) =>
357
359
  roomTypes.some((roomType) => door.IsRoomType(roomType)),
@@ -580,7 +582,7 @@ export function openDoorFast(door: GridEntityDoor): void {
580
582
  * @returns The number of doors removed.
581
583
  * @allowEmptyVariadic
582
584
  */
583
- export function removeAllDoors(...roomTypes: RoomType[]): int {
585
+ export function removeAllDoors(...roomTypes: readonly RoomType[]): int {
584
586
  const doors = getDoors(...roomTypes);
585
587
  removeDoors(...doors);
586
588
 
@@ -598,7 +600,7 @@ export function removeDoor(door: GridEntityDoor): void {
598
600
  *
599
601
  * This function is variadic, meaning that you can specify as many doors as you want to remove.
600
602
  */
601
- export function removeDoors(...doors: GridEntityDoor[]): void {
603
+ export function removeDoors(...doors: readonly GridEntityDoor[]): void {
602
604
  for (const door of doors) {
603
605
  removeDoor(door);
604
606
  }
@@ -37,7 +37,7 @@ const REBIRTH_ITEM_TRACKER_WRITE_TO_FILE_COMMAND =
37
37
  * @see https://github.com/Rchardon/RebirthItemTracker
38
38
  */
39
39
  export function rebirthItemTrackerRemoveCollectible(
40
- ...collectibleTypes: CollectibleType[]
40
+ ...collectibleTypes: readonly CollectibleType[]
41
41
  ): void {
42
42
  for (const collectibleType of collectibleTypes) {
43
43
  // This cannot use the "log" function since the prefix will prevent the Rebirth Item Tracker
@@ -1,4 +1,5 @@
1
1
  import { DamageFlag } from "isaac-typescript-definitions";
2
+ import type { ReadonlyRecord } from "../types/ReadonlyRecord";
2
3
 
3
4
  /**
4
5
  * Helper function to add a bit flag to an existing set of bit flags.
@@ -27,7 +28,7 @@ import { DamageFlag } from "isaac-typescript-definitions";
27
28
  */
28
29
  export function addFlag<T extends BitFlag | BitFlag128>(
29
30
  flags: T | BitFlags<T>,
30
- ...flagsToAdd: T[]
31
+ ...flagsToAdd: readonly T[]
31
32
  ): BitFlags<T> {
32
33
  let flagsAsInt = flags as int;
33
34
 
@@ -64,7 +65,7 @@ export function bitFlags<T extends BitFlag | BitFlag128>(flag: T): BitFlags<T> {
64
65
  */
65
66
  export function getFlagName<T extends BitFlag | BitFlag128>(
66
67
  flag: BitFlag,
67
- flagEnum: Record<string, T>,
68
+ flagEnum: ReadonlyRecord<string, T>,
68
69
  ): string | undefined {
69
70
  for (const [key, value] of Object.entries(flagEnum)) {
70
71
  if (value === flag) {
@@ -95,7 +96,7 @@ export function getFlagName<T extends BitFlag | BitFlag128>(
95
96
  */
96
97
  export function hasFlag<T extends BitFlag | BitFlag128>(
97
98
  flags: T | BitFlags<T>,
98
- ...flagsToCheck: T[]
99
+ ...flagsToCheck: readonly T[]
99
100
  ): boolean {
100
101
  const flagsAsInt = flags as int;
101
102
 
@@ -153,7 +154,7 @@ export function isSelfDamage(
153
154
  */
154
155
  export function removeFlag<T extends BitFlag | BitFlag128>(
155
156
  flags: T | BitFlags<T>,
156
- ...flagsToRemove: T[]
157
+ ...flagsToRemove: readonly T[]
157
158
  ): BitFlags<T> {
158
159
  let flagsAsInt = flags as int;
159
160
 
@@ -227,7 +227,7 @@ export function getConstituentsFromGridEntityID(
227
227
  * @allowEmptyVariadic
228
228
  */
229
229
  export function getGridEntities(
230
- ...gridEntityTypes: GridEntityType[]
230
+ ...gridEntityTypes: readonly GridEntityType[]
231
231
  ): readonly GridEntity[] {
232
232
  const gridEntities = getAllGridEntities();
233
233
 
@@ -249,7 +249,7 @@ export function getGridEntities(
249
249
  * exclude.
250
250
  */
251
251
  export function getGridEntitiesExcept(
252
- ...gridEntityTypes: GridEntityType[]
252
+ ...gridEntityTypes: readonly GridEntityType[]
253
253
  ): readonly GridEntity[] {
254
254
  const gridEntities = getAllGridEntities();
255
255
 
@@ -335,7 +335,7 @@ export function getGridEntitiesInRadius(
335
335
  * @allowEmptyVariadic
336
336
  */
337
337
  export function getGridEntitiesMap(
338
- ...gridEntityTypes: GridEntityType[]
338
+ ...gridEntityTypes: readonly GridEntityType[]
339
339
  ): ReadonlyMap<int, GridEntity> {
340
340
  const gridEntities = getGridEntities(...gridEntityTypes);
341
341
 
@@ -885,7 +885,7 @@ export function isPostBossVoidPortal(gridEntity: GridEntity): boolean {
885
885
  * @returns The grid entities that were removed.
886
886
  */
887
887
  export function removeAllGridEntitiesExcept(
888
- ...gridEntityTypes: GridEntityType[]
888
+ ...gridEntityTypes: readonly GridEntityType[]
889
889
  ): readonly GridEntity[] {
890
890
  const gridEntityTypeExceptions = new ReadonlySet(gridEntityTypes);
891
891
  const gridEntities = getGridEntities();
@@ -925,7 +925,7 @@ export function removeAllGridEntitiesExcept(
925
925
  * @returns An array of the grid entities removed.
926
926
  */
927
927
  export function removeAllMatchingGridEntities(
928
- ...gridEntityType: GridEntityType[]
928
+ ...gridEntityType: readonly GridEntityType[]
929
929
  ): readonly GridEntity[] {
930
930
  const gridEntities = getGridEntities(...gridEntityType);
931
931
  if (gridEntities.length === 0) {
@@ -92,7 +92,7 @@ export function getShootButtonActions(
92
92
  */
93
93
  export function isActionPressed(
94
94
  controllerIndex: ControllerIndex,
95
- ...buttonActions: ButtonAction[]
95
+ ...buttonActions: readonly ButtonAction[]
96
96
  ): boolean {
97
97
  return buttonActions.some((buttonAction) =>
98
98
  Input.IsActionPressed(buttonAction, controllerIndex),
@@ -107,7 +107,7 @@ export function isActionPressed(
107
107
  * function will return true if any of the buttons are pressed.
108
108
  */
109
109
  export function isActionPressedOnAnyInput(
110
- ...buttonActions: ButtonAction[]
110
+ ...buttonActions: readonly ButtonAction[]
111
111
  ): boolean {
112
112
  return CONTROLLER_INDEX_VALUES.some((controllerIndex) =>
113
113
  isActionPressed(controllerIndex, ...buttonActions),
@@ -124,7 +124,7 @@ export function isActionPressedOnAnyInput(
124
124
  */
125
125
  export function isActionTriggered(
126
126
  controllerIndex: ControllerIndex,
127
- ...buttonActions: ButtonAction[]
127
+ ...buttonActions: readonly ButtonAction[]
128
128
  ): boolean {
129
129
  return buttonActions.some((buttonAction) =>
130
130
  Input.IsActionTriggered(buttonAction, controllerIndex),
@@ -139,7 +139,7 @@ export function isActionTriggered(
139
139
  * function will return true if any of the buttons are pressed.
140
140
  */
141
141
  export function isActionTriggeredOnAnyInput(
142
- ...buttonActions: ButtonAction[]
142
+ ...buttonActions: readonly ButtonAction[]
143
143
  ): boolean {
144
144
  return CONTROLLER_INDEX_VALUES.some((controllerIndex) =>
145
145
  isActionTriggered(controllerIndex, ...buttonActions),
@@ -152,7 +152,7 @@ export function isActionTriggeredOnAnyInput(
152
152
  * This function is variadic, meaning you can pass as many keyboard values as you want to check for.
153
153
  * This function will return true if any of the values are pressed.
154
154
  */
155
- export function isKeyboardPressed(...keys: Keyboard[]): boolean {
155
+ export function isKeyboardPressed(...keys: readonly Keyboard[]): boolean {
156
156
  return keys.some((key) =>
157
157
  Input.IsButtonPressed(key, ControllerIndex.KEYBOARD),
158
158
  );
@@ -128,7 +128,7 @@ export function isCollectibleTypeInDefaultItemPool(
128
128
  * This function is variadic, meaning you can pass as many collectible types as you want to remove.
129
129
  */
130
130
  export function removeCollectibleFromPools(
131
- ...collectibleTypes: CollectibleType[]
131
+ ...collectibleTypes: readonly CollectibleType[]
132
132
  ): void {
133
133
  const itemPool = game.GetItemPool();
134
134
 
@@ -142,7 +142,9 @@ export function removeCollectibleFromPools(
142
142
  *
143
143
  * This function is variadic, meaning you can pass as many trinket types as you want to remove.
144
144
  */
145
- export function removeTrinketFromPools(...trinketTypes: TrinketType[]): void {
145
+ export function removeTrinketFromPools(
146
+ ...trinketTypes: readonly TrinketType[]
147
+ ): void {
146
148
  const itemPool = game.GetItemPool();
147
149
 
148
150
  for (const trinketType of trinketTypes) {
@@ -164,7 +164,7 @@ export function getJSONRoomsOfSubType(
164
164
  * what the function is doing. Default is false.
165
165
  */
166
166
  export function getRandomJSONEntity(
167
- jsonEntities: JSONEntity[],
167
+ jsonEntities: readonly JSONEntity[],
168
168
  seedOrRNG: Seed | RNG | undefined,
169
169
  verbose = false,
170
170
  ): JSONEntity {
@@ -58,7 +58,7 @@ export function getLevelBossIDs(): readonly BossID[] {
58
58
  * This function is variadic, meaning that you can pass as many boss IDs as you want to check for.
59
59
  * It will return true if one or more of the boss IDs are matched.
60
60
  */
61
- export function levelHasBossID(...bossIDs: BossID[]): boolean {
61
+ export function levelHasBossID(...bossIDs: readonly BossID[]): boolean {
62
62
  const levelBossIDs = getLevelBossIDs();
63
63
  const levelBossIDsSet = new Set(levelBossIDs);
64
64
 
@@ -72,7 +72,7 @@ export function levelHasBossID(...bossIDs: BossID[]): boolean {
72
72
  * This function is variadic, meaning that you can pass as many room types as you want to check for.
73
73
  * This function will return true if any of the room types are found.
74
74
  */
75
- export function levelHasRoomType(...roomTypes: RoomType[]): boolean {
75
+ export function levelHasRoomType(...roomTypes: readonly RoomType[]): boolean {
76
76
  const roomDescriptors = getRoomDescriptorsForType(...roomTypes);
77
77
  return roomDescriptors.length > 0;
78
78
  }
@@ -318,7 +318,7 @@ export function getRoomAdjacentGridIndexes(
318
318
  * descriptors for N room types.
319
319
  */
320
320
  export function getRoomDescriptorsForType(
321
- ...roomTypes: RoomType[]
321
+ ...roomTypes: readonly RoomType[]
322
322
  ): readonly RoomDescriptor[] {
323
323
  const roomTypesSet = new Set<RoomType>(roomTypes);
324
324
 
@@ -340,7 +340,7 @@ export function getRoomDescriptorsForType(
340
340
  * indexes for N room types.
341
341
  */
342
342
  export function getRoomGridIndexesForType(
343
- ...roomTypes: RoomType[]
343
+ ...roomTypes: readonly RoomType[]
344
344
  ): readonly int[] {
345
345
  const roomDescriptors = getRoomDescriptorsForType(...roomTypes);
346
346
  return roomDescriptors.map((roomDescriptor) => roomDescriptor.SafeGridIndex);
@@ -142,7 +142,7 @@ export function logAllGridEntities(
142
142
  }
143
143
 
144
144
  /** Helper function for logging an array of specific entities. */
145
- export function logEntities(this: void, entities: Entity[]): void {
145
+ export function logEntities(this: void, entities: readonly Entity[]): void {
146
146
  for (const entity of entities) {
147
147
  logEntity(entity);
148
148
  }
@@ -295,7 +295,10 @@ function getTearVariantName(tear: EntityTear) {
295
295
  }
296
296
 
297
297
  /** Helper function for logging an array of specific grid entities. */
298
- export function logGridEntities(this: void, gridEntities: GridEntity[]): void {
298
+ export function logGridEntities(
299
+ this: void,
300
+ gridEntities: readonly GridEntity[],
301
+ ): void {
299
302
  for (const gridEntity of gridEntities) {
300
303
  logGridEntity(gridEntity);
301
304
  }
@@ -386,7 +389,7 @@ export function logPtrHash(this: void, ptrHash: PtrHash): void {
386
389
  * Helper function to log information about the entity that corresponding to one or more pointer
387
390
  * hashes. (Only use this when debugging, since retrieving the corresponding entity is expensive.)
388
391
  */
389
- export function logPtrHashes(this: void, ptrHashes: PtrHash[]): void {
392
+ export function logPtrHashes(this: void, ptrHashes: readonly PtrHash[]): void {
390
393
  for (const ptrHash of ptrHashes) {
391
394
  logPtrHash(ptrHash);
392
395
  }
@@ -20,6 +20,7 @@ import {
20
20
  } from "isaac-typescript-definitions";
21
21
  import { game, musicManager, sfxManager } from "../core/cachedClasses";
22
22
  import type { ReadonlyMap } from "../types/ReadonlyMap";
23
+ import type { ReadonlyRecord } from "../types/ReadonlyRecord";
23
24
  import { ReadonlySet } from "../types/ReadonlySet";
24
25
  import { arrayToString, isArray } from "./array";
25
26
  import { getBossID } from "./bosses";
@@ -140,7 +141,7 @@ export function logEntityID(this: void, entity: Entity): void {
140
141
  export function logFlags<T extends BitFlag | BitFlag128>(
141
142
  this: void,
142
143
  flags: T | BitFlags<T>,
143
- flagEnum: Record<string, T>,
144
+ flagEnum: ReadonlyRecord<string, T>,
144
145
  description = "",
145
146
  ): void {
146
147
  if (description !== "") {
@@ -33,6 +33,7 @@ export function defaultMapGetHash<V, A extends unknown[]>(
33
33
  * `mapSetHash` helper function.
34
34
  */
35
35
  export function defaultMapSetHash<V>(
36
+ // eslint-disable-next-line isaacscript/prefer-readonly-parameter-types
36
37
  map: Map<PtrHash, V>,
37
38
  entity: Entity,
38
39
  value: V,
@@ -78,6 +79,7 @@ export function getReversedMap<K, V>(
78
79
  * the map uses `PtrHash` as an index.
79
80
  */
80
81
  export function mapSetHash<V>(
82
+ // eslint-disable-next-line isaacscript/prefer-readonly-parameter-types
81
83
  map: Map<PtrHash, V>,
82
84
  entity: Entity,
83
85
  value: V,
@@ -53,9 +53,9 @@ import { getTraversalDescription } from "./utils";
53
53
  */
54
54
  export function merge(
55
55
  oldObject:
56
- | LuaMap<AnyNotNil, unknown>
57
- | Map<AnyNotNil, unknown>
58
- | Set<AnyNotNil>,
56
+ | Readonly<LuaMap<AnyNotNil, unknown>>
57
+ | ReadonlyMap<AnyNotNil, unknown>
58
+ | ReadonlySet<AnyNotNil>,
59
59
  newTable: LuaMap<AnyNotNil, unknown>,
60
60
  traversalDescription: string,
61
61
  classConstructors = new LuaMap<string, AnyClass>(),
@@ -131,6 +131,7 @@ function mergeSerializedArray(
131
131
  }
132
132
 
133
133
  function mergeSerializedTSTLObject(
134
+ // eslint-disable-next-line isaacscript/prefer-readonly-parameter-types
134
135
  oldObject: Map<AnyNotNil, unknown> | Set<AnyNotNil>,
135
136
  newTable: LuaMap<AnyNotNil, unknown>,
136
137
  traversalDescription: string,
@@ -41,6 +41,7 @@ export function defaultMapGetNPC<V, Args extends unknown[]>(
41
41
  * `mapSetNPC` helper function.
42
42
  */
43
43
  export function defaultMapSetNPC<V>(
44
+ // eslint-disable-next-line isaacscript/prefer-readonly-parameter-types
44
45
  map: Map<PtrHash, V>,
45
46
  npc: EntityNPC,
46
47
  value: V,
@@ -53,6 +54,7 @@ export function defaultMapSetNPC<V>(
53
54
  * `Map.delete` method if you have a set of this type.
54
55
  */
55
56
  export function mapDeleteNPC(
57
+ // eslint-disable-next-line isaacscript/prefer-readonly-parameter-types
56
58
  map: Map<PtrHash, unknown>,
57
59
  npc: EntityNPC,
58
60
  ): boolean {
@@ -81,7 +83,7 @@ export function mapDeleteNPC(
81
83
  * ```
82
84
  */
83
85
  export function mapGetNPC<V>(
84
- map: Map<PtrHash, V>,
86
+ map: ReadonlyMap<PtrHash, V>,
85
87
  npc: EntityNPC,
86
88
  ): V | undefined {
87
89
  const ptrHash = GetPtrHash(npc);
@@ -92,7 +94,10 @@ export function mapGetNPC<V>(
92
94
  * Helper function to make using maps with an index of `PtrHash` easier. Use this instead of the
93
95
  * `Map.has` method if you have a map of this type.
94
96
  */
95
- export function mapHasNPC<V>(map: Map<PtrHash, V>, npc: EntityNPC): boolean {
97
+ export function mapHasNPC<V>(
98
+ map: ReadonlyMap<PtrHash, V>,
99
+ npc: EntityNPC,
100
+ ): boolean {
96
101
  const ptrHash = GetPtrHash(npc);
97
102
  return map.has(ptrHash);
98
103
  }
@@ -118,6 +123,7 @@ export function mapHasNPC<V>(map: Map<PtrHash, V>, npc: EntityNPC): boolean {
118
123
  * ```
119
124
  */
120
125
  export function mapSetNPC<V>(
126
+ // eslint-disable-next-line isaacscript/prefer-readonly-parameter-types
121
127
  map: Map<PtrHash, V>,
122
128
  npc: EntityNPC,
123
129
  value: V,
@@ -130,6 +136,7 @@ export function mapSetNPC<V>(
130
136
  * Helper function to make using sets with an type of `PtrHash` easier. Use this instead of the
131
137
  * `Set.add` method if you have a set of this type.
132
138
  */
139
+ // eslint-disable-next-line isaacscript/prefer-readonly-parameter-types
133
140
  export function setAddNPC(set: Set<PtrHash>, npc: EntityNPC): void {
134
141
  const ptrHash = GetPtrHash(npc);
135
142
  set.add(ptrHash);
@@ -139,6 +146,7 @@ export function setAddNPC(set: Set<PtrHash>, npc: EntityNPC): void {
139
146
  * Helper function to make using sets with an type of `PtrHash` easier. Use this instead of the
140
147
  * `Set.delete` method if you have a set of this type.
141
148
  */
149
+ // eslint-disable-next-line isaacscript/prefer-readonly-parameter-types
142
150
  export function setDeleteNPC(set: Set<PtrHash>, npc: EntityNPC): boolean {
143
151
  const ptrHash = GetPtrHash(npc);
144
152
  return set.delete(ptrHash);
@@ -148,7 +156,7 @@ export function setDeleteNPC(set: Set<PtrHash>, npc: EntityNPC): boolean {
148
156
  * Helper function to make using sets with an type of `PtrHash` easier. Use this instead of the
149
157
  * `Set.has` method if you have a set of this type.
150
158
  */
151
- export function setHasNPC(set: Set<PtrHash>, npc: EntityNPC): boolean {
159
+ export function setHasNPC(set: ReadonlySet<PtrHash>, npc: EntityNPC): boolean {
152
160
  const ptrHash = GetPtrHash(npc);
153
161
  return set.has(ptrHash);
154
162
  }
@@ -19,7 +19,7 @@ import { isCharacter } from "./players";
19
19
  */
20
20
  export function addCollectible(
21
21
  player: EntityPlayer,
22
- ...collectibleTypes: CollectibleType[]
22
+ ...collectibleTypes: readonly CollectibleType[]
23
23
  ): void {
24
24
  for (const collectibleType of collectibleTypes) {
25
25
  player.AddCollectible(collectibleType);
@@ -93,7 +93,7 @@ export function getAdjustedPrice(basePrice: int): int {
93
93
  */
94
94
  export function getPlayerCollectibleCount(
95
95
  player: EntityPlayer,
96
- ...collectibleTypes: CollectibleType[]
96
+ ...collectibleTypes: readonly CollectibleType[]
97
97
  ): int {
98
98
  let numCollectibles = 0;
99
99
  for (const collectibleType of collectibleTypes) {
@@ -111,7 +111,7 @@ export function getPlayerCollectibleCount(
111
111
  * check for. It only returns the players that have all of the collectibles.
112
112
  */
113
113
  export function getPlayersWithCollectible(
114
- ...collectibleTypes: CollectibleType[]
114
+ ...collectibleTypes: readonly CollectibleType[]
115
115
  ): readonly EntityPlayer[] {
116
116
  const players = getPlayers();
117
117
 
@@ -150,7 +150,7 @@ export function getTotalPlayerCollectibles(
150
150
  */
151
151
  export function hasCollectible(
152
152
  player: EntityPlayer,
153
- ...collectibleTypes: CollectibleType[]
153
+ ...collectibleTypes: readonly CollectibleType[]
154
154
  ): boolean {
155
155
  return collectibleTypes.some((collectibleType) =>
156
156
  player.HasCollectible(collectibleType),
@@ -168,7 +168,7 @@ export function hasCollectible(
168
168
  export function hasCollectibleInActiveSlot(
169
169
  player: EntityPlayer,
170
170
  collectibleType: CollectibleType,
171
- ...activeSlots: ActiveSlot[]
171
+ ...activeSlots: readonly ActiveSlot[]
172
172
  ): boolean {
173
173
  const matchingActiveSlotsSet = new ReadonlySet(activeSlots);
174
174
  const activeItemSlots = getActiveItemSlots(player, collectibleType);
@@ -245,7 +245,7 @@ export function removeAllActiveItems(player: EntityPlayer): void {
245
245
  */
246
246
  export function removeCollectible(
247
247
  player: EntityPlayer,
248
- ...collectibleTypes: CollectibleType[]
248
+ ...collectibleTypes: readonly CollectibleType[]
249
249
  ): void {
250
250
  for (const collectibleType of collectibleTypes) {
251
251
  player.RemoveCollectible(collectibleType);
@@ -276,7 +276,7 @@ export function removeCollectibleCostume(
276
276
  * remove.
277
277
  */
278
278
  export function removeCollectibleFromAllPlayers(
279
- ...collectibleTypes: CollectibleType[]
279
+ ...collectibleTypes: readonly CollectibleType[]
280
280
  ): void {
281
281
  for (const player of getAllPlayers()) {
282
282
  for (const collectibleType of collectibleTypes) {
@@ -39,6 +39,7 @@ export function defaultMapGetPlayer<V, Args extends unknown[]>(
39
39
  * `mapSetPlayer` helper function.
40
40
  */
41
41
  export function defaultMapSetPlayer<V>(
42
+ // eslint-disable-next-line isaacscript/prefer-readonly-parameter-types
42
43
  map: Map<PlayerIndex, V>,
43
44
  player: EntityPlayer,
44
45
  value: V,
@@ -51,6 +52,7 @@ export function defaultMapSetPlayer<V>(
51
52
  * `Map.delete` method if you have a set of this type.
52
53
  */
53
54
  export function mapDeletePlayer(
55
+ // eslint-disable-next-line isaacscript/prefer-readonly-parameter-types
54
56
  map: Map<PlayerIndex, unknown>,
55
57
  player: EntityPlayer,
56
58
  ): boolean {
@@ -79,7 +81,7 @@ export function mapDeletePlayer(
79
81
  * ```
80
82
  */
81
83
  export function mapGetPlayer<V>(
82
- map: Map<PlayerIndex, V>,
84
+ map: ReadonlyMap<PlayerIndex, V>,
83
85
  player: EntityPlayer,
84
86
  ): V | undefined {
85
87
  const playerIndex = getPlayerIndex(player);
@@ -91,7 +93,7 @@ export function mapGetPlayer<V>(
91
93
  * `Map.has` method if you have a map of this type.
92
94
  */
93
95
  export function mapHasPlayer<V>(
94
- map: Map<PlayerIndex, V>,
96
+ map: ReadonlyMap<PlayerIndex, V>,
95
97
  player: EntityPlayer,
96
98
  ): boolean {
97
99
  const playerIndex = getPlayerIndex(player);
@@ -119,6 +121,7 @@ export function mapHasPlayer<V>(
119
121
  * ```
120
122
  */
121
123
  export function mapSetPlayer<V>(
124
+ // eslint-disable-next-line isaacscript/prefer-readonly-parameter-types
122
125
  map: Map<PlayerIndex, V>,
123
126
  player: EntityPlayer,
124
127
  value: V,
@@ -132,6 +135,7 @@ export function mapSetPlayer<V>(
132
135
  * `Set.add` method if you have a set of this type.
133
136
  */
134
137
  export function setAddPlayer(
138
+ // eslint-disable-next-line isaacscript/prefer-readonly-parameter-types
135
139
  set: Set<PlayerIndex>,
136
140
  player: EntityPlayer,
137
141
  ): void {
@@ -144,6 +148,7 @@ export function setAddPlayer(
144
148
  * `Set.delete` method if you have a set of this type.
145
149
  */
146
150
  export function setDeletePlayer(
151
+ // eslint-disable-next-line isaacscript/prefer-readonly-parameter-types
147
152
  set: Set<PlayerIndex>,
148
153
  player: EntityPlayer,
149
154
  ): boolean {
@@ -156,7 +161,7 @@ export function setDeletePlayer(
156
161
  * `Set.has` method if you have a set of this type.
157
162
  */
158
163
  export function setHasPlayer(
159
- set: Set<PlayerIndex>,
164
+ set: ReadonlySet<PlayerIndex>,
160
165
  player: EntityPlayer,
161
166
  ): boolean {
162
167
  const playerIndex = getPlayerIndex(player);
@@ -98,7 +98,7 @@ export function getPlayerTrinkets(
98
98
  * for. It only returns the players that have all of the trinkets.
99
99
  */
100
100
  export function getPlayersWithTrinket(
101
- ...trinketTypes: TrinketType[]
101
+ ...trinketTypes: readonly TrinketType[]
102
102
  ): readonly EntityPlayer[] {
103
103
  const players = getPlayers();
104
104
 
@@ -143,7 +143,7 @@ export function hasOpenTrinketSlot(player: EntityPlayer): boolean {
143
143
  */
144
144
  export function hasTrinket(
145
145
  player: EntityPlayer,
146
- ...trinketTypes: TrinketType[]
146
+ ...trinketTypes: readonly TrinketType[]
147
147
  ): boolean {
148
148
  return trinketTypes.some((trinketType) => player.HasTrinket(trinketType));
149
149
  }
@@ -34,7 +34,9 @@ export function anyPlayerHoldingItem(): boolean {
34
34
  * This function is variadic, meaning that you can supply as many characters as you want to check
35
35
  * for. Returns true if any of the characters supplied are present.
36
36
  */
37
- export function anyPlayerIs(...matchingCharacters: PlayerType[]): boolean {
37
+ export function anyPlayerIs(
38
+ ...matchingCharacters: readonly PlayerType[]
39
+ ): boolean {
38
40
  const matchingCharacterSet = new ReadonlySet(matchingCharacters);
39
41
  const characters = getCharacters();
40
42
 
@@ -271,7 +273,7 @@ export function getPlayerNumHitsRemaining(player: EntityPlayer): int {
271
273
  * for. Returns true if any of the characters supplied are present.
272
274
  */
273
275
  export function getPlayersOfType(
274
- ...characters: PlayerType[]
276
+ ...characters: readonly PlayerType[]
275
277
  ): readonly EntityPlayer[] {
276
278
  const charactersSet = new ReadonlySet(characters);
277
279
  const players = getPlayers();
@@ -321,7 +323,7 @@ export function getPlayersWithControllerIndex(
321
323
  */
322
324
  export function hasForm(
323
325
  player: EntityPlayer,
324
- ...playerForms: PlayerForm[]
326
+ ...playerForms: readonly PlayerForm[]
325
327
  ): boolean {
326
328
  return playerForms.some((playerForm) => player.HasPlayerForm(playerForm));
327
329
  }
@@ -379,7 +381,7 @@ export function isBethany(player: EntityPlayer): boolean {
379
381
  */
380
382
  export function isCharacter(
381
383
  player: EntityPlayer,
382
- ...characters: PlayerType[]
384
+ ...characters: readonly PlayerType[]
383
385
  ): boolean {
384
386
  const characterSet = new ReadonlySet(characters);
385
387
  const character = player.GetPlayerType();