isaacscript-common 6.6.4 → 6.7.1

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 (250) hide show
  1. package/dist/callbacks/customRevive.lua +4 -4
  2. package/dist/callbacks/postCursedTeleport.lua +2 -2
  3. package/dist/callbacks/postCustomDoorEnter.d.ts +1 -1
  4. package/dist/callbacks/postCustomDoorEnter.lua +6 -6
  5. package/dist/callbacks/postDiceRoomActivated.lua +2 -2
  6. package/dist/callbacks/postFlip.lua +3 -3
  7. package/dist/callbacks/postGridEntity.lua +3 -3
  8. package/dist/callbacks/postGridEntityCollision.lua +3 -3
  9. package/dist/callbacks/postGridEntityRender.lua +2 -2
  10. package/dist/callbacks/postNewRoomEarly.lua +5 -5
  11. package/dist/callbacks/postPickupCollect.lua +2 -2
  12. package/dist/callbacks/postPitRender.lua +2 -2
  13. package/dist/callbacks/postPitUpdate.lua +2 -2
  14. package/dist/callbacks/postPlayerCollectible.lua +2 -2
  15. package/dist/callbacks/postPoopRender.lua +2 -2
  16. package/dist/callbacks/postPoopUpdate.lua +2 -2
  17. package/dist/callbacks/postPressurePlateRender.lua +2 -2
  18. package/dist/callbacks/postPressurePlateUpdate.lua +2 -2
  19. package/dist/callbacks/postPurchase.lua +2 -2
  20. package/dist/callbacks/postRockRender.lua +2 -2
  21. package/dist/callbacks/postRockUpdate.lua +2 -2
  22. package/dist/callbacks/postSlotInitUpdate.lua +2 -2
  23. package/dist/callbacks/postSlotRender.lua +2 -2
  24. package/dist/callbacks/postSpikesRender.lua +2 -2
  25. package/dist/callbacks/postSpikesUpdate.lua +2 -2
  26. package/dist/callbacks/postTNTRender.lua +2 -2
  27. package/dist/callbacks/postTNTUpdate.lua +2 -2
  28. package/dist/callbacks/preBerserkDeath.lua +2 -2
  29. package/dist/callbacks/preNewLevel.lua +2 -2
  30. package/dist/callbacks/subscriptions/postDoorRender.d.ts +2 -3
  31. package/dist/callbacks/subscriptions/postDoorRender.d.ts.map +1 -1
  32. package/dist/callbacks/subscriptions/postDoorRender.lua +3 -3
  33. package/dist/callbacks/subscriptions/postDoorUpdate.d.ts +2 -3
  34. package/dist/callbacks/subscriptions/postDoorUpdate.d.ts.map +1 -1
  35. package/dist/callbacks/subscriptions/postDoorUpdate.lua +3 -3
  36. package/dist/callbacks/subscriptions/postPitRender.d.ts +2 -3
  37. package/dist/callbacks/subscriptions/postPitRender.d.ts.map +1 -1
  38. package/dist/callbacks/subscriptions/postPitRender.lua +3 -3
  39. package/dist/callbacks/subscriptions/postPitUpdate.d.ts +2 -3
  40. package/dist/callbacks/subscriptions/postPitUpdate.d.ts.map +1 -1
  41. package/dist/callbacks/subscriptions/postPitUpdate.lua +3 -3
  42. package/dist/callbacks/subscriptions/postPoopRender.d.ts +2 -3
  43. package/dist/callbacks/subscriptions/postPoopRender.d.ts.map +1 -1
  44. package/dist/callbacks/subscriptions/postPoopRender.lua +3 -3
  45. package/dist/callbacks/subscriptions/postPoopUpdate.d.ts +2 -3
  46. package/dist/callbacks/subscriptions/postPoopUpdate.d.ts.map +1 -1
  47. package/dist/callbacks/subscriptions/postPoopUpdate.lua +3 -3
  48. package/dist/callbacks/subscriptions/postPressurePlateRender.d.ts +2 -3
  49. package/dist/callbacks/subscriptions/postPressurePlateRender.d.ts.map +1 -1
  50. package/dist/callbacks/subscriptions/postPressurePlateRender.lua +3 -3
  51. package/dist/callbacks/subscriptions/postPressurePlateUpdate.d.ts +2 -3
  52. package/dist/callbacks/subscriptions/postPressurePlateUpdate.d.ts.map +1 -1
  53. package/dist/callbacks/subscriptions/postPressurePlateUpdate.lua +3 -3
  54. package/dist/enums/private/SerializationBrand.d.ts +0 -4
  55. package/dist/enums/private/SerializationBrand.d.ts.map +1 -1
  56. package/dist/features/characterStats.lua +2 -2
  57. package/dist/features/collectibleItemPoolType.lua +2 -2
  58. package/dist/features/customGridEntity.d.ts.map +1 -1
  59. package/dist/features/customGridEntity.lua +5 -5
  60. package/dist/features/customStage/backdrop.lua +2 -2
  61. package/dist/features/customStage/{gridEntities.d.ts → customStageGridEntities.d.ts} +1 -1
  62. package/dist/features/customStage/customStageGridEntities.d.ts.map +1 -0
  63. package/dist/features/customStage/{gridEntities.lua → customStageGridEntities.lua} +8 -8
  64. package/dist/features/customStage/{util.d.ts → customStageUtils.d.ts} +1 -1
  65. package/dist/features/customStage/customStageUtils.d.ts.map +1 -0
  66. package/dist/features/customStage/{util.lua → customStageUtils.lua} +0 -0
  67. package/dist/features/customStage/exports.lua +4 -4
  68. package/dist/features/customStage/init.lua +6 -6
  69. package/dist/features/customStage/shadows.lua +2 -2
  70. package/dist/features/customStage/versusScreen.lua +4 -4
  71. package/dist/features/debugDisplay/v.lua +4 -4
  72. package/dist/features/deployJSONRoom.lua +20 -20
  73. package/dist/features/extraConsoleCommands/commandsSubroutines.lua +3 -3
  74. package/dist/features/extraConsoleCommands/listCommands.d.ts.map +1 -1
  75. package/dist/features/extraConsoleCommands/listCommands.lua +14 -14
  76. package/dist/features/pause.lua +2 -2
  77. package/dist/features/persistentEntities.lua +2 -2
  78. package/dist/features/preventCollectibleRotation.lua +2 -2
  79. package/dist/features/saveDataManager/exports.d.ts.map +1 -1
  80. package/dist/features/sirenHelpers.lua +2 -2
  81. package/dist/functions/ambush.lua +5 -5
  82. package/dist/functions/{boss.d.ts → bosses.d.ts} +22 -4
  83. package/dist/functions/bosses.d.ts.map +1 -0
  84. package/dist/functions/{boss.lua → bosses.lua} +38 -13
  85. package/dist/functions/collectibleTag.lua +2 -2
  86. package/dist/functions/collectibles.lua +5 -5
  87. package/dist/functions/deepCopy.d.ts +8 -5
  88. package/dist/functions/deepCopy.d.ts.map +1 -1
  89. package/dist/functions/deepCopy.lua +142 -38
  90. package/dist/functions/{entity.d.ts → entities.d.ts} +21 -19
  91. package/dist/functions/entities.d.ts.map +1 -0
  92. package/dist/functions/{entity.lua → entities.lua} +25 -20
  93. package/dist/functions/{entitySpecific.d.ts → entitiesSpecific.d.ts} +145 -68
  94. package/dist/functions/entitiesSpecific.d.ts.map +1 -0
  95. package/dist/functions/{entitySpecific.lua → entitiesSpecific.lua} +203 -65
  96. package/dist/functions/familiars.lua +2 -2
  97. package/dist/functions/{gridEntity.d.ts → gridEntities.d.ts} +48 -17
  98. package/dist/functions/gridEntities.d.ts.map +1 -0
  99. package/dist/functions/{gridEntity.lua → gridEntities.lua} +140 -90
  100. package/dist/functions/gridEntitiesSpecific.d.ts +141 -0
  101. package/dist/functions/gridEntitiesSpecific.d.ts.map +1 -0
  102. package/dist/functions/gridEntitiesSpecific.lua +366 -0
  103. package/dist/functions/log.d.ts +1 -1
  104. package/dist/functions/log.lua +9 -9
  105. package/dist/functions/{npc.d.ts → npcs.d.ts} +24 -2
  106. package/dist/functions/npcs.d.ts.map +1 -0
  107. package/dist/functions/{npc.lua → npcs.lua} +44 -9
  108. package/dist/functions/pickups.d.ts +4 -119
  109. package/dist/functions/pickups.d.ts.map +1 -1
  110. package/dist/functions/pickups.lua +10 -439
  111. package/dist/functions/pickupsSpecific.d.ts +229 -0
  112. package/dist/functions/pickupsSpecific.d.ts.map +1 -0
  113. package/dist/functions/pickupsSpecific.lua +560 -0
  114. package/dist/functions/playerHealth.lua +6 -6
  115. package/dist/functions/{player.d.ts → players.d.ts} +1 -1
  116. package/dist/functions/players.d.ts.map +1 -0
  117. package/dist/functions/{player.lua → players.lua} +0 -0
  118. package/dist/functions/pocketItems.lua +2 -2
  119. package/dist/functions/positionVelocity.lua +6 -6
  120. package/dist/functions/pressurePlate.d.ts +10 -0
  121. package/dist/functions/pressurePlate.d.ts.map +1 -0
  122. package/dist/functions/pressurePlate.lua +29 -0
  123. package/dist/functions/revive.lua +7 -7
  124. package/dist/functions/rooms.lua +2 -2
  125. package/dist/functions/saveFile.lua +3 -3
  126. package/dist/functions/spawnCollectible.lua +4 -4
  127. package/dist/functions/{sprite.d.ts → sprites.d.ts} +1 -1
  128. package/dist/functions/sprites.d.ts.map +1 -0
  129. package/dist/functions/{sprite.lua → sprites.lua} +0 -0
  130. package/dist/functions/table.d.ts +1 -1
  131. package/dist/functions/table.lua +1 -1
  132. package/dist/functions/transformations.lua +2 -2
  133. package/dist/functions/trinketGive.lua +2 -2
  134. package/dist/functions/trinkets.lua +6 -6
  135. package/dist/functions/utils.d.ts +7 -0
  136. package/dist/functions/utils.d.ts.map +1 -1
  137. package/dist/functions/utils.lua +35 -22
  138. package/dist/index.d.ts +10 -8
  139. package/dist/index.d.ts.map +1 -1
  140. package/dist/index.lua +26 -10
  141. package/dist/types/AnyGridEntity.d.ts +10 -0
  142. package/dist/types/AnyGridEntity.d.ts.map +1 -0
  143. package/dist/types/AnyGridEntity.lua +2 -0
  144. package/package.json +2 -2
  145. package/src/callbacks/customRevive.ts +2 -2
  146. package/src/callbacks/postCursedTeleport.ts +2 -2
  147. package/src/callbacks/postCustomDoorEnter.ts +3 -3
  148. package/src/callbacks/postDiceRoomActivated.ts +1 -1
  149. package/src/callbacks/postFlip.ts +1 -1
  150. package/src/callbacks/postGridEntity.ts +1 -1
  151. package/src/callbacks/postGridEntityCollision.ts +1 -1
  152. package/src/callbacks/postGridEntityRender.ts +1 -1
  153. package/src/callbacks/postNewRoomEarly.ts +9 -3
  154. package/src/callbacks/postPickupCollect.ts +1 -1
  155. package/src/callbacks/postPitRender.ts +1 -1
  156. package/src/callbacks/postPitUpdate.ts +1 -1
  157. package/src/callbacks/postPlayerCollectible.ts +2 -2
  158. package/src/callbacks/postPoopRender.ts +1 -1
  159. package/src/callbacks/postPoopUpdate.ts +1 -1
  160. package/src/callbacks/postPressurePlateRender.ts +1 -1
  161. package/src/callbacks/postPressurePlateUpdate.ts +1 -1
  162. package/src/callbacks/postPurchase.ts +1 -1
  163. package/src/callbacks/postRockRender.ts +1 -1
  164. package/src/callbacks/postRockUpdate.ts +1 -1
  165. package/src/callbacks/postSacrifice.ts +1 -1
  166. package/src/callbacks/postSlotInitUpdate.ts +1 -1
  167. package/src/callbacks/postSlotRender.ts +1 -1
  168. package/src/callbacks/postSpikesRender.ts +1 -1
  169. package/src/callbacks/postSpikesUpdate.ts +1 -1
  170. package/src/callbacks/postTNTRender.ts +1 -1
  171. package/src/callbacks/postTNTUpdate.ts +1 -1
  172. package/src/callbacks/preBerserkDeath.ts +1 -1
  173. package/src/callbacks/preNewLevel.ts +1 -1
  174. package/src/callbacks/subscriptions/postDoorRender.ts +7 -5
  175. package/src/callbacks/subscriptions/postDoorUpdate.ts +7 -5
  176. package/src/callbacks/subscriptions/postPitRender.ts +6 -7
  177. package/src/callbacks/subscriptions/postPitUpdate.ts +6 -7
  178. package/src/callbacks/subscriptions/postPoopRender.ts +7 -5
  179. package/src/callbacks/subscriptions/postPoopUpdate.ts +7 -5
  180. package/src/callbacks/subscriptions/postPressurePlateRender.ts +7 -5
  181. package/src/callbacks/subscriptions/postPressurePlateUpdate.ts +7 -5
  182. package/src/enums/private/SerializationBrand.ts +0 -4
  183. package/src/features/characterStats.ts +1 -1
  184. package/src/features/collectibleItemPoolType.ts +1 -1
  185. package/src/features/customGridEntity.ts +6 -3
  186. package/src/features/customStage/backdrop.ts +1 -1
  187. package/src/features/customStage/{gridEntities.ts → customStageGridEntities.ts} +3 -3
  188. package/src/features/customStage/{util.ts → customStageUtils.ts} +0 -0
  189. package/src/features/customStage/exports.ts +2 -2
  190. package/src/features/customStage/init.ts +1 -1
  191. package/src/features/customStage/shadows.ts +1 -1
  192. package/src/features/customStage/versusScreen.ts +2 -2
  193. package/src/features/debugDisplay/v.ts +2 -2
  194. package/src/features/deployJSONRoom.ts +11 -7
  195. package/src/features/extraConsoleCommands/commandsSubroutines.ts +2 -2
  196. package/src/features/extraConsoleCommands/listCommands.ts +13 -9
  197. package/src/features/pause.ts +1 -1
  198. package/src/features/persistentEntities.ts +2 -2
  199. package/src/features/preventCollectibleRotation.ts +1 -1
  200. package/src/features/saveDataManager/exports.ts +7 -4
  201. package/src/features/sirenHelpers.ts +1 -1
  202. package/src/functions/ambush.ts +2 -2
  203. package/src/functions/array.ts +1 -1
  204. package/src/functions/bitwise.ts +2 -2
  205. package/src/functions/{boss.ts → bosses.ts} +29 -21
  206. package/src/functions/collectibleTag.ts +1 -1
  207. package/src/functions/collectibles.ts +2 -2
  208. package/src/functions/deepCopy.ts +98 -19
  209. package/src/functions/deepCopyTests.ts +6 -4
  210. package/src/functions/{entity.ts → entities.ts} +23 -21
  211. package/src/functions/{entitySpecific.ts → entitiesSpecific.ts} +170 -99
  212. package/src/functions/familiars.ts +1 -1
  213. package/src/functions/{gridEntity.ts → gridEntities.ts} +110 -34
  214. package/src/functions/gridEntitiesSpecific.ts +490 -0
  215. package/src/functions/log.ts +6 -6
  216. package/src/functions/{npc.ts → npcs.ts} +42 -11
  217. package/src/functions/pickups.ts +8 -475
  218. package/src/functions/pickupsSpecific.ts +613 -0
  219. package/src/functions/playerHealth.ts +1 -1
  220. package/src/functions/{player.ts → players.ts} +0 -0
  221. package/src/functions/pocketItems.ts +1 -1
  222. package/src/functions/positionVelocity.ts +3 -3
  223. package/src/functions/pressurePlate.ts +29 -0
  224. package/src/functions/revive.ts +2 -2
  225. package/src/functions/rooms.ts +1 -1
  226. package/src/functions/saveFile.ts +1 -1
  227. package/src/functions/spawnCollectible.ts +2 -2
  228. package/src/functions/{sprite.ts → sprites.ts} +0 -0
  229. package/src/functions/table.ts +1 -1
  230. package/src/functions/transformations.ts +1 -1
  231. package/src/functions/trinketGive.ts +4 -4
  232. package/src/functions/trinkets.ts +3 -3
  233. package/src/functions/tstlClass.ts +1 -1
  234. package/src/functions/ui.ts +3 -3
  235. package/src/functions/utils.ts +32 -13
  236. package/src/index.ts +10 -8
  237. package/src/types/AnyGridEntity.ts +9 -0
  238. package/dist/features/customStage/gridEntities.d.ts.map +0 -1
  239. package/dist/features/customStage/util.d.ts.map +0 -1
  240. package/dist/functions/boss.d.ts.map +0 -1
  241. package/dist/functions/entity.d.ts.map +0 -1
  242. package/dist/functions/entitySpecific.d.ts.map +0 -1
  243. package/dist/functions/gridEntity.d.ts.map +0 -1
  244. package/dist/functions/gridEntitySpecific.d.ts +0 -29
  245. package/dist/functions/gridEntitySpecific.d.ts.map +0 -1
  246. package/dist/functions/gridEntitySpecific.lua +0 -114
  247. package/dist/functions/npc.d.ts.map +0 -1
  248. package/dist/functions/player.d.ts.map +0 -1
  249. package/dist/functions/sprite.d.ts.map +0 -1
  250. package/src/functions/gridEntitySpecific.ts +0 -143
@@ -8,7 +8,7 @@ import {
8
8
  import { game } from "../../cachedClasses";
9
9
  import { HealthType } from "../../enums/HealthType";
10
10
  import { directionToVector } from "../../functions/direction";
11
- import { spawnGridWithVariant } from "../../functions/gridEntity";
11
+ import { spawnGridEntityWithVariant } from "../../functions/gridEntities";
12
12
  import { logEntities, logGridEntities } from "../../functions/log";
13
13
  import { addPlayerHealthType } from "../../functions/playerHealth";
14
14
  import { getRoomData, getRoomDescriptor } from "../../functions/roomData";
@@ -118,7 +118,7 @@ export function spawnTrapdoorOrCrawlSpace(trapdoor: boolean): void {
118
118
  ? GridEntityType.TRAPDOOR
119
119
  : GridEntityType.CRAWL_SPACE;
120
120
 
121
- spawnGridWithVariant(gridEntityType, 0, gridIndex);
121
+ spawnGridEntityWithVariant(gridEntityType, 0, gridIndex);
122
122
  }
123
123
 
124
124
  export function warpToRoomType(roomType: RoomType): void {
@@ -53,10 +53,10 @@ import { getCardName } from "../../functions/cards";
53
53
  import { getCharacterName } from "../../functions/character";
54
54
  import { addCharge } from "../../functions/charge";
55
55
  import { isValidCollectibleType } from "../../functions/collectibles";
56
- import { getNPCs } from "../../functions/entitySpecific";
56
+ import { getNPCs } from "../../functions/entitiesSpecific";
57
57
  import { getEnumValues } from "../../functions/enums";
58
58
  import { addFlag } from "../../functions/flag";
59
- import { spawnGrid } from "../../functions/gridEntity";
59
+ import { spawnGridEntity } from "../../functions/gridEntities";
60
60
  import {
61
61
  logEffects,
62
62
  logRoom,
@@ -64,15 +64,19 @@ import {
64
64
  logSounds,
65
65
  } from "../../functions/log";
66
66
  import { getMapPartialMatch } from "../../functions/map";
67
- import { spawnCard, spawnPill, spawnTrinket } from "../../functions/pickups";
67
+ import {
68
+ spawnCard,
69
+ spawnPill,
70
+ spawnTrinket,
71
+ } from "../../functions/pickupsSpecific";
68
72
  import { getPillEffectName } from "../../functions/pills";
73
+ import { getPlayers } from "../../functions/playerIndex";
69
74
  import {
70
75
  addCollectibleCostume,
71
76
  getPlayerName,
72
77
  removeCollectibleCostume,
73
78
  useActiveItemTemp,
74
- } from "../../functions/player";
75
- import { getPlayers } from "../../functions/playerIndex";
79
+ } from "../../functions/players";
76
80
  import { gridCoordinatesToWorldPosition } from "../../functions/roomGrid";
77
81
  import { changeRoom, getRoomGridIndexesForType } from "../../functions/rooms";
78
82
  import { onSetSeed, restart, setUnseeded } from "../../functions/run";
@@ -337,7 +341,7 @@ export function cards(): void {
337
341
 
338
342
  const position = gridCoordinatesToWorldPosition(x, y);
339
343
  spawnCard(cardType as Card, position);
340
- cardType += 1;
344
+ cardType++;
341
345
  }
342
346
  }
343
347
  }
@@ -647,14 +651,14 @@ export function gridEntities(): void {
647
651
  let gridEntityTypeIndex = -1;
648
652
  for (let y = 0; y <= 6; y++) {
649
653
  for (let x = 0; x <= 12; x++) {
650
- gridEntityTypeIndex += 1;
654
+ gridEntityTypeIndex++;
651
655
  const gridEntityType = gridEntityTypes[gridEntityTypeIndex];
652
656
  if (gridEntityType === undefined) {
653
657
  return;
654
658
  }
655
659
 
656
660
  const position = gridCoordinatesToWorldPosition(x, y);
657
- spawnGrid(gridEntityType, position);
661
+ spawnGridEntity(gridEntityType, position);
658
662
  }
659
663
  }
660
664
  }
@@ -884,7 +888,7 @@ export function pills(): void {
884
888
  let pillColorIndex = -1;
885
889
  for (let y = 0; y <= 6; y++) {
886
890
  for (let x = 0; x <= 12; x++) {
887
- pillColorIndex += 1;
891
+ pillColorIndex++;
888
892
  const pillColor = pillColors[pillColorIndex];
889
893
  if (pillColor === undefined) {
890
894
  return;
@@ -5,7 +5,7 @@ import {
5
5
  ModCallback,
6
6
  } from "isaac-typescript-definitions";
7
7
  import { logError } from "../functions/log";
8
- import { useActiveItemTemp } from "../functions/player";
8
+ import { useActiveItemTemp } from "../functions/players";
9
9
  import { disableAllInputsExceptFor, enableAllInputs } from "./disableInputs";
10
10
  import { saveDataManager } from "./saveDataManager/exports";
11
11
 
@@ -7,7 +7,7 @@ import { game } from "../cachedClasses";
7
7
  import { ModUpgraded } from "../classes/ModUpgraded";
8
8
  import { ModCallbackCustom } from "../enums/ModCallbackCustom";
9
9
  import { errorIfFeaturesNotInitialized } from "../featuresInitialized";
10
- import { spawn } from "../functions/entity";
10
+ import { spawn } from "../functions/entities";
11
11
  import { getRoomListIndex } from "../functions/roomData";
12
12
  import { saveDataManager } from "./saveDataManager/exports";
13
13
 
@@ -123,7 +123,7 @@ export function spawnPersistentEntity(
123
123
  ): [Entity, int] {
124
124
  errorIfFeaturesNotInitialized(FEATURE_NAME);
125
125
 
126
- persistentEntityIndexCounter += 1;
126
+ persistentEntityIndexCounter++;
127
127
 
128
128
  const entity = spawnAndTrack(
129
129
  entityType,
@@ -10,7 +10,7 @@ import {
10
10
  import { game } from "../cachedClasses";
11
11
  import { errorIfFeaturesNotInitialized } from "../featuresInitialized";
12
12
  import { setCollectibleSubType } from "../functions/collectibles";
13
- import { getEntityID } from "../functions/entity";
13
+ import { getEntityID } from "../functions/entities";
14
14
  import { isCollectible } from "../functions/pickupVariants";
15
15
  import { saveDataManager } from "./saveDataManager/exports";
16
16
 
@@ -169,8 +169,11 @@ export function saveDataManagerSave(): void {
169
169
  forceSaveDataManagerSave();
170
170
  }
171
171
 
172
- declare let g: LuaTable<string, SaveData>; // Globals
173
- declare let gd: LuaTable<string, SaveData>; // Globals defaults
172
+ /** "g" stands for "globals". */
173
+ declare let g: LuaTable<string, SaveData>; // eslint-disable-line @typescript-eslint/no-unused-vars
174
+
175
+ /** "gd" stands for "globals defaults". */
176
+ declare let gd: LuaTable<string, SaveData>; // eslint-disable-line @typescript-eslint/no-unused-vars
174
177
 
175
178
  /**
176
179
  * - Sets the global variable of "g" equal to all of the save data variables for this mod.
@@ -182,8 +185,8 @@ declare let gd: LuaTable<string, SaveData>; // Globals defaults
182
185
  export function saveDataManagerSetGlobal(): void {
183
186
  errorIfFeaturesNotInitialized(SAVE_DATA_MANAGER_FEATURE_NAME);
184
187
 
185
- g = saveDataMap; // eslint-disable-line @typescript-eslint/no-unused-vars
186
- gd = saveDataDefaultsMap; // eslint-disable-line @typescript-eslint/no-unused-vars
188
+ g = saveDataMap;
189
+ gd = saveDataDefaultsMap;
187
190
  }
188
191
 
189
192
  /**
@@ -4,7 +4,7 @@ import {
4
4
  ModCallback,
5
5
  } from "isaac-typescript-definitions";
6
6
  import { errorIfFeaturesNotInitialized } from "../featuresInitialized";
7
- import { getEntities } from "../functions/entity";
7
+ import { getEntities } from "../functions/entities";
8
8
  import { saveDataManager } from "./saveDataManager/exports";
9
9
 
10
10
  const FEATURE_NAME = "sirenHelpers";
@@ -1,7 +1,7 @@
1
1
  import { SackSubType } from "isaac-typescript-definitions";
2
2
  import { runNextGameFrame } from "../features/runInNFrames";
3
- import { removeEntities } from "./entity";
4
- import { getCoins, spawnSackWithSeed } from "./pickups";
3
+ import { removeEntities } from "./entities";
4
+ import { getCoins, spawnSackWithSeed } from "./pickupsSpecific";
5
5
 
6
6
  /** Hard-coding this makes it easier to clean up the pickups afterwards. */
7
7
  const SACK_SEED_THAT_SPAWNS_TWO_COINS = 6 as Seed;
@@ -527,7 +527,7 @@ export function shuffleArrayInPlace<T>(
527
527
  const rng = isRNG(seedOrRNG) ? seedOrRNG : newRNG(seedOrRNG);
528
528
 
529
529
  while (currentIndex > 0) {
530
- currentIndex -= 1;
530
+ currentIndex--;
531
531
 
532
532
  const randomIndex = getRandomArrayIndex(array, rng);
533
533
  swapArrayElements(array, currentIndex, randomIndex);
@@ -57,7 +57,7 @@ export function countSetBits(n: int): int {
57
57
 
58
58
  while (n > 0) {
59
59
  n &= n - 1;
60
- count += 1;
60
+ count++;
61
61
  }
62
62
 
63
63
  return count;
@@ -72,7 +72,7 @@ export function getKBitOfN(k: int, n: int): int {
72
72
  export function getNumBitsOfN(n: int): int {
73
73
  let numBits = 0;
74
74
  while (n > 0) {
75
- numBits += 1;
75
+ numBits++;
76
76
  n >>>= 1;
77
77
  }
78
78
 
@@ -10,8 +10,8 @@ import {
10
10
  STAGE_TO_STAGE_TYPE_TO_BOSS_SET_MAP,
11
11
  } from "../sets/bossSets";
12
12
  import { SIN_ENTITY_TYPES_SET } from "../sets/sinEntityTypesSet";
13
- import { getNPCs, spawnNPC } from "./entitySpecific";
14
- import { getAliveNPCs } from "./npc";
13
+ import { getNPCs, spawnNPC } from "./entitiesSpecific";
14
+ import { getAliveNPCs } from "./npcs";
15
15
  import { isRNG } from "./rng";
16
16
  import { copySet } from "./set";
17
17
  import { repeat } from "./utils";
@@ -31,19 +31,22 @@ const DEFAULT_BOSS_MULTI_SEGMENTS = 4;
31
31
  *
32
32
  * This function will not include bosses on an internal blacklist, such as Death's scythes or Big
33
33
  * Horn holes.
34
+ *
35
+ * @param entityType Optional. If specified, will only get the bosses that match the type. Default
36
+ * is -1, which matches every type.
37
+ * @param variant Optional. If specified, will only get the bosses that match the variant. Default
38
+ * is -1, which matches every variant.
39
+ * @param subType Optional. If specified, will only get the bosses that match the sub-type. Default
40
+ * is -1, which matches every sub-type.
41
+ * @param ignoreFriendly Optional. Default is false.
34
42
  */
35
43
  export function getAliveBosses(
36
- matchingEntityType?: EntityType,
37
- matchingVariant?: int,
38
- matchingSubType?: int,
44
+ entityType: EntityType = -1,
45
+ variant = -1,
46
+ subType = -1,
39
47
  ignoreFriendly = false,
40
48
  ): EntityNPC[] {
41
- const aliveNPCs = getAliveNPCs(
42
- matchingEntityType,
43
- matchingVariant,
44
- matchingSubType,
45
- ignoreFriendly,
46
- );
49
+ const aliveNPCs = getAliveNPCs(entityType, variant, subType, ignoreFriendly);
47
50
  return aliveNPCs.filter((aliveNPC) => aliveNPC.IsBoss());
48
51
  }
49
52
 
@@ -83,19 +86,24 @@ export function getBossSet(
83
86
  return copySet(bossSet);
84
87
  }
85
88
 
86
- /** Helper function to get all of the bosses in the room. */
89
+ /**
90
+ * Helper function to get all of the bosses in the room.
91
+ *
92
+ * @param entityType Optional. If specified, will only get the bosses that match the type. Default
93
+ * is -1, which matches every type.
94
+ * @param variant Optional. If specified, will only get the bosses that match the variant. Default
95
+ * is -1, which matches every variant.
96
+ * @param subType Optional. If specified, will only get the bosses that match the sub-type. Default
97
+ * is -1, which matches every sub-type.
98
+ * @param ignoreFriendly Optional. Default is false.
99
+ */
87
100
  export function getBosses(
88
- matchingEntityType?: EntityType,
89
- matchingVariant?: int,
90
- matchingSubType?: int,
101
+ entityType?: EntityType,
102
+ variant?: int,
103
+ subType?: int,
91
104
  ignoreFriendly = false,
92
105
  ): EntityNPC[] {
93
- const npcs = getNPCs(
94
- matchingEntityType,
95
- matchingVariant,
96
- matchingSubType,
97
- ignoreFriendly,
98
- );
106
+ const npcs = getNPCs(entityType, variant, subType, ignoreFriendly);
99
107
  return npcs.filter((npc) => npc.IsBoss());
100
108
  }
101
109
 
@@ -3,7 +3,7 @@ import { itemConfig } from "../cachedClasses";
3
3
  import { getCollectibleArray } from "./collectibleSet";
4
4
  import { getEnumValues } from "./enums";
5
5
  import { getFlagName } from "./flag";
6
- import { getPlayerCollectibleCount } from "./player";
6
+ import { getPlayerCollectibleCount } from "./players";
7
7
  import { copySet } from "./set";
8
8
 
9
9
  const TAG_TO_COLLECTIBLE_TYPES_MAP = new Map<
@@ -27,10 +27,10 @@ import {
27
27
  } from "../maps/collectibleNameMap";
28
28
  import { SINGLE_USE_ACTIVE_COLLECTIBLE_TYPES_SET } from "../sets/singleUseActiveCollectibleTypesSet";
29
29
  import { CollectibleIndex } from "../types/CollectibleIndex";
30
- import { getEntityID } from "./entity";
30
+ import { getEntityID } from "./entities";
31
31
  import { isCollectible } from "./pickupVariants";
32
32
  import { getRoomListIndex } from "./roomData";
33
- import { clearSprite, spriteEquals } from "./sprite";
33
+ import { clearSprite, spriteEquals } from "./sprites";
34
34
  import { irange } from "./utils";
35
35
 
36
36
  const COLLECTIBLE_SPRITE_LAYER = 1;
@@ -51,15 +51,19 @@ const COPYABLE_ISAAC_API_CLASS_TYPES_SET = new Set<string>(
51
51
  * - other Isaac API objects such as `EntityPtr` (that have a type of "userdata")
52
52
  *
53
53
  * @param value The primitive or object to copy.
54
- * @param serializationType Has 3 possible values. Can leave objects as-is, or can serialize objects
55
- * to Lua tables, or can deserialize Lua tables to objects. Default is
56
- * `SerializationType.NONE`.
57
- * @param traversalDescription Used to track the current key that we are operating on.
54
+ * @param serializationType Optional. Has 3 possible values. Can copy objects as-is, or can
55
+ * serialize objects to Lua tables, or can deserialize Lua tables to
56
+ * objects. Default is `SerializationType.NONE`.
57
+ * @param traversalDescription Optional. Used to track the current key that we are operating on.
58
+ * Default is an empty string.
59
+ * @param insideMap Optional. Tracks whether or not the deep copy function is in the process of
60
+ * recursively copying a TSTL Map. Default is false.
58
61
  */
59
62
  export function deepCopy(
60
63
  value: unknown,
61
64
  serializationType = SerializationType.NONE,
62
65
  traversalDescription = "",
66
+ insideMap = false,
63
67
  ): unknown {
64
68
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
65
69
  if (SAVE_DATA_MANAGER_DEBUG) {
@@ -98,7 +102,12 @@ export function deepCopy(
98
102
 
99
103
  case "table": {
100
104
  const luaTable = value as LuaTable<AnyNotNil, unknown>;
101
- return deepCopyTable(luaTable, serializationType, traversalDescription);
105
+ return deepCopyTable(
106
+ luaTable,
107
+ serializationType,
108
+ traversalDescription,
109
+ insideMap,
110
+ );
102
111
  }
103
112
 
104
113
  case "userdata": {
@@ -111,6 +120,7 @@ function deepCopyTable(
111
120
  luaTable: LuaTable<AnyNotNil, unknown>,
112
121
  serializationType: SerializationType,
113
122
  traversalDescription: string,
123
+ insideMap: boolean,
114
124
  ) {
115
125
  // First, handle the cases of TSTL classes or serialized TSTL classes.
116
126
  if (isDefaultMap(luaTable) || luaTable.has(SerializationBrand.DEFAULT_MAP)) {
@@ -118,15 +128,26 @@ function deepCopyTable(
118
128
  luaTable,
119
129
  serializationType,
120
130
  traversalDescription,
131
+ insideMap,
121
132
  );
122
133
  }
123
134
 
124
135
  if (isTSTLMap(luaTable) || luaTable.has(SerializationBrand.MAP)) {
125
- return deepCopyMap(luaTable, serializationType, traversalDescription);
136
+ return deepCopyMap(
137
+ luaTable,
138
+ serializationType,
139
+ traversalDescription,
140
+ insideMap,
141
+ );
126
142
  }
127
143
 
128
144
  if (isTSTLSet(luaTable) || luaTable.has(SerializationBrand.SET)) {
129
- return deepCopySet(luaTable, serializationType, traversalDescription);
145
+ return deepCopySet(
146
+ luaTable,
147
+ serializationType,
148
+ traversalDescription,
149
+ insideMap,
150
+ );
130
151
  }
131
152
 
132
153
  const className = getTSTLClassName(luaTable);
@@ -144,7 +165,12 @@ function deepCopyTable(
144
165
  }
145
166
 
146
167
  if (isUserDefinedTSTLClass(luaTable)) {
147
- return deepCopyTSTLClass(luaTable, serializationType, traversalDescription);
168
+ return deepCopyTSTLClass(
169
+ luaTable,
170
+ serializationType,
171
+ traversalDescription,
172
+ insideMap,
173
+ );
148
174
  }
149
175
 
150
176
  // This is not a TSTL Map/Set/class. If it has a metatable, abort.
@@ -160,7 +186,12 @@ function deepCopyTable(
160
186
 
161
187
  // Handle the special case of an array.
162
188
  if (isArray(luaTable)) {
163
- return deepCopyArray(luaTable, serializationType, traversalDescription);
189
+ return deepCopyArray(
190
+ luaTable,
191
+ serializationType,
192
+ traversalDescription,
193
+ insideMap,
194
+ );
164
195
  }
165
196
 
166
197
  // Base case: copy a normal Lua table
@@ -168,6 +199,7 @@ function deepCopyTable(
168
199
  luaTable,
169
200
  serializationType,
170
201
  traversalDescription,
202
+ insideMap,
171
203
  );
172
204
  }
173
205
 
@@ -175,19 +207,39 @@ function deepCopyDefaultMap(
175
207
  defaultMap: DefaultMap<AnyNotNil, unknown> | LuaTable<AnyNotNil, unknown>,
176
208
  serializationType: SerializationType,
177
209
  traversalDescription: string,
210
+ insideMap: boolean,
178
211
  ) {
179
- // First, handle the special case of serializing a DefaultMap instantiated with a factory
180
- // function. If this is the case, then we cannot serialize it, so we serialize it as a normal
181
- // `Map` instead. We do not throw a runtime error because the merge function does not need to
182
- // instantiate the DefaultMap class in most circumstances.
183
212
  const constructorArg = isDefaultMap(defaultMap)
184
213
  ? defaultMap.getConstructorArg()
185
- : undefined;
214
+ : undefined; // The undefined case is handled explicitly in the "getNewDefaultMap" function.
215
+
216
+ // First, handle the special case of serializing a DefaultMap instantiated with a factory
217
+ // function. If this is the case, then we cannot serialize it (because there is no way to
218
+ // serialize a function).
186
219
  if (
187
220
  serializationType === SerializationType.SERIALIZE &&
188
221
  !isPrimitive(constructorArg)
189
222
  ) {
190
- return deepCopyMap(defaultMap, serializationType, traversalDescription);
223
+ if (insideMap) {
224
+ // The case of a DefaultMap within another map is complicated. Unlike a DefaultMap attached to
225
+ // a "normal" object, the `merge` function will have no reference to the factory function that
226
+ // was used to instantiate it. Thus, there is no way to copy this object. In this case, we
227
+ // throw a run-time error to immediately alert the end-user that their data structure is
228
+ // invalid.
229
+ error(
230
+ 'Failed to deep copy a DefaultMap because it was instantiated with a factory function and was also inside of another map. You cannot use a nested DefaultMap in this way because factory functions are not serializable. (In other words, there is no way to copy the function that you are using for the DefaultMap into the "save#.dat" file.) Instead, refactor your data structure so that the DefaultMap is not nested.',
231
+ );
232
+ } else {
233
+ // In most cases, the DefaultMap will be attached to a normal table element. In this case, if
234
+ // we serialize it as a normal `Map`, then everything will work out fine, because the `merge`
235
+ // function only needs to copy the values (and not instantiate the object itself).
236
+ return deepCopyMap(
237
+ defaultMap,
238
+ serializationType,
239
+ traversalDescription,
240
+ insideMap,
241
+ );
242
+ }
191
243
  }
192
244
 
193
245
  const newDefaultMap = getNewDefaultMap(
@@ -196,11 +248,13 @@ function deepCopyDefaultMap(
196
248
  traversalDescription,
197
249
  constructorArg,
198
250
  );
251
+ insideMap = true;
199
252
 
200
253
  const { entries, convertedNumberKeysToStrings } = getCopiedEntries(
201
254
  defaultMap,
202
255
  serializationType,
203
256
  traversalDescription,
257
+ insideMap,
204
258
  );
205
259
 
206
260
  if (convertedNumberKeysToStrings) {
@@ -223,12 +277,14 @@ function deepCopyDefaultMap(
223
277
  }
224
278
  }
225
279
 
280
+ insideMap = false;
281
+
226
282
  return newDefaultMap;
227
283
  }
228
284
 
229
285
  /**
230
- * The new default map with either be a TSTL `DefaultMap` class or a Lua table, depending on whether
231
- * we are serializing or not.
286
+ * The new copied default map with either be a TSTL `DefaultMap` class or a Lua table, depending on
287
+ * whether we are serializing or not.
232
288
  */
233
289
  function getNewDefaultMap(
234
290
  defaultMap: DefaultMap<AnyNotNil, unknown> | LuaTable<AnyNotNil, unknown>,
@@ -278,6 +334,7 @@ function deepCopyMap(
278
334
  map: Map<AnyNotNil, unknown> | LuaTable<AnyNotNil, unknown>,
279
335
  serializationType: SerializationType,
280
336
  traversalDescription: string,
337
+ insideMap: boolean,
281
338
  ) {
282
339
  let newMap: Map<AnyNotNil, unknown> | LuaTable<AnyNotNil, unknown>;
283
340
  if (serializationType === SerializationType.SERIALIZE) {
@@ -287,11 +344,13 @@ function deepCopyMap(
287
344
  } else {
288
345
  newMap = new Map();
289
346
  }
347
+ insideMap = true;
290
348
 
291
349
  const { entries, convertedNumberKeysToStrings } = getCopiedEntries(
292
350
  map,
293
351
  serializationType,
294
352
  traversalDescription,
353
+ insideMap,
295
354
  );
296
355
 
297
356
  if (convertedNumberKeysToStrings) {
@@ -314,6 +373,8 @@ function deepCopyMap(
314
373
  }
315
374
  }
316
375
 
376
+ insideMap = false;
377
+
317
378
  return newMap;
318
379
  }
319
380
 
@@ -321,6 +382,7 @@ function deepCopySet(
321
382
  set: Set<AnyNotNil> | LuaTable<AnyNotNil, unknown>,
322
383
  serializationType: SerializationType,
323
384
  traversalDescription: string,
385
+ insideMap: boolean,
324
386
  ) {
325
387
  let newSet: Set<AnyNotNil> | LuaTable<AnyNotNil, string>;
326
388
  if (serializationType === SerializationType.SERIALIZE) {
@@ -336,6 +398,7 @@ function deepCopySet(
336
398
  set,
337
399
  serializationType,
338
400
  traversalDescription,
401
+ insideMap,
339
402
  );
340
403
 
341
404
  if (convertedNumberKeysToStrings) {
@@ -368,6 +431,7 @@ function deepCopyTSTLClass(
368
431
  tstlClass: TSTLClass,
369
432
  serializationType: SerializationType,
370
433
  traversalDescription: string,
434
+ insideMap: boolean,
371
435
  ) {
372
436
  let newClass: TSTLClass | LuaTable<AnyNotNil, unknown>;
373
437
  if (serializationType === SerializationType.SERIALIZE) {
@@ -383,6 +447,7 @@ function deepCopyTSTLClass(
383
447
  tstlClass,
384
448
  serializationType,
385
449
  traversalDescription,
450
+ insideMap,
386
451
  );
387
452
 
388
453
  if (convertedNumberKeysToStrings) {
@@ -400,11 +465,17 @@ function deepCopyArray(
400
465
  array: unknown[],
401
466
  serializationType: SerializationType,
402
467
  traversalDescription: string,
468
+ insideMap: boolean,
403
469
  ) {
404
470
  const newArray: unknown[] = [];
405
471
 
406
472
  for (const value of array) {
407
- const newValue = deepCopy(value, serializationType, traversalDescription);
473
+ const newValue = deepCopy(
474
+ value,
475
+ serializationType,
476
+ traversalDescription,
477
+ insideMap,
478
+ );
408
479
  newArray.push(newValue);
409
480
  }
410
481
 
@@ -415,12 +486,14 @@ function deepCopyNormalLuaTable(
415
486
  luaTable: LuaTable<AnyNotNil, unknown>,
416
487
  serializationType: SerializationType,
417
488
  traversalDescription: string,
489
+ insideMap: boolean,
418
490
  ) {
419
491
  const newTable = new LuaTable<AnyNotNil, unknown>();
420
492
  const { entries, convertedNumberKeysToStrings } = getCopiedEntries(
421
493
  luaTable,
422
494
  serializationType,
423
495
  traversalDescription,
496
+ insideMap,
424
497
  );
425
498
 
426
499
  if (convertedNumberKeysToStrings) {
@@ -442,6 +515,7 @@ function getCopiedEntries(
442
515
  object: unknown,
443
516
  serializationType: SerializationType,
444
517
  traversalDescription: string,
518
+ insideMap: boolean,
445
519
  ): {
446
520
  entries: Array<[key: AnyNotNil, value: unknown]>;
447
521
  convertedNumberKeysToStrings: boolean;
@@ -479,7 +553,12 @@ function getCopiedEntries(
479
553
  }
480
554
 
481
555
  traversalDescription = getTraversalDescription(key, traversalDescription);
482
- const newValue = deepCopy(value, serializationType, traversalDescription);
556
+ const newValue = deepCopy(
557
+ value,
558
+ serializationType,
559
+ traversalDescription,
560
+ insideMap,
561
+ );
483
562
 
484
563
  const keyToUse = convertNumberKeysToStrings ? tostring(key) : key;
485
564
  copiedEntries.push([keyToUse, newValue]);
@@ -131,6 +131,7 @@ function copiedTableDoesNotCoerceTypes() {
131
131
  }
132
132
  }
133
133
 
134
+ /** In this context, a reference is a pointer. */
134
135
  function copiedObjectHasNoReferencesForPrimitivesForward() {
135
136
  const originalStringValue = "abcdef";
136
137
  const originalNumberValue = 123;
@@ -181,6 +182,7 @@ function copiedObjectHasNoReferencesForPrimitivesBackward() {
181
182
  }
182
183
  }
183
184
 
185
+ /** In this context, a reference is a pointer. */
184
186
  function copiedObjectHasNoReferencesForArray() {
185
187
  const oldObject = {
186
188
  abc: [1, 2, 3],
@@ -200,21 +202,21 @@ function copiedObjectHasNoReferencesForArray() {
200
202
  error("The copied object does not have an equal array.");
201
203
  }
202
204
 
203
- oldObject.abc[0] += 1;
205
+ oldObject.abc[0]++;
204
206
  if (arrayEquals(oldObject.abc, newObject.abc)) {
205
207
  error(
206
208
  "The copied object has an equal array after a modification to the old array.",
207
209
  );
208
210
  }
209
- oldObject.abc[0] -= 1;
211
+ oldObject.abc[0]--;
210
212
 
211
- newObject.abc[0] += 1;
213
+ newObject.abc[0]++;
212
214
  if (arrayEquals(oldObject.abc, newObject.abc)) {
213
215
  error(
214
216
  "The copied object has an equal array after a modification to the new array.",
215
217
  );
216
218
  }
217
- newObject.abc[0] -= 1;
219
+ newObject.abc[0]--;
218
220
  }
219
221
 
220
222
  function copiedObjectHasChildObject() {