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
@@ -8,6 +8,16 @@ local getEntities = ____entity.getEntities
8
8
  local getFilteredNewEntities = ____entity.getFilteredNewEntities
9
9
  local removeEntities = ____entity.removeEntities
10
10
  local spawn = ____entity.spawn
11
+ --- Helper function to get all of the `EntityType.BOMB` in the room.
12
+ --
13
+ -- For example:
14
+ --
15
+ -- ```ts
16
+ -- // Make all of the bombs in the room invisible
17
+ -- for (const bomb of getBombs()) {
18
+ -- bomb.Visible = false;
19
+ -- }
20
+ -- ```
11
21
  function ____exports.getBombs(self, bombVariant, subType)
12
22
  if bombVariant == nil then
13
23
  bombVariant = -1
@@ -25,6 +35,16 @@ function ____exports.getBombs(self, bombVariant, subType)
25
35
  end
26
36
  return bombs
27
37
  end
38
+ --- Helper function to get all of the `EntityType.EFFECT` in the room.
39
+ --
40
+ -- For example:
41
+ --
42
+ -- ```ts
43
+ -- // Make all of the effects in the room invisible
44
+ -- for (const effect of getEffects()) {
45
+ -- effect.Visible = false;
46
+ -- }
47
+ -- ```
28
48
  function ____exports.getEffects(self, effectVariant, subType)
29
49
  if effectVariant == nil then
30
50
  effectVariant = -1
@@ -42,6 +62,16 @@ function ____exports.getEffects(self, effectVariant, subType)
42
62
  end
43
63
  return effects
44
64
  end
65
+ --- Helper function to get all of the familiars in the room.
66
+ --
67
+ -- For example:
68
+ --
69
+ -- ```ts
70
+ -- // Make all of the familiars in the room invisible
71
+ -- for (const familiar of getFamiliars()) {
72
+ -- familiar.Visible = false;
73
+ -- }
74
+ -- ```
45
75
  function ____exports.getFamiliars(self, familiarVariant, subType)
46
76
  if familiarVariant == nil then
47
77
  familiarVariant = -1
@@ -59,6 +89,16 @@ function ____exports.getFamiliars(self, familiarVariant, subType)
59
89
  end
60
90
  return familiars
61
91
  end
92
+ --- Helper function to get all of the `EntityType.KNIFE` in the room.
93
+ --
94
+ -- For example:
95
+ --
96
+ -- ```ts
97
+ -- // Make all of the knives in the room invisible
98
+ -- for (const knife of getKnives()) {
99
+ -- knife.Visible = false;
100
+ -- }
101
+ -- ```
62
102
  function ____exports.getKnives(self, knifeVariant, subType)
63
103
  if knifeVariant == nil then
64
104
  knifeVariant = -1
@@ -76,6 +116,16 @@ function ____exports.getKnives(self, knifeVariant, subType)
76
116
  end
77
117
  return knives
78
118
  end
119
+ --- Helper function to get all of the `EntityType.LASER` in the room.
120
+ --
121
+ -- For example:
122
+ --
123
+ -- ```ts
124
+ -- // Make all of the lasers in the room invisible
125
+ -- for (const laser of getLasers()) {
126
+ -- laser.Visible = false;
127
+ -- }
128
+ -- ```
79
129
  function ____exports.getLasers(self, laserVariant, subType)
80
130
  if laserVariant == nil then
81
131
  laserVariant = -1
@@ -93,6 +143,7 @@ function ____exports.getLasers(self, laserVariant, subType)
93
143
  end
94
144
  return lasers
95
145
  end
146
+ --- The same thing as the `getEntities` function, but returns only NPCs.
96
147
  function ____exports.getNPCs(self, entityType, variant, subType, ignoreFriendly)
97
148
  if ignoreFriendly == nil then
98
149
  ignoreFriendly = false
@@ -113,6 +164,16 @@ function ____exports.getNPCs(self, entityType, variant, subType, ignoreFriendly)
113
164
  end
114
165
  return npcs
115
166
  end
167
+ --- Helper function to get all of the pickups in the room.
168
+ --
169
+ -- For example:
170
+ --
171
+ -- ```ts
172
+ -- // Make all of the pickups in the room invisible
173
+ -- for (const pickup of getPickups()) {
174
+ -- pickup.Visible = false;
175
+ -- }
176
+ -- ```
116
177
  function ____exports.getPickups(self, pickupVariant, subType)
117
178
  if pickupVariant == nil then
118
179
  pickupVariant = -1
@@ -130,6 +191,16 @@ function ____exports.getPickups(self, pickupVariant, subType)
130
191
  end
131
192
  return pickups
132
193
  end
194
+ --- Helper function to get all of the `EntityType.PROJECTILE` in the room.
195
+ --
196
+ -- For example:
197
+ --
198
+ -- ```ts
199
+ -- // Make all of the projectiles in the room invisible
200
+ -- for (const projectile of getProjectiles()) {
201
+ -- projectile.Visible = false;
202
+ -- }
203
+ -- ```
133
204
  function ____exports.getProjectiles(self, projectileVariant, subType)
134
205
  if projectileVariant == nil then
135
206
  projectileVariant = -1
@@ -147,6 +218,16 @@ function ____exports.getProjectiles(self, projectileVariant, subType)
147
218
  end
148
219
  return projectiles
149
220
  end
221
+ --- Helper function to get all of the `EntityType.SLOT` in the room.
222
+ --
223
+ -- For example:
224
+ --
225
+ -- ```ts
226
+ -- // Make all of the slots in the room invisible
227
+ -- for (const slot of getSlots()) {
228
+ -- slot.Visible = false;
229
+ -- }
230
+ -- ```
150
231
  function ____exports.getSlots(self, slotVariant, subType)
151
232
  if slotVariant == nil then
152
233
  slotVariant = -1
@@ -157,6 +238,16 @@ function ____exports.getSlots(self, slotVariant, subType)
157
238
  local slots = getEntities(nil, EntityType.SLOT, slotVariant, subType)
158
239
  return slots
159
240
  end
241
+ --- Helper function to get all of the `EntityType.TEAR` in the room.
242
+ --
243
+ -- For example:
244
+ --
245
+ -- ```ts
246
+ -- // Make all of the tears in the room invisible
247
+ -- for (const tear of getTears()) {
248
+ -- tear.Visible = false;
249
+ -- }
250
+ -- ```
160
251
  function ____exports.getTears(self, tearVariant, subType)
161
252
  if tearVariant == nil then
162
253
  tearVariant = -1
@@ -174,6 +265,17 @@ function ____exports.getTears(self, tearVariant, subType)
174
265
  end
175
266
  return tears
176
267
  end
268
+ --- The base game `EntityNPC.FireProjectiles` method does not return anything, which is a problem in
269
+ -- situations where you need to work with the fired projectiles. This function invokes that method,
270
+ -- and then returns the projectiles that were spawned.
271
+ --
272
+ -- @param npc The EntityNPC firing projectiles.
273
+ -- @param position The starting position of the projectiles.
274
+ -- @param velocity The starting velocity of the projectiles.
275
+ -- @param projectilesMode A ProjectilesMode enum value defining how to fire the projectiles.
276
+ -- @param projectileParams A ProjectileParams object containing various parameters for the
277
+ -- projectiles.
278
+ -- @returns An array of EntityProjectiles containing all fired projectiles.
177
279
  function ____exports.npcFireProjectiles(self, npc, position, velocity, projectilesMode, projectileParams)
178
280
  local oldEntities = ____exports.getProjectiles(nil)
179
281
  npc:FireProjectiles(position, velocity, projectilesMode, projectileParams)
@@ -181,46 +283,107 @@ function ____exports.npcFireProjectiles(self, npc, position, velocity, projectil
181
283
  local filteredNewEntities = getFilteredNewEntities(nil, oldEntities, newEntities)
182
284
  return filteredNewEntities
183
285
  end
286
+ --- Helper function to remove all of the `EntityType.BOMB` in the room.
287
+ --
288
+ -- @param bombVariant Optional. If specified, will only remove bombs that match this variant.
289
+ -- @param subType Optional. If specified, will only remove bombs that match this sub-type.
290
+ -- @param cap Optional. If specified, will only remove the given amount of bombs.
291
+ -- @returns An array of the bombs that were removed.
184
292
  function ____exports.removeAllBombs(self, bombVariant, subType, cap)
185
293
  local bombs = ____exports.getBombs(nil, bombVariant, subType)
186
294
  return removeEntities(nil, bombs, cap)
187
295
  end
296
+ --- Helper function to remove all of the effects in the room.
297
+ --
298
+ -- @param effectVariant Optional. If specified, will only remove effects that match this variant.
299
+ -- @param subType Optional. If specified, will only remove effects that match this sub-type.
300
+ -- @param cap Optional. If specified, will only remove the given amount of effects.
301
+ -- @returns An array of the effects that were removed.
188
302
  function ____exports.removeAllEffects(self, effectVariant, subType, cap)
189
303
  local effects = ____exports.getEffects(nil, effectVariant, subType)
190
304
  return removeEntities(nil, effects, cap)
191
305
  end
306
+ --- Helper function to remove all of the familiars in the room.
307
+ --
308
+ -- @param familiarVariant Optional. If specified, will only remove familiars that match this
309
+ -- variant.
310
+ -- @param subType Optional. If specified, will only remove familiars that match this sub-type.
311
+ -- @param cap Optional. If specified, will only remove the given amount of familiars.
312
+ -- @returns An array of the familiars that were removed.
192
313
  function ____exports.removeAllFamiliars(self, familiarVariant, subType, cap)
193
314
  local familiars = ____exports.getFamiliars(nil, familiarVariant, subType)
194
315
  return removeEntities(nil, familiars, cap)
195
316
  end
317
+ --- Helper function to remove all of the `EntityType.KNIFE` in the room.
318
+ --
319
+ -- @param knifeVariant Optional. If specified, will only remove knives that match this variant.
320
+ -- @param subType Optional. If specified, will only remove knives that match this sub-type.
321
+ -- @param cap Optional. If specified, will only remove the given amount of knives.
322
+ -- @returns An array of the knives that were removed.
196
323
  function ____exports.removeAllKnives(self, knifeVariant, subType, cap)
197
324
  local knives = ____exports.getKnives(nil, knifeVariant, subType)
198
325
  return removeEntities(nil, knives, cap)
199
326
  end
327
+ --- Helper function to remove all of the `EntityType.LASER` in the room.
328
+ --
329
+ -- @param laserVariant Optional. If specified, will only remove lasers that match this variant.
330
+ -- @param subType Optional. If specified, will only remove lasers that match this sub-type.
331
+ -- @param cap Optional. If specified, will only remove the given amount of lasers.
332
+ -- @returns An array of the lasers that were removed.
200
333
  function ____exports.removeAllLasers(self, laserVariant, subType, cap)
201
334
  local lasers = ____exports.getLasers(nil, laserVariant, subType)
202
335
  return removeEntities(nil, lasers, cap)
203
336
  end
337
+ --- Helper function to remove all NPCs in the room.
338
+ --
339
+ -- @param cap Optional. If specified, will only remove the given amount of NPCs.
340
+ -- @returns An array of the NPCs that were removed.
204
341
  function ____exports.removeAllNPCs(self, cap)
205
342
  local npcs = ____exports.getNPCs(nil)
206
343
  return removeEntities(nil, npcs, cap)
207
344
  end
345
+ --- Helper function to remove all of the pickups in the room.
346
+ --
347
+ -- @param pickupVariant Optional. If specified, will only remove pickups that match this variant.
348
+ -- @param subType Optional. If specified, will only remove pickups that match this sub-type.
349
+ -- @param cap Optional. If specified, will only remove the given amount of pickups.
350
+ -- @returns An array of the pickups that were removed.
208
351
  function ____exports.removeAllPickups(self, pickupVariant, subType, cap)
209
352
  local pickups = ____exports.getPickups(nil, pickupVariant, subType)
210
353
  return removeEntities(nil, pickups, cap)
211
354
  end
355
+ --- Helper function to remove all of the `EntityType.PROJECTILE` in the room.
356
+ --
357
+ -- @param projectileVariant Optional. If specified, will only remove projectiles that match this
358
+ -- variant.
359
+ -- @param subType Optional. If specified, will only remove projectiles that match this sub-type.
360
+ -- @param cap Optional. If specified, will only remove the given amount of projectiles.
361
+ -- @returns An array of the projectiles that were removed.
212
362
  function ____exports.removeAllProjectiles(self, projectileVariant, subType, cap)
213
363
  local projectiles = ____exports.getProjectiles(nil, projectileVariant, subType)
214
364
  return removeEntities(nil, projectiles, cap)
215
365
  end
366
+ --- Helper function to remove all of the `EntityType.SLOT` in the room.
367
+ --
368
+ -- @param slotVariant Optional. If specified, will only remove slots that match this variant.
369
+ -- @param subType Optional. If specified, will only remove slots that match this sub-type.
370
+ -- @param cap Optional. If specified, will only remove the given amount of slots.
371
+ -- @returns An array of the slots that were removed.
216
372
  function ____exports.removeAllSlots(self, slotVariant, subType, cap)
217
373
  local slots = ____exports.getSlots(nil, slotVariant, subType)
218
374
  return removeEntities(nil, slots, cap)
219
375
  end
376
+ --- Helper function to remove all of the `EntityType.TEAR` in the room.
377
+ --
378
+ -- @param tearVariant Optional. If specified, will only remove tears that match this variant.
379
+ -- @param subType Optional. If specified, will only remove tears that match this sub-type.
380
+ -- @param cap Optional. If specified, will only remove the given amount of tears.
381
+ -- @returns An array of the tears that were removed.
220
382
  function ____exports.removeAllTears(self, tearVariant, subType, cap)
221
383
  local tears = ____exports.getTears(nil, tearVariant, subType)
222
384
  return removeEntities(nil, tears, cap)
223
385
  end
386
+ --- Helper function to spawn a `EntityType.BOMB` (4).
224
387
  function ____exports.spawnBomb(self, bombVariant, subType, position, velocity, spawner, seed)
225
388
  if velocity == nil then
226
389
  velocity = VectorZero
@@ -247,6 +410,7 @@ function ____exports.spawnBomb(self, bombVariant, subType, position, velocity, s
247
410
  end
248
411
  return bomb
249
412
  end
413
+ --- Helper function to spawn a `EntityType.BOMB` (4) with a specific seed.
250
414
  function ____exports.spawnBombWithSeed(self, bombVariant, subType, position, seed, velocity, spawner)
251
415
  if velocity == nil then
252
416
  velocity = VectorZero
@@ -264,6 +428,7 @@ function ____exports.spawnBombWithSeed(self, bombVariant, subType, position, see
264
428
  seed
265
429
  )
266
430
  end
431
+ --- Helper function to spawn a `EntityType.EFFECT` (1000).
267
432
  function ____exports.spawnEffect(self, effectVariant, subType, position, velocity, spawner, seed)
268
433
  if velocity == nil then
269
434
  velocity = VectorZero
@@ -290,6 +455,7 @@ function ____exports.spawnEffect(self, effectVariant, subType, position, velocit
290
455
  end
291
456
  return effect
292
457
  end
458
+ --- Helper function to spawn a `EntityType.EFFECT` (1000) with a specific seed.
293
459
  function ____exports.spawnEffectWithSeed(self, effectVariant, subType, position, seed, velocity, spawner)
294
460
  if velocity == nil then
295
461
  velocity = VectorZero
@@ -307,6 +473,7 @@ function ____exports.spawnEffectWithSeed(self, effectVariant, subType, position,
307
473
  seed
308
474
  )
309
475
  end
476
+ --- Helper function to spawn a `EntityType.FAMILIAR` (3).
310
477
  function ____exports.spawnFamiliar(self, familiarVariant, subType, position, velocity, spawner, seed)
311
478
  if velocity == nil then
312
479
  velocity = VectorZero
@@ -333,6 +500,7 @@ function ____exports.spawnFamiliar(self, familiarVariant, subType, position, vel
333
500
  end
334
501
  return familiar
335
502
  end
503
+ --- Helper function to spawn a `EntityType.FAMILIAR` (3) with a specific seed.
336
504
  function ____exports.spawnFamiliarWithSeed(self, familiarVariant, subType, position, seed, velocity, spawner)
337
505
  if velocity == nil then
338
506
  velocity = VectorZero
@@ -350,6 +518,7 @@ function ____exports.spawnFamiliarWithSeed(self, familiarVariant, subType, posit
350
518
  seed
351
519
  )
352
520
  end
521
+ --- Helper function to spawn a `EntityType.KNIFE` (8).
353
522
  function ____exports.spawnKnife(self, knifeVariant, subType, position, velocity, spawner, seed)
354
523
  if velocity == nil then
355
524
  velocity = VectorZero
@@ -376,6 +545,7 @@ function ____exports.spawnKnife(self, knifeVariant, subType, position, velocity,
376
545
  end
377
546
  return knife
378
547
  end
548
+ --- Helper function to spawn a `EntityType.KNIFE` (8) with a specific seed.
379
549
  function ____exports.spawnKnifeWithSeed(self, knifeVariant, subType, position, seed, velocity, spawner)
380
550
  if velocity == nil then
381
551
  velocity = VectorZero
@@ -393,6 +563,7 @@ function ____exports.spawnKnifeWithSeed(self, knifeVariant, subType, position, s
393
563
  seed
394
564
  )
395
565
  end
566
+ --- Helper function to spawn a `EntityType.LASER` (7).
396
567
  function ____exports.spawnLaser(self, laserVariant, subType, position, velocity, spawner, seed)
397
568
  if velocity == nil then
398
569
  velocity = VectorZero
@@ -419,6 +590,7 @@ function ____exports.spawnLaser(self, laserVariant, subType, position, velocity,
419
590
  end
420
591
  return laser
421
592
  end
593
+ --- Helper function to spawn a `EntityType.LASER` (7) with a specific seed.
422
594
  function ____exports.spawnLaserWithSeed(self, laserVariant, subType, position, seed, velocity, spawner)
423
595
  if velocity == nil then
424
596
  velocity = VectorZero
@@ -436,6 +608,7 @@ function ____exports.spawnLaserWithSeed(self, laserVariant, subType, position, s
436
608
  seed
437
609
  )
438
610
  end
611
+ --- Helper function to spawn an NPC.
439
612
  function ____exports.spawnNPC(self, entityType, variant, subType, position, velocity, spawner, seed)
440
613
  if velocity == nil then
441
614
  velocity = VectorZero
@@ -462,6 +635,7 @@ function ____exports.spawnNPC(self, entityType, variant, subType, position, velo
462
635
  end
463
636
  return npc
464
637
  end
638
+ --- Helper function to spawn an NPC with a specific seed.
465
639
  function ____exports.spawnNPCWithSeed(self, entityType, variant, subType, position, seed, velocity, spawner)
466
640
  if velocity == nil then
467
641
  velocity = VectorZero
@@ -480,6 +654,7 @@ function ____exports.spawnNPCWithSeed(self, entityType, variant, subType, positi
480
654
  seed
481
655
  )
482
656
  end
657
+ --- Helper function to spawn a `EntityType.PICKUP` (5).
483
658
  function ____exports.spawnPickup(self, pickupVariant, subType, position, velocity, spawner, seed)
484
659
  if velocity == nil then
485
660
  velocity = VectorZero
@@ -506,6 +681,7 @@ function ____exports.spawnPickup(self, pickupVariant, subType, position, velocit
506
681
  end
507
682
  return pickup
508
683
  end
684
+ --- Helper function to spawn a `EntityType.PICKUP` (5) with a specific seed.
509
685
  function ____exports.spawnPickupWithSeed(self, pickupVariant, subType, position, seed, velocity, spawner)
510
686
  if velocity == nil then
511
687
  velocity = VectorZero
@@ -523,6 +699,7 @@ function ____exports.spawnPickupWithSeed(self, pickupVariant, subType, position,
523
699
  seed
524
700
  )
525
701
  end
702
+ --- Helper function to spawn a `EntityType.PROJECTILE` (9).
526
703
  function ____exports.spawnProjectile(self, projectileVariant, subType, position, velocity, spawner, seed)
527
704
  if velocity == nil then
528
705
  velocity = VectorZero
@@ -549,6 +726,7 @@ function ____exports.spawnProjectile(self, projectileVariant, subType, position,
549
726
  end
550
727
  return projectile
551
728
  end
729
+ --- Helper function to spawn a `EntityType.PROJECTILE` (9) with a specific seed.
552
730
  function ____exports.spawnProjectileWithSeed(self, projectileVariant, subType, position, seed, velocity, spawner)
553
731
  if velocity == nil then
554
732
  velocity = VectorZero
@@ -566,6 +744,7 @@ function ____exports.spawnProjectileWithSeed(self, projectileVariant, subType, p
566
744
  seed
567
745
  )
568
746
  end
747
+ --- Helper function to spawn a `EntityType.SLOT` (6).
569
748
  function ____exports.spawnSlot(self, slotVariant, subType, position, velocity, spawner, seed)
570
749
  if velocity == nil then
571
750
  velocity = VectorZero
@@ -587,6 +766,7 @@ function ____exports.spawnSlot(self, slotVariant, subType, position, velocity, s
587
766
  seed
588
767
  )
589
768
  end
769
+ --- Helper function to spawn a `EntityType.SLOT` (6) with a specific seed.
590
770
  function ____exports.spawnSlotWithSeed(self, slotVariant, subType, position, seed, velocity, spawner)
591
771
  if velocity == nil then
592
772
  velocity = VectorZero
@@ -604,6 +784,7 @@ function ____exports.spawnSlotWithSeed(self, slotVariant, subType, position, see
604
784
  seed
605
785
  )
606
786
  end
787
+ --- Helper function to spawn a `EntityType.TEAR` (2).
607
788
  function ____exports.spawnTear(self, tearVariant, subType, position, velocity, spawner, seed)
608
789
  if velocity == nil then
609
790
  velocity = VectorZero
@@ -630,6 +811,7 @@ function ____exports.spawnTear(self, tearVariant, subType, position, velocity, s
630
811
  end
631
812
  return tear
632
813
  end
814
+ --- Helper function to spawn a `EntityType.EntityType` (2) with a specific seed.
633
815
  function ____exports.spawnTearWithSeed(self, tearVariant, subType, position, seed, velocity, spawner)
634
816
  if velocity == nil then
635
817
  velocity = VectorZero
@@ -1,3 +1,3 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
- /** For EntityType.SLOT (6) */
2
+ /** For `EntityType.SLOT` (6) */
3
3
  export declare function isSlot(entity: Entity): entity is EntitySlot;
@@ -1,6 +1,7 @@
1
1
  local ____exports = {}
2
2
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
3
3
  local EntityType = ____isaac_2Dtypescript_2Ddefinitions.EntityType
4
+ --- For `EntityType.SLOT` (6)
4
5
  function ____exports.isSlot(self, entity)
5
6
  return entity.Type == EntityType.SLOT
6
7
  end
@@ -1,4 +1,6 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
+ /// <reference types="isaac-typescript-definitions" />
3
+ /// <reference types="isaac-typescript-definitions" />
2
4
  /**
3
5
  * TypeScriptToLua will transpile TypeScript enums to Lua tables that have a double mapping. Thus,
4
6
  * when you iterate over them, you will get both the names of the enums and the values of the enums,
@@ -6,6 +6,21 @@ local ____array = require("functions.array")
6
6
  local getRandomArrayElement = ____array.getRandomArrayElement
7
7
  local ____rng = require("functions.rng")
8
8
  local getRandomSeed = ____rng.getRandomSeed
9
+ --- TypeScriptToLua will transpile TypeScript enums to Lua tables that have a double mapping. Thus,
10
+ -- when you iterate over them, you will get both the names of the enums and the values of the enums,
11
+ -- in a random order. Use this helper function to get the entries of the enum with the reverse
12
+ -- mappings filtered out.
13
+ --
14
+ -- This function will return the enum values in a sorted order, which may not necessarily be the
15
+ -- same order as which they were declared in.
16
+ --
17
+ -- This function will work properly for both number enums and string enums. (Reverse mappings are
18
+ -- not created for string enums.)
19
+ --
20
+ -- Also see the `getEnumKeys` and `getEnumValues` helper functions.
21
+ --
22
+ -- For a more in depth explanation, see:
23
+ -- https://isaacscript.github.io/gotchas#iterating-over-enums
9
24
  function ____exports.getEnumEntries(self, transpiledEnum)
10
25
  local enumEntries = {}
11
26
  for key, value in pairs(transpiledEnum) do
@@ -27,6 +42,20 @@ function ____exports.getEnumEntries(self, transpiledEnum)
27
42
  )
28
43
  return enumEntries
29
44
  end
45
+ --- TypeScriptToLua will transpile TypeScript enums to Lua tables that have a double mapping. Thus,
46
+ -- when you iterate over them, you will get both the names of the enums and the values of the enums,
47
+ -- in a random order. If all you need are the keys of an enum, use this helper function.
48
+ --
49
+ -- This function will return the enum keys in a sorted order, which may not necessarily be the same
50
+ -- order as which they were declared in.
51
+ --
52
+ -- This function will work properly for both number enums and string enums. (Reverse mappings are
53
+ -- not created for string enums.)
54
+ --
55
+ -- Also see the `getEnumEntries` and `getEnumValues` helper functions.
56
+ --
57
+ -- For a more in depth explanation, see:
58
+ -- https://isaacscript.github.io/gotchas#iterating-over-enums
30
59
  function ____exports.getEnumKeys(self, transpiledEnum)
31
60
  local enumEntries = ____exports.getEnumEntries(nil, transpiledEnum)
32
61
  return __TS__ArrayMap(
@@ -39,10 +68,25 @@ function ____exports.getEnumKeys(self, transpiledEnum)
39
68
  end
40
69
  )
41
70
  end
71
+ --- Helper function to get the amount of entries inside of an enum.
42
72
  function ____exports.getEnumLength(self, transpiledEnum)
43
73
  local enumEntries = ____exports.getEnumEntries(nil, transpiledEnum)
44
74
  return #enumEntries
45
75
  end
76
+ --- TypeScriptToLua will transpile TypeScript enums to Lua tables that have a double mapping. Thus,
77
+ -- when you iterate over them, you will get both the names of the enums and the values of the enums,
78
+ -- in a random order. If all you need are the values of an enum, use this helper function.
79
+ --
80
+ -- This function will return the enum values in a sorted order, which may not necessarily be the
81
+ -- same order as which they were declared in.
82
+ --
83
+ -- This function will work properly for both number enums and string enums. (Reverse mappings are
84
+ -- not created for string enums.)
85
+ --
86
+ -- Also see the `getEnumEntries` and `getEnumKeys` helper functions.
87
+ --
88
+ -- For a more in depth explanation, see:
89
+ -- https://isaacscript.github.io/gotchas#iterating-over-enums
46
90
  function ____exports.getEnumValues(self, transpiledEnum)
47
91
  local enumEntries = ____exports.getEnumEntries(nil, transpiledEnum)
48
92
  return __TS__ArrayMap(
@@ -63,6 +107,12 @@ function ____exports.getLastEnumValue(self, transpiledEnum)
63
107
  end
64
108
  return lastElement
65
109
  end
110
+ --- Helper function to get a random value from the provided enum.
111
+ --
112
+ -- @param transpiledEnum The enum to get the value from.
113
+ -- @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
114
+ -- `RNG.Next` method will be called. Default is `getRandomSeed()`.
115
+ -- @param exceptions Optional. An array of elements to skip over if selected.
66
116
  function ____exports.getRandomEnumValue(self, transpiledEnum, seedOrRNG, exceptions)
67
117
  if seedOrRNG == nil then
68
118
  seedOrRNG = getRandomSeed(nil)
@@ -73,6 +123,18 @@ function ____exports.getRandomEnumValue(self, transpiledEnum, seedOrRNG, excepti
73
123
  local enumValues = ____exports.getEnumValues(nil, transpiledEnum)
74
124
  return getRandomArrayElement(nil, enumValues, seedOrRNG, exceptions)
75
125
  end
126
+ --- Helper function to check every value of a custom enum for -1. This is helpful as a run-time check
127
+ -- because many methods of the Isaac class return -1 if they fail.
128
+ --
129
+ -- For example:
130
+ --
131
+ -- ```ts
132
+ -- enum EntityTypeCustom {
133
+ -- FOO = Isaac.GetEntityTypeByName("Foo"),
134
+ -- }
135
+ --
136
+ -- validateCustomEnum("EntityTypeCustom", EntityTypeCustom);
137
+ -- ```
76
138
  function ____exports.validateCustomEnum(self, transpiledEnumName, transpiledEnum)
77
139
  for ____, ____value in ipairs(____exports.getEnumEntries(nil, transpiledEnum)) do
78
140
  local key = ____value[1]
@@ -3,6 +3,33 @@ local ____cachedClasses = require("cachedClasses")
3
3
  local itemConfig = ____cachedClasses.itemConfig
4
4
  local ____familiarsThatShootPlayerTearsSet = require("sets.familiarsThatShootPlayerTearsSet")
5
5
  local FAMILIARS_THAT_SHOOT_PLAYER_TEARS_SET = ____familiarsThatShootPlayerTearsSet.FAMILIARS_THAT_SHOOT_PLAYER_TEARS_SET
6
+ --- Helper function to add and remove familiars based on a target amount that you specify.
7
+ --
8
+ -- This is a convenience wrapper around the `EntityPlayer.CheckFamiliar` method. Use this helper
9
+ -- function instead so that you do not have to retrieve the `ItemConfigItem` and so that you do not
10
+ -- specify an incorrect RNG object. (The vanilla method is bugged in that it does not increment the
11
+ -- RNG object; see the documentation of the method for more details.)
12
+ --
13
+ -- This function is meant to be called in the EvaluateCache callback (when the cache flag is equal
14
+ -- to `CacheFlag.FAMILIARS`).
15
+ --
16
+ -- Note that this function is only meant to be used in special circumstances where the familiar
17
+ -- count is completely custom and does not correspond to the amount of collectibles. For the general
18
+ -- case, use the `checkFamiliarFromCollectibles` helper function instead.
19
+ --
20
+ -- Note that this will spawn familiars with a completely random `InitSeed`. When calculating random
21
+ -- events for this familiar, you should use a data structure that maps familiar `InitSeed` to RNG
22
+ -- objects that are initialized based on the seed from
23
+ -- `EntityPlayer.GetCollectibleRNG(collectibleType)`.
24
+ --
25
+ -- @param player The player that owns the familiars.
26
+ -- @param collectibleType The collectible type of the collectible associated with this familiar.
27
+ -- @param targetCount The number of familiars that should exist. This function will add or remove
28
+ -- familiars until it matches the target count.
29
+ -- @param familiarVariant The variant of the familiar to spawn or remove.
30
+ -- @param familiarSubType Optional. The sub-type of the familiar to spawn or remove. If not
31
+ -- specified, it will search for existing familiars of all sub-types, and
32
+ -- spawn new familiars with a sub-type of 0.
6
33
  function ____exports.checkFamiliar(self, player, collectibleType, targetCount, familiarVariant, familiarSubType)
7
34
  local itemConfigItem = itemConfig:GetCollectible(collectibleType)
8
35
  player:CheckFamiliar(
@@ -13,6 +40,31 @@ function ____exports.checkFamiliar(self, player, collectibleType, targetCount, f
13
40
  familiarSubType
14
41
  )
15
42
  end
43
+ --- Helper function to add and remove familiars based on the amount of associated collectibles that a
44
+ -- player has.
45
+ --
46
+ -- Use this helper function instead of invoking the `EntityPlayer.CheckFamiliar` method directly so
47
+ -- that the target count is handled automatically.
48
+ --
49
+ -- This function is meant to be called in the EvaluateCache callback (when the cache flag is equal
50
+ -- to `CacheFlag.FAMILIARS`).
51
+ --
52
+ -- Use this function when the amount of familiars should be equal to the amount of associated
53
+ -- collectibles that the player has (plus any extras from having used Box of Friends or Monster
54
+ -- Manual). If you instead need to have a custom amount of familiars, use the `checkFamiliars`
55
+ -- function instead.
56
+ --
57
+ -- Note that this will spawn familiars with a completely random `InitSeed`. When calculating random
58
+ -- events for this familiar, you should use a data structure that maps familiar `InitSeed` to RNG
59
+ -- objects that are initialized based on the seed from
60
+ -- `EntityPlayer.GetCollectibleRNG(collectibleType)`.
61
+ --
62
+ -- @param player The player that owns the familiars and collectibles.
63
+ -- @param collectibleType The collectible type of the collectible associated with this familiar.
64
+ -- @param familiarVariant The variant of the familiar to spawn or remove.
65
+ -- @param familiarSubType Optional. The sub-type of the familiar to spawn or remove. If not
66
+ -- specified, it will search for existing familiars of all sub-types, and
67
+ -- spawn new familiars with a sub-type of 0.
16
68
  function ____exports.checkFamiliarFromCollectibles(self, player, collectibleType, familiarVariant, familiarSubType)
17
69
  local numCollectibles = player:GetCollectibleNum(collectibleType)
18
70
  local effects = player:GetEffects()