isaacscript-common 2.3.2 → 3.1.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 (337) hide show
  1. package/cachedClasses.d.ts +6 -4
  2. package/cachedClasses.lua +24 -0
  3. package/callbacks/customRevive.lua +2 -0
  4. package/callbacks/itemPickup.lua +2 -0
  5. package/callbacks/postBombInitLate.lua +2 -0
  6. package/callbacks/postBoneSwing.lua +2 -0
  7. package/callbacks/postCollectibleInitFirst.lua +2 -0
  8. package/callbacks/postCursedTeleport.lua +2 -0
  9. package/callbacks/postCustomDoorEnter.lua +44 -0
  10. package/callbacks/postDoorRender.lua +2 -0
  11. package/callbacks/postDoorUpdate.lua +2 -0
  12. package/callbacks/postEffectInitLate.lua +2 -0
  13. package/callbacks/postEffectStateChanged.lua +2 -0
  14. package/callbacks/postEsauJr.lua +2 -0
  15. package/callbacks/postFamiliarInitLate.lua +2 -0
  16. package/callbacks/postFamiliarStateChanged.lua +2 -0
  17. package/callbacks/postFlip.lua +2 -0
  18. package/callbacks/postGreedModeWave.lua +2 -0
  19. package/callbacks/postGridEntity.lua +2 -0
  20. package/callbacks/postGridEntityCollision.lua +2 -0
  21. package/callbacks/postGridEntityRender.lua +2 -0
  22. package/callbacks/postHolyMantleRemoved.lua +2 -0
  23. package/callbacks/postKnifeInitLate.lua +2 -0
  24. package/callbacks/postLaserInitLate.lua +2 -0
  25. package/callbacks/postNPCInitLate.lua +2 -0
  26. package/callbacks/postNPCStateChanged.lua +2 -0
  27. package/callbacks/postNewRoomEarly.lua +2 -0
  28. package/callbacks/postPickupCollect.lua +2 -0
  29. package/callbacks/postPickupInitFirst.d.ts +1 -0
  30. package/callbacks/postPickupInitFirst.lua +55 -0
  31. package/callbacks/postPickupInitLate.lua +2 -0
  32. package/callbacks/postPickupStateChanged.lua +2 -0
  33. package/callbacks/postPitRender.lua +2 -0
  34. package/callbacks/postPitUpdate.lua +2 -0
  35. package/callbacks/postPlayerChangeHealth.lua +2 -0
  36. package/callbacks/postPlayerChangeType.lua +2 -0
  37. package/callbacks/postPlayerFatalDamage.lua +2 -0
  38. package/callbacks/postPlayerInitLate.lua +2 -0
  39. package/callbacks/postPlayerReordered.lua +2 -0
  40. package/callbacks/postPoopRender.lua +2 -0
  41. package/callbacks/postPoopUpdate.lua +2 -0
  42. package/callbacks/postPressurePlateRender.lua +2 -0
  43. package/callbacks/postPressurePlateUpdate.lua +2 -0
  44. package/callbacks/postProjectileInitLate.lua +2 -0
  45. package/callbacks/postPurchase.lua +2 -0
  46. package/callbacks/postRockRender.lua +2 -0
  47. package/callbacks/postRockUpdate.lua +2 -0
  48. package/callbacks/postRoomClearChanged.lua +2 -0
  49. package/callbacks/postSacrifice.lua +2 -0
  50. package/callbacks/postSlotDestroyed.d.ts +1 -0
  51. package/callbacks/postSlotDestroyed.lua +66 -0
  52. package/callbacks/postSlotInitUpdate.lua +2 -0
  53. package/callbacks/postSlotRender.lua +5 -21
  54. package/callbacks/postSpikesRender.lua +2 -0
  55. package/callbacks/postSpikesUpdate.lua +2 -0
  56. package/callbacks/postTNTRender.lua +2 -0
  57. package/callbacks/postTNTUpdate.lua +2 -0
  58. package/callbacks/postTearInitLate.lua +2 -0
  59. package/callbacks/postTearInitVeryLate.lua +2 -0
  60. package/callbacks/postTransformation.lua +2 -0
  61. package/callbacks/postTrinketBreak.lua +2 -0
  62. package/callbacks/preBerserkDeath.lua +2 -0
  63. package/callbacks/preNewLevel.lua +2 -0
  64. package/callbacks/reorderedCallbacks.lua +16 -0
  65. package/callbacks/subscriptions/postBombInitLate.lua +6 -0
  66. package/callbacks/subscriptions/postBoneSwing.lua +6 -0
  67. package/callbacks/subscriptions/postCollectibleInitFirst.lua +6 -0
  68. package/callbacks/subscriptions/postCursedTeleport.lua +6 -0
  69. package/callbacks/subscriptions/postCustomDoorEnter.lua +6 -0
  70. package/callbacks/subscriptions/postCustomRevive.d.ts +1 -0
  71. package/callbacks/subscriptions/postCustomRevive.lua +6 -0
  72. package/callbacks/subscriptions/postDoorRender.d.ts +1 -0
  73. package/callbacks/subscriptions/postDoorRender.lua +6 -0
  74. package/callbacks/subscriptions/postDoorUpdate.d.ts +1 -0
  75. package/callbacks/subscriptions/postDoorUpdate.lua +6 -0
  76. package/callbacks/subscriptions/postEffectInitLate.lua +6 -0
  77. package/callbacks/subscriptions/postEffectStateChanged.lua +6 -0
  78. package/callbacks/subscriptions/postEsauJr.lua +6 -0
  79. package/callbacks/subscriptions/postFamiliarInitLate.lua +6 -0
  80. package/callbacks/subscriptions/postFamiliarStateChanged.lua +6 -0
  81. package/callbacks/subscriptions/postFirstEsauJr.lua +6 -0
  82. package/callbacks/subscriptions/postFirstFlip.lua +6 -0
  83. package/callbacks/subscriptions/postFlip.lua +6 -0
  84. package/callbacks/subscriptions/postGameStartedReordered.lua +6 -0
  85. package/callbacks/subscriptions/postGreedModeWave.lua +6 -0
  86. package/callbacks/subscriptions/postGridEntityBroken.lua +6 -0
  87. package/callbacks/subscriptions/postGridEntityCollision.lua +6 -0
  88. package/callbacks/subscriptions/postGridEntityInit.lua +6 -0
  89. package/callbacks/subscriptions/postGridEntityRemove.lua +6 -0
  90. package/callbacks/subscriptions/postGridEntityRender.lua +6 -0
  91. package/callbacks/subscriptions/postGridEntityStateChanged.lua +6 -0
  92. package/callbacks/subscriptions/postGridEntityUpdate.lua +6 -0
  93. package/callbacks/subscriptions/postHolyMantleRemoved.lua +6 -0
  94. package/callbacks/subscriptions/postItemDischarged.lua +6 -0
  95. package/callbacks/subscriptions/postItemPickup.lua +6 -0
  96. package/callbacks/subscriptions/postKnifeInitLate.lua +6 -0
  97. package/callbacks/subscriptions/postLaserInitLate.lua +6 -0
  98. package/callbacks/subscriptions/postNPCInitLate.lua +6 -0
  99. package/callbacks/subscriptions/postNPCStateChanged.lua +6 -0
  100. package/callbacks/subscriptions/postNewLevelReordered.lua +6 -0
  101. package/callbacks/subscriptions/postNewRoomEarly.lua +6 -0
  102. package/callbacks/subscriptions/postNewRoomReordered.lua +6 -0
  103. package/callbacks/subscriptions/postPEffectUpdateReordered.lua +6 -0
  104. package/callbacks/subscriptions/postPickupCollect.d.ts +1 -0
  105. package/callbacks/subscriptions/postPickupCollect.lua +6 -0
  106. package/callbacks/subscriptions/postPickupInitFirst.d.ts +3 -0
  107. package/callbacks/subscriptions/postPickupInitFirst.lua +29 -0
  108. package/callbacks/subscriptions/postPickupInitLate.lua +6 -0
  109. package/callbacks/subscriptions/postPickupStateChanged.d.ts +1 -0
  110. package/callbacks/subscriptions/postPickupStateChanged.lua +6 -0
  111. package/callbacks/subscriptions/postPitRender.d.ts +1 -0
  112. package/callbacks/subscriptions/postPitRender.lua +6 -0
  113. package/callbacks/subscriptions/postPitUpdate.d.ts +1 -0
  114. package/callbacks/subscriptions/postPitUpdate.lua +6 -0
  115. package/callbacks/subscriptions/postPlayerChangeHealth.lua +6 -0
  116. package/callbacks/subscriptions/postPlayerChangeType.lua +6 -0
  117. package/callbacks/subscriptions/postPlayerFatalDamage.lua +6 -0
  118. package/callbacks/subscriptions/postPlayerInitLate.lua +6 -0
  119. package/callbacks/subscriptions/postPlayerInitReordered.lua +6 -0
  120. package/callbacks/subscriptions/postPlayerRenderReordered.lua +6 -0
  121. package/callbacks/subscriptions/postPlayerUpdateReordered.lua +6 -0
  122. package/callbacks/subscriptions/postPoopRender.d.ts +1 -0
  123. package/callbacks/subscriptions/postPoopRender.lua +6 -0
  124. package/callbacks/subscriptions/postPoopUpdate.d.ts +1 -0
  125. package/callbacks/subscriptions/postPoopUpdate.lua +6 -0
  126. package/callbacks/subscriptions/postPressurePlateRender.d.ts +1 -0
  127. package/callbacks/subscriptions/postPressurePlateRender.lua +6 -0
  128. package/callbacks/subscriptions/postPressurePlateUpdate.d.ts +1 -0
  129. package/callbacks/subscriptions/postPressurePlateUpdate.lua +6 -0
  130. package/callbacks/subscriptions/postProjectileInitLate.lua +6 -0
  131. package/callbacks/subscriptions/postPurchase.lua +6 -0
  132. package/callbacks/subscriptions/postRockRender.d.ts +1 -0
  133. package/callbacks/subscriptions/postRockRender.lua +6 -0
  134. package/callbacks/subscriptions/postRockUpdate.d.ts +1 -0
  135. package/callbacks/subscriptions/postRockUpdate.lua +6 -0
  136. package/callbacks/subscriptions/postRoomClearChanged.lua +6 -0
  137. package/callbacks/subscriptions/postSacrifice.lua +6 -0
  138. package/callbacks/subscriptions/postSlotAnimationChanged.lua +6 -0
  139. package/callbacks/subscriptions/postSlotDestroyed.lua +6 -0
  140. package/callbacks/subscriptions/postSlotInit.lua +6 -0
  141. package/callbacks/subscriptions/postSlotRender.lua +6 -0
  142. package/callbacks/subscriptions/postSlotUpdate.lua +6 -0
  143. package/callbacks/subscriptions/postSpikesRender.d.ts +1 -0
  144. package/callbacks/subscriptions/postSpikesRender.lua +6 -0
  145. package/callbacks/subscriptions/postSpikesUpdate.d.ts +1 -0
  146. package/callbacks/subscriptions/postSpikesUpdate.lua +6 -0
  147. package/callbacks/subscriptions/postTNTRender.d.ts +1 -0
  148. package/callbacks/subscriptions/postTNTRender.lua +6 -0
  149. package/callbacks/subscriptions/postTNTUpdate.d.ts +1 -0
  150. package/callbacks/subscriptions/postTNTUpdate.lua +6 -0
  151. package/callbacks/subscriptions/postTearInitLate.lua +6 -0
  152. package/callbacks/subscriptions/postTearInitVeryLate.lua +6 -0
  153. package/callbacks/subscriptions/postTransformation.lua +6 -0
  154. package/callbacks/subscriptions/postTrinketBreak.lua +6 -0
  155. package/callbacks/subscriptions/preBerserkDeath.lua +6 -0
  156. package/callbacks/subscriptions/preCustomRevive.lua +6 -0
  157. package/callbacks/subscriptions/preItemPickup.lua +6 -0
  158. package/callbacks/subscriptions/preNewLevel.lua +6 -0
  159. package/classes/DefaultMap.d.ts +70 -39
  160. package/classes/DefaultMap.lua +94 -43
  161. package/classes/ModUpgraded.d.ts +3 -3
  162. package/classes/ModUpgraded.lua +5 -0
  163. package/constants.lua +41 -0
  164. package/constantsFirstLast.lua +63 -0
  165. package/enums/HealthType.lua +3 -0
  166. package/enums/ModCallbackCustom.d.ts +62 -40
  167. package/enums/ModCallbackCustom.lua +46 -38
  168. package/enums/private/CopyableIsaacAPIClassType.lua +1 -0
  169. package/enums/private/SerializationBrand.lua +5 -0
  170. package/features/characterHealthConversion.lua +6 -0
  171. package/features/characterStats.lua +17 -0
  172. package/features/debugDisplay/exports.d.ts +17 -0
  173. package/features/debugDisplay/exports.lua +90 -0
  174. package/features/debugDisplay/v.d.ts +17 -0
  175. package/features/deployJSONRoom.d.ts +1 -0
  176. package/features/deployJSONRoom.lua +56 -0
  177. package/features/disableInputs.lua +45 -0
  178. package/features/disableSound.lua +14 -0
  179. package/features/extraConsoleCommands/commandsDisplay.lua +90 -0
  180. package/features/extraConsoleCommands/init.lua +16 -0
  181. package/features/extraConsoleCommands/listCommands.lua +172 -0
  182. package/features/fadeInRemover.lua +10 -0
  183. package/features/fastReset.lua +10 -0
  184. package/features/forgottenSwitch.lua +4 -0
  185. package/features/getCollectibleItemPoolType.lua +5 -0
  186. package/features/playerInventory.lua +18 -0
  187. package/features/ponyDetection.lua +4 -0
  188. package/features/preventCollectibleRotation.lua +9 -0
  189. package/features/runInNFrames.lua +50 -0
  190. package/features/saveDataManager/constants.lua +1 -0
  191. package/features/saveDataManager/exports.lua +115 -0
  192. package/features/saveDataManager/load.lua +12 -8
  193. package/features/saveDataManager/main.lua +16 -3
  194. package/features/saveDataManager/maps.lua +3 -0
  195. package/features/saveDataManager/merge.lua +53 -21
  196. package/features/saveDataManager/save.lua +12 -7
  197. package/features/sirenHelpers.lua +13 -0
  198. package/features/taintedLazarusPlayers.lua +11 -0
  199. package/featuresInitialized.lua +6 -0
  200. package/functions/array.d.ts +2 -0
  201. package/functions/array.lua +85 -0
  202. package/functions/benchmark.lua +6 -0
  203. package/functions/bombs.d.ts +3 -0
  204. package/functions/bombs.lua +12 -0
  205. package/functions/boss.lua +35 -0
  206. package/functions/cacheFlag.lua +4 -0
  207. package/functions/cards.lua +60 -0
  208. package/functions/challenges.lua +1 -0
  209. package/functions/character.lua +23 -0
  210. package/functions/charge.lua +39 -0
  211. package/functions/chargeBar.d.ts +1 -0
  212. package/functions/chargeBar.lua +4 -0
  213. package/functions/collectibleCacheFlag.lua +15 -0
  214. package/functions/collectibleSet.lua +3 -0
  215. package/functions/collectibleTag.lua +9 -0
  216. package/functions/collectibles.d.ts +13 -8
  217. package/functions/collectibles.lua +147 -3
  218. package/functions/color.lua +18 -0
  219. package/functions/debug.lua +18 -0
  220. package/functions/deepCopy.lua +60 -26
  221. package/functions/deepCopyTests.lua +8 -5
  222. package/functions/direction.d.ts +8 -0
  223. package/functions/direction.lua +27 -0
  224. package/functions/doors.d.ts +1 -0
  225. package/functions/doors.lua +58 -0
  226. package/functions/entity.d.ts +4 -4
  227. package/functions/entity.lua +94 -6
  228. package/functions/entitySpecific.d.ts +20 -20
  229. package/functions/entitySpecific.lua +182 -0
  230. package/functions/entityTypes.d.ts +1 -1
  231. package/functions/entityTypes.lua +1 -0
  232. package/functions/enums.d.ts +2 -0
  233. package/functions/enums.lua +62 -0
  234. package/functions/familiars.lua +52 -0
  235. package/functions/flag.lua +77 -0
  236. package/functions/flying.lua +10 -0
  237. package/functions/globals.lua +8 -10
  238. package/functions/gridEntity.lua +105 -0
  239. package/functions/gridEntitySpecific.d.ts +5 -0
  240. package/functions/gridEntitySpecific.lua +8 -0
  241. package/functions/input.lua +11 -0
  242. package/functions/isaacAPIClass.d.ts +4 -4
  243. package/functions/isaacAPIClass.lua +15 -3
  244. package/functions/jsonHelpers.lua +11 -0
  245. package/functions/jsonRoom.d.ts +2 -0
  246. package/functions/jsonRoom.lua +5 -0
  247. package/functions/kColor.lua +9 -0
  248. package/functions/language.lua +5 -0
  249. package/functions/log.lua +31 -3
  250. package/functions/map.lua +18 -0
  251. package/functions/math.lua +26 -0
  252. package/functions/npc.lua +24 -0
  253. package/functions/pickupVariants.d.ts +11 -11
  254. package/functions/pickupVariants.lua +11 -0
  255. package/functions/pickups.d.ts +9 -9
  256. package/functions/pickups.lua +67 -0
  257. package/functions/pills.lua +45 -0
  258. package/functions/player.d.ts +7 -0
  259. package/functions/player.lua +210 -9
  260. package/functions/playerDataStructures.lua +65 -0
  261. package/functions/playerHealth.d.ts +3 -0
  262. package/functions/playerHealth.lua +92 -63
  263. package/functions/playerIndex.d.ts +2 -0
  264. package/functions/playerIndex.lua +47 -0
  265. package/functions/pocketItems.lua +18 -0
  266. package/functions/positionVelocity.d.ts +3 -0
  267. package/functions/positionVelocity.lua +46 -0
  268. package/functions/random.d.ts +2 -0
  269. package/functions/random.lua +32 -0
  270. package/functions/revive.d.ts +2 -0
  271. package/functions/revive.lua +15 -0
  272. package/functions/rng.d.ts +1 -0
  273. package/functions/rng.lua +19 -0
  274. package/functions/roomData.lua +68 -0
  275. package/functions/roomGrid.lua +21 -0
  276. package/functions/roomShape.lua +22 -0
  277. package/functions/rooms.lua +100 -0
  278. package/functions/run.lua +5 -0
  279. package/functions/seeds.lua +4 -0
  280. package/functions/serialization.lua +6 -2
  281. package/functions/set.d.ts +1 -0
  282. package/functions/set.lua +22 -0
  283. package/functions/spawnCollectible.lua +24 -0
  284. package/functions/sprite.d.ts +2 -0
  285. package/functions/sprite.lua +25 -0
  286. package/functions/stage.lua +16 -0
  287. package/functions/string.lua +6 -0
  288. package/functions/table.d.ts +12 -0
  289. package/functions/table.lua +53 -0
  290. package/functions/tears.d.ts +1 -0
  291. package/functions/tears.lua +12 -0
  292. package/functions/transformations.lua +18 -0
  293. package/functions/trinketCacheFlag.lua +3 -0
  294. package/functions/trinketGive.lua +24 -0
  295. package/functions/trinkets.lua +52 -0
  296. package/functions/tstlClass.d.ts +34 -0
  297. package/functions/tstlClass.lua +63 -9
  298. package/functions/ui.d.ts +2 -0
  299. package/functions/ui.lua +16 -0
  300. package/functions/utils.d.ts +16 -0
  301. package/functions/utils.lua +108 -0
  302. package/functions/vector.lua +13 -16
  303. package/index.d.ts +1 -0
  304. package/index.lua +8 -0
  305. package/initCustomCallbacks.lua +6 -0
  306. package/interfaces/AddCallbackParameterCustom.d.ts +2 -0
  307. package/interfaces/ChargeBarSprites.d.ts +1 -0
  308. package/interfaces/private/TSTLClassMetatable.d.ts +2 -0
  309. package/lualib_bundle.lua +21 -34
  310. package/maps/cardMap.lua +1 -0
  311. package/maps/characterMap.lua +1 -0
  312. package/maps/defaultPlayerStatMap.lua +1 -0
  313. package/maps/gridEntityXMLMap.lua +2 -0
  314. package/maps/pillEffectMap.lua +1 -0
  315. package/maps/roomShapeToTopLeftWallGridIndexMap.lua +2 -0
  316. package/maps/roomTypeMap.lua +1 -0
  317. package/objects/LRoomShapeToRectangles.lua +2 -0
  318. package/objects/callbackRegisterFunctions.lua +3 -0
  319. package/objects/colors.lua +4 -0
  320. package/objects/oppositeDoorSlots.d.ts +4 -0
  321. package/objects/oppositeDoorSlots.lua +15 -0
  322. package/objects/roomShapeBounds.lua +2 -0
  323. package/objects/roomShapeLayoutSizes.lua +4 -0
  324. package/objects/roomShapeToBottomRightPosition.lua +2 -0
  325. package/objects/roomShapeToDoorSlotsToGridIndexDelta.lua +2 -0
  326. package/objects/roomShapeToTopLeftPosition.lua +2 -0
  327. package/objects/roomShapeVolumes.lua +3 -0
  328. package/package.json +2 -2
  329. package/patchErrorFunctions.lua +8 -0
  330. package/sets/bossSets.lua +23 -0
  331. package/sets/charactersWithNoRedHeartsSet.lua +2 -0
  332. package/sets/charactersWithNoSoulHeartsSet.lua +2 -0
  333. package/sets/lostStyleCharactersSet.lua +2 -0
  334. package/types/AnyEntity.d.ts +10 -0
  335. package/types/PickingUpItem.lua +7 -0
  336. package/upgradeMod.d.ts +4 -4
  337. package/upgradeMod.lua +18 -0
@@ -14,20 +14,33 @@ local ____random = require("functions.random")
14
14
  local getRandom = ____random.getRandom
15
15
  local ____rng = require("functions.rng")
16
16
  local newRNG = ____rng.newRNG
17
+ --- Helper function to remove all of the entities in the supplied array.
18
+ --
19
+ -- @param entities The array of entities to remove.
20
+ -- @param cap Optional. If specified, will only remove the given amount of entities.
21
+ -- @returns An array of the entities that were removed.
17
22
  function ____exports.removeEntities(self, entities, cap)
18
23
  if #entities == 0 then
19
- return false
24
+ return {}
20
25
  end
21
- local numEntitiesRemoved = 0
26
+ local entitiesRemoved = {}
22
27
  for ____, entity in ipairs(entities) do
23
28
  entity:Remove()
24
- numEntitiesRemoved = numEntitiesRemoved + 1
25
- if cap ~= nil and numEntitiesRemoved >= cap then
26
- return true
29
+ entitiesRemoved[#entitiesRemoved + 1] = entity
30
+ if cap ~= nil and #entitiesRemoved >= cap then
31
+ return entitiesRemoved
27
32
  end
28
33
  end
29
- return true
34
+ return entitiesRemoved
30
35
  end
36
+ --- Helper function to count the number of entities in room. Use this over the vanilla
37
+ -- `Isaac.CountEntities` method to avoid having to specify a spawner and to handle ignoring charmed
38
+ -- enemies.
39
+ --
40
+ -- @param entityType Default is -1. -1 matches every entity type.
41
+ -- @param variant Default is -1. -1 matches every variant.
42
+ -- @param subType Default is -1. -1 matches every sub-type.
43
+ -- @param ignoreFriendly Default is false.
31
44
  function ____exports.countEntities(self, entityType, variant, subType, ignoreFriendly)
32
45
  if entityType == nil then
33
46
  entityType = -1
@@ -53,6 +66,16 @@ function ____exports.countEntities(self, entityType, variant, subType, ignoreFri
53
66
  )
54
67
  return #entities
55
68
  end
69
+ --- Given an array of entities, this helper function returns the closest one to a provided reference
70
+ -- entity.
71
+ --
72
+ -- For example:
73
+ --
74
+ -- ```ts
75
+ -- const player = Isaac.GetPlayer();
76
+ -- const gapers = getEntities(EntityType.GAPER);
77
+ -- const closestGaper = getClosestEntityTo(player, gapers);
78
+ -- ```
56
79
  function ____exports.getClosestEntityTo(self, referenceEntity, entities)
57
80
  local closestEntity
58
81
  local closestDistance = math.huge
@@ -65,6 +88,30 @@ function ____exports.getClosestEntityTo(self, referenceEntity, entities)
65
88
  end
66
89
  return closestEntity
67
90
  end
91
+ --- Helper function to get all of the entities in the room or all of the entities that match a
92
+ -- specific entity type / variant / sub-type.
93
+ --
94
+ -- Due to bugs with `Isaac.FindInRadius`, this function uses `Isaac.GetRoomEntities`, which is more
95
+ -- expensive but also more robust. (If a matching entity type is provided, then `Isaac.FindByType`
96
+ -- will be used instead.)
97
+ --
98
+ -- For example:
99
+ --
100
+ -- ```ts
101
+ -- // Make all of the entities in the room invisible
102
+ -- for (const entity of getEntities()) {
103
+ -- entity.Visible = false;
104
+ -- }
105
+ -- ```
106
+ --
107
+ -- @param entityType Optional. If specified, will only return NPCs that match this entity type.
108
+ -- @param variant Optional. If specified, will only return NPCs that match this variant. Default is
109
+ -- -1. -1 matches every variant.
110
+ -- @param subType Optional. If specified, will only return NPCs that match this sub-type. Default is
111
+ -- -1. -1 matches every sub-type.
112
+ -- @param ignoreFriendly Optional. If set to true, it will exclude friendly NPCs from being
113
+ -- returned. Default is false. Will only be taken into account if
114
+ -- `matchingEntityType` is specified.
68
115
  function ____exports.getEntities(self, entityType, variant, subType, ignoreFriendly)
69
116
  if variant == nil then
70
117
  variant = -1
@@ -80,9 +127,12 @@ function ____exports.getEntities(self, entityType, variant, subType, ignoreFrien
80
127
  end
81
128
  return Isaac.FindByType(entityType, variant, subType, ignoreFriendly)
82
129
  end
130
+ --- Helper function to return a string containing the entity's type, variant, and sub-type.
83
131
  function ____exports.getEntityID(self, entity)
84
132
  return (((tostring(entity.Type) .. ".") .. tostring(entity.Variant)) .. ".") .. tostring(entity.SubType)
85
133
  end
134
+ --- Helper function to compare two different arrays of entities. Returns the entities that are in the
135
+ -- second array but not in the first array.
86
136
  function ____exports.getFilteredNewEntities(self, oldEntities, newEntities)
87
137
  local oldEntitiesSet = __TS__New(Set)
88
138
  for ____, entity in ipairs(oldEntities) do
@@ -97,15 +147,28 @@ function ____exports.getFilteredNewEntities(self, oldEntities, newEntities)
97
147
  end
98
148
  )
99
149
  end
150
+ --- Helper function to measure an entity's velocity to see if it is moving.
151
+ --
152
+ -- @param entity The entity whose velocity to measure.
153
+ -- @param threshold Optional. The threshold from 0 to consider to be moving. Default is 0.01.
100
154
  function ____exports.isEntityMoving(self, entity, threshold)
101
155
  if threshold == nil then
102
156
  threshold = 0.01
103
157
  end
104
158
  return entity.Velocity:Length() >= threshold
105
159
  end
160
+ --- Helper function to determine if the specified entity type is an end-game story boss, like Isaac,
161
+ -- Blue Baby, Mega Satan, The Beast, and so on. This is useful because certain effects should only
162
+ -- apply to non-story bosses, like Vanishing Twin. Also see the `STORY_BOSSES` constant.
106
163
  function ____exports.isStoryBoss(self, entityType)
107
164
  return STORY_BOSSES_SET:has(entityType)
108
165
  end
166
+ --- Helper function to parse a string that contains an entity type, a variant, and a sub-type,
167
+ -- separated by periods.
168
+ --
169
+ -- For example, passing "45.0.1" would return an array of [45, 0, 1].
170
+ --
171
+ -- Returns undefined if the string cannot be parsed.
109
172
  function ____exports.parseEntityID(self, entityID)
110
173
  local entityIDArray = __TS__StringSplit(entityID, ".")
111
174
  if #entityIDArray ~= 3 then
@@ -126,6 +189,12 @@ function ____exports.parseEntityID(self, entityID)
126
189
  end
127
190
  return {entityType, variant, subType}
128
191
  end
192
+ --- Helper function to parse a string that contains an entity type and a variant separated by a
193
+ -- period.
194
+ --
195
+ -- For example, passing "45.0" would return an array of [45, 0].
196
+ --
197
+ -- Returns undefined if the string cannot be parsed.
129
198
  function ____exports.parseEntityTypeVariantString(self, entityTypeVariantString)
130
199
  local entityTypeVariantArray = __TS__StringSplit(entityTypeVariantString, ".")
131
200
  if #entityTypeVariantArray ~= 2 then
@@ -142,6 +211,13 @@ function ____exports.parseEntityTypeVariantString(self, entityTypeVariantString)
142
211
  end
143
212
  return {entityType, variant}
144
213
  end
214
+ --- Helper function to remove all of the matching entities in the room.
215
+ --
216
+ -- @param entityType The entity type to match.
217
+ -- @param entityVariant Optional. The variant to match. Default is -1. -1 matches every variant.
218
+ -- @param entitySubType Optional. The sub-type to match. Default is -1. -1 matches every sub-type.
219
+ -- @param cap Optional. If specified, will only remove the given amount of collectibles.
220
+ -- @returns An array of the entities that were removed.
145
221
  function ____exports.removeAllMatchingEntities(self, entityType, entityVariant, entitySubType, cap)
146
222
  if entityVariant == nil then
147
223
  entityVariant = -1
@@ -155,6 +231,12 @@ function ____exports.removeAllMatchingEntities(self, entityType, entityVariant,
155
231
  local entities = ____exports.getEntities(nil, entityType, entityVariant, entitySubType)
156
232
  return ____exports.removeEntities(nil, entities, cap)
157
233
  end
234
+ --- Helper function to reroll an enemy. Use this instead of the vanilla "Game.RerollEnemy" function
235
+ -- if you want the rerolled enemy to be returned.
236
+ --
237
+ -- @param entity The entity to reroll.
238
+ -- @returns If the game failed to reroll the enemy, returns undefined. Otherwise, returns the
239
+ -- rerolled entity.
158
240
  function ____exports.rerollEnemy(self, entity)
159
241
  local oldEntities = ____exports.getEntities(nil)
160
242
  local wasRerolled = game:RerollEnemy(entity)
@@ -182,6 +264,10 @@ function ____exports.setEntityRandomColor(self, entity)
182
264
  false
183
265
  )
184
266
  end
267
+ --- Helper function to spawn an entity. Use this instead of the `Isaac.Spawn` method if you do not
268
+ -- need to specify the velocity or spawner.
269
+ --
270
+ -- Also see the `spawnWithSeed` helper function.
185
271
  function ____exports.spawn(self, entityType, variant, subType, position, velocity, spawner, seed)
186
272
  if velocity == nil then
187
273
  velocity = VectorZero
@@ -212,6 +298,8 @@ function ____exports.spawn(self, entityType, variant, subType, position, velocit
212
298
  seed
213
299
  )
214
300
  end
301
+ --- Helper function to spawn an entity. Use this instead of the `Game.Spawn` method if you do not
302
+ -- need to specify the velocity or spawner.
215
303
  function ____exports.spawnWithSeed(self, entityType, variant, subType, position, seed, velocity, spawner)
216
304
  if velocity == nil then
217
305
  velocity = VectorZero
@@ -138,18 +138,18 @@ export declare function npcFireProjectiles(npc: EntityNPC, position: Vector, vel
138
138
  * @param bombVariant Optional. If specified, will only remove bombs that match this variant.
139
139
  * @param subType Optional. If specified, will only remove bombs that match this sub-type.
140
140
  * @param cap Optional. If specified, will only remove the given amount of bombs.
141
- * @returns True if one or more bombs were removed, false otherwise.
141
+ * @returns An array of the bombs that were removed.
142
142
  */
143
- export declare function removeAllBombs(bombVariant?: BombVariant, subType?: int, cap?: int): boolean;
143
+ export declare function removeAllBombs(bombVariant?: BombVariant, subType?: int, cap?: int): EntityBomb[];
144
144
  /**
145
145
  * Helper function to remove all of the effects in the room.
146
146
  *
147
147
  * @param effectVariant Optional. If specified, will only remove effects that match this variant.
148
148
  * @param subType Optional. If specified, will only remove effects that match this sub-type.
149
149
  * @param cap Optional. If specified, will only remove the given amount of effects.
150
- * @returns True if one or more effects were removed, false otherwise.
150
+ * @returns An array of the effects that were removed.
151
151
  */
152
- export declare function removeAllEffects(effectVariant?: EffectVariant, subType?: int, cap?: int): boolean;
152
+ export declare function removeAllEffects(effectVariant?: EffectVariant, subType?: int, cap?: int): EntityEffect[];
153
153
  /**
154
154
  * Helper function to remove all of the familiars in the room.
155
155
  *
@@ -157,43 +157,43 @@ export declare function removeAllEffects(effectVariant?: EffectVariant, subType?
157
157
  * variant.
158
158
  * @param subType Optional. If specified, will only remove familiars that match this sub-type.
159
159
  * @param cap Optional. If specified, will only remove the given amount of familiars.
160
- * @returns True if one or more familiars were removed, false otherwise.
160
+ * @returns An array of the familiars that were removed.
161
161
  */
162
- export declare function removeAllFamiliars(familiarVariant?: FamiliarVariant, subType?: int, cap?: int): boolean;
162
+ export declare function removeAllFamiliars(familiarVariant?: FamiliarVariant, subType?: int, cap?: int): EntityFamiliar[];
163
163
  /**
164
164
  * Helper function to remove all of the `EntityType.KNIFE` in the room.
165
165
  *
166
166
  * @param knifeVariant Optional. If specified, will only remove knives that match this variant.
167
167
  * @param subType Optional. If specified, will only remove knives that match this sub-type.
168
168
  * @param cap Optional. If specified, will only remove the given amount of knives.
169
- * @returns True if one or more knives were removed, false otherwise.
169
+ * @returns An array of the knives that were removed.
170
170
  */
171
- export declare function removeAllKnives(knifeVariant?: KnifeVariant, subType?: int, cap?: int): boolean;
171
+ export declare function removeAllKnives(knifeVariant?: KnifeVariant, subType?: int, cap?: int): EntityKnife[];
172
172
  /**
173
173
  * Helper function to remove all of the `EntityType.LASER` in the room.
174
174
  *
175
175
  * @param laserVariant Optional. If specified, will only remove lasers that match this variant.
176
176
  * @param subType Optional. If specified, will only remove lasers that match this sub-type.
177
177
  * @param cap Optional. If specified, will only remove the given amount of lasers.
178
- * @returns True if one or more lasers were removed, false otherwise.
178
+ * @returns An array of the lasers that were removed.
179
179
  */
180
- export declare function removeAllLasers(laserVariant?: LaserVariant, subType?: int, cap?: int): boolean;
180
+ export declare function removeAllLasers(laserVariant?: LaserVariant, subType?: int, cap?: int): EntityLaser[];
181
181
  /**
182
182
  * Helper function to remove all NPCs in the room.
183
183
  *
184
184
  * @param cap Optional. If specified, will only remove the given amount of NPCs.
185
- * @returns True if one or more NPCs were removed, false otherwise.
185
+ * @returns An array of the NPCs that were removed.
186
186
  */
187
- export declare function removeAllNPCs(cap?: int): boolean;
187
+ export declare function removeAllNPCs(cap?: int): EntityNPC[];
188
188
  /**
189
189
  * Helper function to remove all of the pickups in the room.
190
190
  *
191
191
  * @param pickupVariant Optional. If specified, will only remove pickups that match this variant.
192
192
  * @param subType Optional. If specified, will only remove pickups that match this sub-type.
193
193
  * @param cap Optional. If specified, will only remove the given amount of pickups.
194
- * @returns True if one or more pickups were removed, false otherwise.
194
+ * @returns An array of the pickups that were removed.
195
195
  */
196
- export declare function removeAllPickups(pickupVariant?: PickupVariant, subType?: int, cap?: int): boolean;
196
+ export declare function removeAllPickups(pickupVariant?: PickupVariant, subType?: int, cap?: int): EntityPickup[];
197
197
  /**
198
198
  * Helper function to remove all of the `EntityType.PROJECTILE` in the room.
199
199
  *
@@ -201,27 +201,27 @@ export declare function removeAllPickups(pickupVariant?: PickupVariant, subType?
201
201
  * variant.
202
202
  * @param subType Optional. If specified, will only remove projectiles that match this sub-type.
203
203
  * @param cap Optional. If specified, will only remove the given amount of projectiles.
204
- * @returns True if one or more projectiles were removed, false otherwise.
204
+ * @returns An array of the projectiles that were removed.
205
205
  */
206
- export declare function removeAllProjectiles(projectileVariant?: ProjectileVariant, subType?: int, cap?: int): boolean;
206
+ export declare function removeAllProjectiles(projectileVariant?: ProjectileVariant, subType?: int, cap?: int): EntityProjectile[];
207
207
  /**
208
208
  * Helper function to remove all of the `EntityType.SLOT` in the room.
209
209
  *
210
210
  * @param slotVariant Optional. If specified, will only remove slots that match this variant.
211
211
  * @param subType Optional. If specified, will only remove slots that match this sub-type.
212
212
  * @param cap Optional. If specified, will only remove the given amount of slots.
213
- * @returns True if one or more slots were removed, false otherwise.
213
+ * @returns An array of the slots that were removed.
214
214
  */
215
- export declare function removeAllSlots(slotVariant?: SlotVariant, subType?: int, cap?: int): boolean;
215
+ export declare function removeAllSlots(slotVariant?: SlotVariant, subType?: int, cap?: int): Entity[];
216
216
  /**
217
217
  * Helper function to remove all of the `EntityType.TEAR` in the room.
218
218
  *
219
219
  * @param tearVariant Optional. If specified, will only remove tears that match this variant.
220
220
  * @param subType Optional. If specified, will only remove tears that match this sub-type.
221
221
  * @param cap Optional. If specified, will only remove the given amount of tears.
222
- * @returns True if one or more tears were removed, false otherwise.
222
+ * @returns An array of the tears that were removed.
223
223
  */
224
- export declare function removeAllTears(tearVariant?: TearVariant, subType?: int, cap?: int): boolean;
224
+ export declare function removeAllTears(tearVariant?: TearVariant, subType?: int, cap?: int): EntityTear[];
225
225
  /** Helper function to spawn a `EntityType.BOMB` (4). */
226
226
  export declare function spawnBomb(bombVariant: BombVariant, subType: int, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seed?: Seed | undefined): EntityBomb;
227
227
  /** Helper function to spawn a `EntityType.BOMB` (4) with a specific seed. */