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
@@ -12,14 +12,22 @@ local ____enums = require("functions.enums")
12
12
  local getEnumValues = ____enums.getEnumValues
13
13
  local ____flag = require("functions.flag")
14
14
  local hasFlag = ____flag.hasFlag
15
+ --- Alias for the `Level.GetCurrentRoomDesc` method. Use this to make it more clear what type of
16
+ -- `RoomDescriptor` object that you are retrieving.
15
17
  function ____exports.getCurrentRoomDescriptorReadOnly(self)
16
18
  local level = game:GetLevel()
17
19
  return level:GetCurrentRoomDesc()
18
20
  end
21
+ --- Helper function to get the room data for the provided room.
22
+ --
23
+ -- @param roomGridIndex Optional. Default is the current room index.
19
24
  function ____exports.getRoomData(self, roomGridIndex)
20
25
  local roomDescriptor = ____exports.getRoomDescriptor(nil, roomGridIndex)
21
26
  return roomDescriptor.Data
22
27
  end
28
+ --- Helper function to get the descriptor for a room.
29
+ --
30
+ -- @param roomGridIndex Optional. Default is the current room index.
23
31
  function ____exports.getRoomDescriptor(self, roomGridIndex)
24
32
  local level = game:GetLevel()
25
33
  if roomGridIndex == nil then
@@ -27,6 +35,20 @@ function ____exports.getRoomDescriptor(self, roomGridIndex)
27
35
  end
28
36
  return level:GetRoomByIdx(roomGridIndex)
29
37
  end
38
+ --- Helper function to get the grid index of the current room.
39
+ --
40
+ -- - If the current room is inside of the grid, this function will return the `SafeGridIndex` from
41
+ -- the room descriptor. (The safe grid index is defined as the top-left 1x1 section that the room
42
+ -- overlaps with, or the top-right 1x1 section of a `RoomType.SHAPE_LTL` room.)
43
+ -- - If the current room is outside of the grid, it will return the index from the
44
+ -- `Level.GetCurrentRoomIndex` method (since `SafeGridIndex` is bugged for these cases).
45
+ --
46
+ -- Use this function instead of the `Level.GetCurrentRoomIndex` method directly because the latter
47
+ -- will return the specific 1x1 quadrant that the player entered the room at. For most situations,
48
+ -- using the safe grid index is more reliable than this.
49
+ --
50
+ -- Data structures that store data per room should use the room's `ListIndex` instead of
51
+ -- `SafeGridIndex`, since the former is unique across different dimensions.
30
52
  function ____exports.getRoomGridIndex(self)
31
53
  local level = game:GetLevel()
32
54
  local currentRoomIndex = level:GetCurrentRoomIndex()
@@ -36,6 +58,8 @@ function ____exports.getRoomGridIndex(self)
36
58
  local roomDescriptor = ____exports.getCurrentRoomDescriptorReadOnly(nil)
37
59
  return roomDescriptor.SafeGridIndex
38
60
  end
61
+ --- Helper function to get the set of allowed door slots for the room at the supplied grid index.
62
+ -- This corresponds to the doors that are enabled in the STB/XML file for the room.
39
63
  function ____exports.getRoomAllowedDoors(self, roomGridIndex)
40
64
  local allowedDoors = __TS__New(Set)
41
65
  local roomData = ____exports.getRoomData(nil, roomGridIndex)
@@ -51,14 +75,30 @@ function ____exports.getRoomAllowedDoors(self, roomGridIndex)
51
75
  end
52
76
  return allowedDoors
53
77
  end
78
+ --- Helper function to get the list grid index of the provided room, which is equal to the index in
79
+ -- the `RoomList.Get` method. In other words, this is equal to the order that the room was created
80
+ -- by the floor generation algorithm.
81
+ --
82
+ -- Use this as an index for data structures that store data per room, since it is unique across
83
+ -- different dimensions.
84
+ --
85
+ -- @param roomGridIndex Optional. Default is the current room index.
54
86
  function ____exports.getRoomListIndex(self, roomGridIndex)
55
87
  local roomDescriptor = ____exports.getRoomDescriptor(nil, roomGridIndex)
56
88
  return roomDescriptor.ListIndex
57
89
  end
90
+ --- Helper function to get the name of the room as it appears in the STB/XML data.
91
+ --
92
+ -- @param roomGridIndex Optional. Default is the current room index.
93
+ -- @returns The room name. Returns "Unknown" if the type was not found.
58
94
  function ____exports.getRoomName(self, roomGridIndex)
59
95
  local roomData = ____exports.getRoomData(nil, roomGridIndex)
60
96
  return roomData == nil and "Unknown" or roomData.Name
61
97
  end
98
+ --- Helper function to get the name of the room as it appears in the STB/XML data.
99
+ --
100
+ -- @param roomGridIndex Optional. Default is the current room index.
101
+ -- @returns The room name. Returns "Unknown" if the type was not found.
62
102
  function ____exports.getRoomShape(self, roomGridIndex)
63
103
  local roomData = ____exports.getRoomData(nil, roomGridIndex)
64
104
  local ____temp_0
@@ -69,22 +109,50 @@ function ____exports.getRoomShape(self, roomGridIndex)
69
109
  end
70
110
  return ____temp_0
71
111
  end
112
+ --- Helper function to get the stage ID for a room from the XML/STB data. The room stage ID will
113
+ -- correspond to the first number in the filename of the XML/STB file. For example, a Depths room
114
+ -- would have a stage ID of 7.
115
+ --
116
+ -- @param roomGridIndex Optional. Default is the current room index.
117
+ -- @returns The room stage ID. Returns -1 if the stage ID was not found.
72
118
  function ____exports.getRoomStageID(self, roomGridIndex)
73
119
  local roomData = ____exports.getRoomData(nil, roomGridIndex)
74
120
  return roomData == nil and -1 or roomData.StageID
75
121
  end
122
+ --- Helper function to get the sub-type for a room from the XML/STB data. The room sub-type will
123
+ -- correspond to different things depending on what XML/STB file it draws from. For example, in the
124
+ -- "00.special rooms.stb" file, an Angel Room with a sub-type of 0 will correspond to a normal Angel
125
+ -- Room and a sub-type of 1 will correspond to an Angel Room shop for The Stairway.
126
+ --
127
+ -- @param roomGridIndex Optional. Default is the current room index.
128
+ -- @returns The room sub-type. Returns -1 if the sub-type was not found.
76
129
  function ____exports.getRoomSubType(self, roomGridIndex)
77
130
  local roomData = ____exports.getRoomData(nil, roomGridIndex)
78
131
  return roomData == nil and -1 or roomData.Subtype
79
132
  end
133
+ --- Helper function for getting the type of the room with the given grid index.
134
+ --
135
+ -- @param roomGridIndex Optional. Default is the current room index.
136
+ -- @returns The room data type. Returns -1 if the type was not found.
80
137
  function ____exports.getRoomType(self, roomGridIndex)
81
138
  local roomData = ____exports.getRoomData(nil, roomGridIndex)
82
139
  return roomData == nil and -1 or roomData.Type
83
140
  end
141
+ --- Helper function to get the variant for a room from the XML/STB data. You can think of a room
142
+ -- variant as its identifier. For example, to go to Basement room #123, you would use a console
143
+ -- command of `goto d.123` while on the Basement.
144
+ --
145
+ -- @param roomGridIndex Optional. Default is the current room index.
146
+ -- @returns The room variant. Returns -1 if the variant was not found.
84
147
  function ____exports.getRoomVariant(self, roomGridIndex)
85
148
  local roomData = ____exports.getRoomData(nil, roomGridIndex)
86
149
  return roomData == nil and -1 or roomData.Variant
87
150
  end
151
+ --- Note that the room visited count will be inaccurate during the period before the PostNewRoom
152
+ -- callback has fired (i.e. when entities are initializing and performing their first update). This
153
+ -- is because the variable is only incremented immediately before the PostNewRoom callback fires.
154
+ --
155
+ -- @param roomGridIndex Optional. Default is the current room index.
88
156
  function ____exports.getRoomVisitedCount(self, roomGridIndex)
89
157
  local roomDescriptor = ____exports.getRoomDescriptor(nil, roomGridIndex)
90
158
  return roomDescriptor.VisitedCount
@@ -9,6 +9,9 @@ local getRoomShapeBottomRightPosition = ____roomShape.getRoomShapeBottomRightPos
9
9
  local getRoomShapeTopLeftPosition = ____roomShape.getRoomShapeTopLeftPosition
10
10
  local getRoomShapeWidth = ____roomShape.getRoomShapeWidth
11
11
  local isLRoom = ____roomShape.isLRoom
12
+ --- Helper function to convert a grid position `Vector` to a world position `Vector`.
13
+ --
14
+ -- For example, the coordinates of (0, 0) are equal to `Vector(80, 160)`.
12
15
  function ____exports.gridPositionToWorldPosition(self, gridPosition)
13
16
  local x = (gridPosition.X + 2) * 40
14
17
  local y = (gridPosition.Y + 4) * 40
@@ -27,16 +30,26 @@ function isValidGridPositionLRoom(self, gridPosition, roomShape)
27
30
  local verticalTopLeft, verticalBottomRight, horizontalTopLeft, horizontalBottomRight = table.unpack(rectangles)
28
31
  return inRectangle(nil, gridPosition, verticalTopLeft, verticalBottomRight) or inRectangle(nil, gridPosition, horizontalTopLeft, horizontalBottomRight)
29
32
  end
33
+ --- Helper function to convert grid coordinates to a world position `Vector`.
34
+ --
35
+ -- For example, the coordinates of (0, 0) are equal to `Vector(80, 160)`.
30
36
  function ____exports.gridCoordinatesToWorldPosition(self, x, y)
31
37
  local gridPosition = Vector(x, y)
32
38
  return ____exports.gridPositionToWorldPosition(nil, gridPosition)
33
39
  end
40
+ --- Helper function to convert a grid index to a grid position.
41
+ --
42
+ -- For example, in a 1x1 room, grid index 0 is equal to "Vector(-1, -1) and grid index 16 is equal
43
+ -- to "Vector(0, 0)".
34
44
  function ____exports.gridIndexToGridPosition(self, gridIndex, roomShape)
35
45
  local gridWidth = getRoomShapeWidth(nil, roomShape)
36
46
  local x = gridIndex % gridWidth - 1
37
47
  local y = math.floor(gridIndex / gridWidth) - 1
38
48
  return Vector(x, y)
39
49
  end
50
+ --- Test if a grid position is actually in the given `RoomShape`.
51
+ --
52
+ -- In this context, the grid position of the top-left wall is "Vector(-1, -1)".
40
53
  function ____exports.isValidGridPosition(self, gridPosition, roomShape)
41
54
  local ____isLRoom_result_0
42
55
  if isLRoom(nil, roomShape) then
@@ -46,11 +59,19 @@ function ____exports.isValidGridPosition(self, gridPosition, roomShape)
46
59
  end
47
60
  return ____isLRoom_result_0
48
61
  end
62
+ --- Helper function to convert a world position `Vector` to a grid position `Vector`.
63
+ --
64
+ -- In this context, the grid position of the top-left wall is "Vector(-1, -1)".
49
65
  function ____exports.worldPositionToGridPosition(self, worldPos)
50
66
  local x = math.floor(worldPos.X / 40 - 2 + 0.5)
51
67
  local y = math.floor(worldPos.Y / 40 - 4 + 0.5)
52
68
  return Vector(x, y)
53
69
  end
70
+ --- Helper function to convert a world position `Vector` to a grid position `Vector`.
71
+ --
72
+ -- In this context, the grid position of the top-left wall is "Vector(-1, -1)".
73
+ --
74
+ -- This is similar to the `worldPositionToGridPosition` function, but the values are not rounded.
54
75
  function ____exports.worldPositionToGridPositionFast(self, worldPos)
55
76
  local x = worldPos.X / 40 - 2
56
77
  local y = worldPos.Y / 40 - 4
@@ -17,22 +17,44 @@ local ____roomShapeVolumes = require("objects.roomShapeVolumes")
17
17
  local ROOM_SHAPE_VOLUMES = ____roomShapeVolumes.ROOM_SHAPE_VOLUMES
18
18
  local ____LRoomShapesSet = require("sets.LRoomShapesSet")
19
19
  local L_ROOM_SHAPES_SET = ____LRoomShapesSet.L_ROOM_SHAPES_SET
20
+ --- Helper function to get the grid index delta that a door out of the given room shape would lead
21
+ -- to. For example, if you went through the bottom door in a room of `RoomShape.SHAPE_1x2`, you
22
+ -- would end up in a room with a grid index that is +26 units from the `SafeGridIndex` of where you
23
+ -- started.
20
24
  function ____exports.getGridIndexDelta(self, roomShape, doorSlot)
21
25
  local doorSlotToGridIndexMap = ROOM_SHAPE_TO_DOOR_SLOTS_TO_GRID_INDEX_DELTA[roomShape]
22
26
  return doorSlotToGridIndexMap:get(doorSlot)
23
27
  end
28
+ --- Helper function to get the grid position of the bottom-right tile of a given room shape.
29
+ --
30
+ -- "Vector(0, 0)" corresponds to the top left tile of a room, not including the walls. (The top-left
31
+ -- wall would be at "Vector(-1, -1)".)
24
32
  function ____exports.getRoomShapeBottomRightPosition(self, roomShape)
25
33
  return ROOM_SHAPE_TO_BOTTOM_RIGHT_POSITION[roomShape]
26
34
  end
35
+ --- Helper function to get the bounds of a room shape, which are a box representing its contents.
36
+ -- This does not include the tiles that the walls are on. L rooms use the same bounds as a 2x2 room.
27
37
  function ____exports.getRoomShapeBounds(self, roomShape)
28
38
  return ROOM_SHAPE_BOUNDS[roomShape]
29
39
  end
40
+ --- Helper function to get the dimensions of a room shape's layout. This is NOT the size of the
41
+ -- room's actual contents! For that, use the `getRoomShapeBounds` function.
42
+ --
43
+ -- For example, a horizontal narrow room has a layout size of equal to that of a 1x1 room.
30
44
  function ____exports.getRoomShapeLayoutSize(self, roomShape)
31
45
  return ROOM_SHAPE_LAYOUT_SIZES[roomShape]
32
46
  end
47
+ --- Helper function to get the grid position of the top-left tile of a given room shape.
48
+ --
49
+ -- "Vector(0, 0)" corresponds to the top left tile of a room, not including the walls. (The top-left
50
+ -- wall would be at "Vector(-1, -1)".)
33
51
  function ____exports.getRoomShapeTopLeftPosition(self, roomShape)
34
52
  return ROOM_SHAPE_TO_TOP_LEFT_POSITION[roomShape]
35
53
  end
54
+ --- Helper function to get the volume of a room shape, which is the amount of tiles that are inside
55
+ -- the room.
56
+ --
57
+ -- (This cannot be directly calculated from the bounds since L rooms are a special case.)
36
58
  function ____exports.getRoomShapeVolume(self, roomShape)
37
59
  return ROOM_SHAPE_VOLUMES[roomShape]
38
60
  end
@@ -68,6 +68,13 @@ local irange = ____utils.irange
68
68
  function ____exports.getRoomShapeNeighborGridIndexDeltas(self, roomShape)
69
69
  return {__TS__Spread(ROOM_SHAPE_TO_DOOR_SLOTS_TO_GRID_INDEX_DELTA[roomShape]:values())}
70
70
  end
71
+ --- Helper function to get the room descriptor for every room on the level. Uses the `Level.GetRooms`
72
+ -- method to accomplish this. Rooms without data are assumed to be non-existent and are not added to
73
+ -- the list.
74
+ --
75
+ -- @param includeExtraDimensionalRooms Optional. On some floors (e.g. Downpour 2, Mines 2),
76
+ -- extra-dimensional rooms are automatically be generated and can be
77
+ -- seen when you iterate over the `RoomList`. Default is false.
71
78
  function ____exports.getRooms(self, includeExtraDimensionalRooms)
72
79
  if includeExtraDimensionalRooms == nil then
73
80
  includeExtraDimensionalRooms = false
@@ -96,15 +103,21 @@ function ____exports.getRooms(self, includeExtraDimensionalRooms)
96
103
  end
97
104
  return {__TS__Spread(roomsMap:values())}
98
105
  end
106
+ --- We cannot use the standard code in the `inDimension` function for this purpose since it is bugged
107
+ -- with the Death Certificate area.
99
108
  function ____exports.inDeathCertificateArea(self)
100
109
  local roomStageID = getRoomStageID(nil)
101
110
  local roomSubType = getRoomSubType(nil)
102
111
  return roomStageID == StageID.HOME and (roomSubType == HomeRoomSubType.DEATH_CERTIFICATE_ENTRANCE or roomSubType == HomeRoomSubType.DEATH_CERTIFICATE_ITEMS)
103
112
  end
113
+ --- Helper function to check if a room exists at the given room grid index.
104
114
  function ____exports.roomExists(self, roomGridIndex)
105
115
  local roomData = getRoomData(nil, roomGridIndex)
106
116
  return roomData ~= nil
107
117
  end
118
+ --- Helper function for quickly switching to a new room without playing a particular animation. Use
119
+ -- this helper function over invoking the `Game.ChangeRoom` method directly to ensure that you do
120
+ -- not forget to set the `LeaveDoor` property and to prevent crashing on invalid room grid indexes.
108
121
  function ____exports.changeRoom(self, roomGridIndex)
109
122
  local level = game:GetLevel()
110
123
  local roomData = getRoomData(nil, roomGridIndex)
@@ -114,6 +127,7 @@ function ____exports.changeRoom(self, roomGridIndex)
114
127
  level.LeaveDoor = DoorSlot.NO_DOOR_SLOT
115
128
  game:ChangeRoom(roomGridIndex)
116
129
  end
130
+ --- Helper function to get an array with every valid `Dimension` (not including `Dimension.CURRENT`).
117
131
  function ____exports.getAllDimensions(self)
118
132
  return erange(nil, NUM_DIMENSIONS)
119
133
  end
@@ -124,6 +138,11 @@ function ____exports.getAllRoomGridIndexes(self)
124
138
  function(____, roomDescriptor) return roomDescriptor.SafeGridIndex end
125
139
  )
126
140
  end
141
+ --- Helper function to get the current dimension. Most of the time, this will be `Dimension.MAIN`,
142
+ -- but it can change if e.g. the player is in the mirror world of Downpour/Dross.
143
+ --
144
+ -- Note that this function correctly handles detecting the Death Certificate dimension, which is
145
+ -- tricky to properly detect.
127
146
  function ____exports.getCurrentDimension(self)
128
147
  local level = game:GetLevel()
129
148
  if ____exports.inDeathCertificateArea(nil) then
@@ -141,10 +160,19 @@ function ____exports.getCurrentDimension(self)
141
160
  end
142
161
  return error("Failed to get the current dimension using the starting room index of: " .. tostring(startingRoomGridIndex))
143
162
  end
163
+ --- Helper function to get the number of rooms that are currently on the floor layout. This does not
164
+ -- include off-grid rooms, like the Devil Room.
144
165
  function ____exports.getNumRooms(self)
145
166
  local rooms = ____exports.getRooms(nil)
146
167
  return #rooms
147
168
  end
169
+ --- Helper function to get an array of all of the safe grid indexes for rooms that match the
170
+ -- specified room type.
171
+ --
172
+ -- This function only searches through rooms in the current dimension.
173
+ --
174
+ -- This function is variadic, meaning that you can specify N arguments to get the combined grid
175
+ -- indexes for N room types.
148
176
  function ____exports.getRoomGridIndexesForType(self, ...)
149
177
  local roomTypesSet = __TS__New(Set, {...})
150
178
  local rooms = ____exports.getRooms(nil)
@@ -157,6 +185,8 @@ function ____exports.getRoomGridIndexesForType(self, ...)
157
185
  function(____, roomDescriptor) return roomDescriptor.SafeGridIndex end
158
186
  )
159
187
  end
188
+ --- Helper function to get the item pool type for the current room. For example, this returns
189
+ -- `ItemPoolType.ItemPoolType.POOL_ANGEL` if you are in an Angel Room.
160
190
  function ____exports.getRoomItemPoolType(self)
161
191
  local itemPool = game:GetItemPool()
162
192
  local room = game:GetRoom()
@@ -164,6 +194,9 @@ function ____exports.getRoomItemPoolType(self)
164
194
  local roomSeed = room:GetSpawnSeed()
165
195
  return itemPool:GetPoolForRoom(roomType, roomSeed)
166
196
  end
197
+ --- Helper function to get the grid indexes of all the rooms connected to the given room index.
198
+ --
199
+ -- @param roomGridIndex Optional. Default is the current room index.
167
200
  function ____exports.getRoomNeighbors(self, roomGridIndex)
168
201
  local roomDescriptor = getRoomDescriptor(nil, roomGridIndex)
169
202
  if roomDescriptor.SafeGridIndex < 0 or roomDescriptor.SafeGridIndex > MAX_LEVEL_GRID_INDEX then
@@ -184,10 +217,18 @@ function ____exports.getRoomNeighbors(self, roomGridIndex)
184
217
  function(____, gridIndex) return ____exports.roomExists(nil, gridIndex) end
185
218
  )
186
219
  end
220
+ --- Helper function to get the proper name of a room type.
221
+ --
222
+ -- For example, `RoomType.TREASURE` will return "Treasure Room".
187
223
  function ____exports.getRoomTypeName(self, roomType)
188
224
  local roomTypeName = ROOM_TYPE_NAMES[roomType]
189
225
  return roomTypeName == nil and DEFAULT_ROOM_TYPE_NAME or roomTypeName
190
226
  end
227
+ --- Helper function to get the room descriptor for every room on the level in a specific dimension.
228
+ -- Uses the `Level.GetRooms` method to accomplish this. Rooms without data are assumed to be
229
+ -- non-existent and are not added to the list.
230
+ --
231
+ -- @returns A map of room ListIndex to RoomDescriptor.
191
232
  function ____exports.getRoomsOfDimension(self, dimension)
192
233
  local level = game:GetLevel()
193
234
  local roomsMap = __TS__New(Map)
@@ -199,6 +240,8 @@ function ____exports.getRoomsOfDimension(self, dimension)
199
240
  end
200
241
  return {__TS__Spread(roomsMap:values())}
201
242
  end
243
+ --- Helper function to determine if the current room shape is equal to `RoomShape.1x2` or
244
+ -- `RoomShape.2x1`.
202
245
  function ____exports.in2x1Room(self)
203
246
  local room = game:GetRoom()
204
247
  local roomShape = room:GetRoomShape()
@@ -216,6 +259,8 @@ function ____exports.inBeastRoom(self)
216
259
  local roomSubType = getRoomSubType(nil)
217
260
  return roomType == RoomType.DUNGEON and roomSubType == DungeonSubType.BEAST_ROOM
218
261
  end
262
+ --- Helper function to check if the current room is a boss room for a particular boss. This will only
263
+ -- work for bosses that have dedicated boss rooms in the "00.special rooms.stb" file.
219
264
  function ____exports.inBossRoomOf(self, bossID)
220
265
  local room = game:GetRoom()
221
266
  local roomType = room:GetType()
@@ -223,12 +268,18 @@ function ____exports.inBossRoomOf(self, bossID)
223
268
  local roomSubType = getRoomSubType(nil)
224
269
  return roomType == RoomType.BOSS and roomStageID == StageID.SPECIAL_ROOMS and roomSubType == bossID
225
270
  end
271
+ --- Helper function for determining whether the current room is a crawlspace. Use this function over
272
+ -- comparing to `RoomType.DUNGEON` or `GridRoom.DUNGEON_IDX` since there is a special case of the
273
+ -- player being in a boss fight that take place in a dungeon.
226
274
  function ____exports.inCrawlspace(self)
227
275
  local room = game:GetRoom()
228
276
  local roomType = room:GetType()
229
277
  local roomSubType = getRoomSubType(nil)
230
278
  return roomType == RoomType.DUNGEON and roomSubType == DungeonSubType.NORMAL
231
279
  end
280
+ --- Helper function to detect if the current room is a Treasure Room created when entering with a
281
+ -- Devil's Crown trinket. Under the hood, this checks for the `RoomDescriptorFlag.DEVIL_TREASURE`
282
+ -- flag.
232
283
  function ____exports.inDevilsCrownTreasureRoom(self)
233
284
  local roomDescriptor = getCurrentRoomDescriptorReadOnly(nil)
234
285
  return hasFlag(nil, roomDescriptor.Flags, RoomDescriptorFlag.DEVIL_TREASURE)
@@ -246,6 +297,7 @@ function ____exports.inGenesisRoom(self)
246
297
  local roomGridIndex = getRoomGridIndex(nil)
247
298
  return roomGridIndex == GridRoom.GENESIS
248
299
  end
300
+ --- Helper function to determine if the current room shape is one of the four L room shapes.
249
301
  function ____exports.inLRoom(self)
250
302
  local room = game:GetRoom()
251
303
  local roomShape = room:GetRoomShape()
@@ -255,11 +307,15 @@ function ____exports.inMegaSatanRoom(self)
255
307
  local roomGridIndex = getRoomGridIndex(nil)
256
308
  return roomGridIndex == GridRoom.MEGA_SATAN
257
309
  end
310
+ --- Helper function to determine if the current room is part of the Repentance "escape sequence" in
311
+ -- the Mines/Ashpit.
258
312
  function ____exports.inMineShaft(self)
259
313
  local roomStageID = getRoomStageID(nil)
260
314
  local roomSubType = getRoomSubType(nil)
261
315
  return (roomStageID == StageID.MINES or roomStageID == StageID.ASHPIT) and MINE_SHAFT_ROOM_SUB_TYPE_SET:has(roomSubType)
262
316
  end
317
+ --- Helper function to check if the current room is a miniboss room for a particular miniboss. This
318
+ -- will only work for mini-bosses that have dedicated boss rooms in the "00.special rooms.stb" file.
263
319
  function ____exports.inMinibossRoomOf(self, minibossID)
264
320
  local room = game:GetRoom()
265
321
  local roomType = room:GetType()
@@ -267,16 +323,31 @@ function ____exports.inMinibossRoomOf(self, minibossID)
267
323
  local roomSubType = getRoomSubType(nil)
268
324
  return roomType == RoomType.MINI_BOSS and roomStageID == StageID.SPECIAL_ROOMS and roomSubType == minibossID
269
325
  end
326
+ --- Helper function for checking if the room is a secret shop (from the Member Card collectible).
327
+ --
328
+ -- Secret shops are simply copies of normal shops, but with the backdrop of a secret room. In other
329
+ -- words, they will have the same room type, room variant, and room sub-type of a normal shop. Thus,
330
+ -- the only way to detect them is by using the grid index.
270
331
  function ____exports.inSecretShop(self)
271
332
  local roomGridIndex = getRoomGridIndex(nil)
272
333
  return roomGridIndex == GridRoom.SECRET_SHOP
273
334
  end
335
+ --- Helper function to determine whether or not the current room is the starting room of a floor. It
336
+ -- only returns true for the starting room of the primary dimension (meaning that being in the
337
+ -- starting room of the mirror world does not count).
274
338
  function ____exports.inStartingRoom(self)
275
339
  local level = game:GetLevel()
276
340
  local startingRoomGridIndex = level:GetStartingRoomIndex()
277
341
  local roomGridIndex = getRoomGridIndex(nil)
278
342
  return roomGridIndex == startingRoomGridIndex and ____exports.inDimension(nil, Dimension.MAIN)
279
343
  end
344
+ --- Helper function to loop through every room on the floor and see if it has been cleared.
345
+ --
346
+ -- This function will only check rooms in the current dimension.
347
+ --
348
+ -- @param onlyCheckRoomTypes Optional. A whitelist of room types. If specified, room types not in
349
+ -- the array will be ignored. If not specified, then all rooms will be
350
+ -- checked. Undefined by default.
280
351
  function ____exports.isAllRoomsClear(self, onlyCheckRoomTypes)
281
352
  local ____temp_0
282
353
  if onlyCheckRoomTypes == nil then
@@ -315,21 +386,36 @@ function ____exports.isDoorSlotValidAtGridIndexForRedRoom(self, doorSlot, roomGr
315
386
  local redRoomGridIndex = roomGridIndex + delta
316
387
  return not ____exports.roomExists(nil, redRoomGridIndex) and redRoomGridIndex >= 0 and redRoomGridIndex <= MAX_LEVEL_GRID_INDEX
317
388
  end
389
+ --- Helper function to detect if the provided room was created by the Red Key item. Under the hood,
390
+ -- this checks for the `RoomDescriptorFlag.FLAG_RED_ROOM` flag.
391
+ --
392
+ -- @param roomGridIndex Optional. Default is the current room index.
318
393
  function ____exports.isRedKeyRoom(self, roomGridIndex)
319
394
  local roomDescriptor = getRoomDescriptor(nil, roomGridIndex)
320
395
  return hasFlag(nil, roomDescriptor.Flags, RoomDescriptorFlag.RED_ROOM)
321
396
  end
397
+ --- Helper function to determine if the provided room is part of the floor layout. For example, Devil
398
+ -- Rooms and the Mega Satan room are not considered to be inside the map.
399
+ --
400
+ -- @param roomGridIndex Optional. Default is the current room index.
322
401
  function ____exports.isRoomInsideMap(self, roomGridIndex)
323
402
  if roomGridIndex == nil then
324
403
  roomGridIndex = getRoomGridIndex(nil)
325
404
  end
326
405
  return roomGridIndex >= 0
327
406
  end
407
+ --- Helper function to get the coordinates of a given grid index. The floor is represented by a 13x13
408
+ -- grid. For example, since the starting room is in the center, the starting room grid index of 84
409
+ -- be equal to coordinates of (?, ?).
328
410
  function ____exports.roomGridIndexToXY(self, roomGridIndex)
329
411
  local x = roomGridIndex % LEVEL_GRID_ROW_WIDTH
330
412
  local y = math.floor(roomGridIndex / LEVEL_GRID_ROW_WIDTH)
331
413
  return {x, y}
332
414
  end
415
+ --- If the `Room.Update` method is called in a PostNewRoom callback, then some entities will slide
416
+ -- around (such as the player). Since those entity velocities are already at zero, setting them to
417
+ -- zero will have no effect. Thus, a generic solution is to record all of the entity
418
+ -- positions/velocities before updating the room, and then restore those positions/velocities.
333
419
  function ____exports.roomUpdateSafe(self)
334
420
  local room = game:GetRoom()
335
421
  local entities = getEntities(nil)
@@ -339,6 +425,9 @@ function ____exports.roomUpdateSafe(self)
339
425
  setEntityPositions(nil, entityPositions, entities)
340
426
  setEntityVelocities(nil, entityVelocities, entities)
341
427
  end
428
+ --- Helper function to convert an uncleared room to a cleared room in the PostNewRoom callback. This
429
+ -- is useful because if enemies are removed in this callback, a room drop will be awarded and the
430
+ -- doors will start closed and then open.
342
431
  function ____exports.setRoomCleared(self)
343
432
  local room = game:GetRoom()
344
433
  local roomClear = room:IsClear()
@@ -359,11 +448,22 @@ function ____exports.setRoomCleared(self)
359
448
  sfxManager:Stop(SoundEffect.DOOR_HEAVY_OPEN)
360
449
  game:ShakeScreen(0)
361
450
  end
451
+ --- Helper function to emulate what happens when you bomb an Angel Statue or push a Reward Plate that
452
+ -- spawns an NPC.
362
453
  function ____exports.setRoomUncleared(self)
363
454
  local room = game:GetRoom()
364
455
  room:SetClear(false)
365
456
  closeAllDoors(nil)
366
457
  end
458
+ --- Helper function to change the current room. It can be used for both teleportation and "normal"
459
+ -- room transitions, depending on what is passed for the `direction` and `roomTransitionAnim`
460
+ -- arguments. Use this function instead of invoking the `Game.StartRoomTransition` method directly
461
+ -- so that you do not forget to set `Level.LeaveDoor` property and to prevent crashing on invalid
462
+ -- room grid indexes.
463
+ --
464
+ -- @param roomGridIndex The room grid index of the destination room.
465
+ -- @param direction Optional. Default is `Direction.NO_DIRECTION`.
466
+ -- @param roomTransitionAnim Optional. Default is `RoomTransitionAnim.TELEPORT`.
367
467
  function ____exports.teleport(self, roomGridIndex, direction, roomTransitionAnim)
368
468
  if direction == nil then
369
469
  direction = Direction.NO_DIRECTION
package/functions/run.lua CHANGED
@@ -7,12 +7,17 @@ local ____constantsFirstLast = require("constantsFirstLast")
7
7
  local FIRST_CHARACTER = ____constantsFirstLast.FIRST_CHARACTER
8
8
  local ____log = require("functions.log")
9
9
  local log = ____log.log
10
+ --- Whether or not the player is playing on a set seed (i.e. that they entered in a specific seed by
11
+ -- pressing tab on the character selection screen). When the player resets the game on a set seed,
12
+ -- the game will not switch to a different seed.
10
13
  function ____exports.onSetSeed(self)
11
14
  local seeds = game:GetSeeds()
12
15
  local customRun = seeds:IsCustomRun()
13
16
  local challenge = Isaac.GetChallenge()
14
17
  return challenge == Challenge.NULL and customRun
15
18
  end
19
+ --- Helper function to restart the game using the console command of "restart". You can optionally
20
+ -- specify a `PlayerType` to restart the game as that character.
16
21
  function ____exports.restart(self, character)
17
22
  if character == nil then
18
23
  log("Restarting.")
@@ -3,10 +3,14 @@ local ____cachedClasses = require("cachedClasses")
3
3
  local game = ____cachedClasses.game
4
4
  local ____rng = require("functions.rng")
5
5
  local newRNG = ____rng.newRNG
6
+ --- Alias for the `Seeds.GetStartSeedString` method.
6
7
  function ____exports.getStartSeedString(self)
7
8
  local seeds = game:GetSeeds()
8
9
  return seeds:GetStartSeedString()
9
10
  end
11
+ --- Helper function to get the next seed value.
12
+ --
13
+ -- This function is useful when you are working with seed values directly over RNG objects.
10
14
  function ____exports.nextSeed(self, seed)
11
15
  local rng = newRNG(nil, seed)
12
16
  rng:Next()
@@ -13,7 +13,7 @@ local ISAAC_API_CLASS_TYPE_TO_COPY_FUNCTION = ____isaacAPIClassTypeToCopyFunctio
13
13
  local ____serializedIsaacAPIClassTypeToIdentityFunction = require("objects.serializedIsaacAPIClassTypeToIdentityFunction")
14
14
  local SERIALIZED_ISAAC_API_CLASS_TYPE_TO_IDENTITY_FUNCTION = ____serializedIsaacAPIClassTypeToIdentityFunction.SERIALIZED_ISAAC_API_CLASS_TYPE_TO_IDENTITY_FUNCTION
15
15
  local ____isaacAPIClass = require("functions.isaacAPIClass")
16
- local getIsaacAPIClassType = ____isaacAPIClass.getIsaacAPIClassType
16
+ local getIsaacAPIClassName = ____isaacAPIClass.getIsaacAPIClassName
17
17
  function getSerializedTableType(self, serializedIsaacAPIClass)
18
18
  for ____, ____value in ipairs(__TS__ObjectEntries(ISAAC_API_CLASS_TYPE_TO_BRAND)) do
19
19
  local copyableIsaacAPIClassType = ____value[1]
@@ -29,7 +29,7 @@ function ____exports.copyIsaacAPIClass(self, isaacAPIClass, serializationType)
29
29
  if objectType ~= "userdata" then
30
30
  error("Failed to copy an Isaac API class since the provided object was of type: " .. objectType)
31
31
  end
32
- local isaacAPIClassType = getIsaacAPIClassType(nil, isaacAPIClass)
32
+ local isaacAPIClassType = getIsaacAPIClassName(nil, isaacAPIClass)
33
33
  if isaacAPIClassType == nil then
34
34
  error("Failed to copy an Isaac API class since it does not have a class type.")
35
35
  end
@@ -40,6 +40,10 @@ function ____exports.copyIsaacAPIClass(self, isaacAPIClass, serializationType)
40
40
  end
41
41
  return copyFunction(nil, isaacAPIClass, serializationType)
42
42
  end
43
+ --- Deserialization is a special case, so we make a dedicated function for this.
44
+ --
45
+ -- There is no need for a corresponding "serializeIsaacAPIClass" function because the
46
+ -- "copyIsaacAPIClass" function can handles all serialization types.
43
47
  function ____exports.deserializeIsaacAPIClass(self, serializedIsaacAPIClass)
44
48
  local objectType = type(serializedIsaacAPIClass)
45
49
  if objectType ~= "table" then
@@ -1,4 +1,5 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
+ /// <reference types="isaac-typescript-definitions" />
2
3
  /**
3
4
  * Helper function to add all of the values in one set to another set. The first set passed will be
4
5
  * modified in place.
package/functions/set.lua CHANGED
@@ -9,12 +9,20 @@ local ____array = require("functions.array")
9
9
  local getRandomArrayElement = ____array.getRandomArrayElement
10
10
  local ____rng = require("functions.rng")
11
11
  local getRandomSeed = ____rng.getRandomSeed
12
+ --- Helper function to get a sorted array based on the contents of a set.
13
+ --
14
+ -- Normally, set values are returned in a random order, so use this function when the ordering of
15
+ -- the contents is important.
12
16
  function ____exports.getSortedSetValues(self, set)
13
17
  local values = set:values()
14
18
  local array = {__TS__Spread(values)}
15
19
  __TS__ArraySort(array)
16
20
  return array
17
21
  end
22
+ --- Helper function to add all of the values in one set to another set. The first set passed will be
23
+ -- modified in place.
24
+ --
25
+ -- This function is variadic, meaning that you can specify N sets to add to the first set.
18
26
  function ____exports.addSetsToSet(self, mainSet, ...)
19
27
  local setsToAdd = {...}
20
28
  for ____, set in ipairs(setsToAdd) do
@@ -23,6 +31,9 @@ function ____exports.addSetsToSet(self, mainSet, ...)
23
31
  end
24
32
  end
25
33
  end
34
+ --- Helper function to create a new set that is the composition of two or more sets.
35
+ --
36
+ -- This function is variadic, meaning that you can specify N sets.
26
37
  function ____exports.combineSets(self, ...)
27
38
  local sets = {...}
28
39
  local newSet = __TS__New(Set)
@@ -33,6 +44,7 @@ function ____exports.combineSets(self, ...)
33
44
  end
34
45
  return newSet
35
46
  end
47
+ --- Helper function to copy a set. (You can also use a Set constructor to accomplish this task.)
36
48
  function ____exports.copySet(self, oldSet)
37
49
  local newSet = __TS__New(Set)
38
50
  for ____, value in __TS__Iterator(oldSet:values()) do
@@ -40,6 +52,10 @@ function ____exports.copySet(self, oldSet)
40
52
  end
41
53
  return newSet
42
54
  end
55
+ --- Helper function to delete all of the values in one set from another set. The first set passed
56
+ -- will be modified in place.
57
+ --
58
+ -- This function is variadic, meaning that you can specify N sets to remove from the first set.
43
59
  function ____exports.deleteSetsFromSet(self, mainSet, ...)
44
60
  local setsToRemove = {...}
45
61
  for ____, set in ipairs(setsToRemove) do
@@ -48,6 +64,12 @@ function ____exports.deleteSetsFromSet(self, mainSet, ...)
48
64
  end
49
65
  end
50
66
  end
67
+ --- Helper function to get a random element from the provided set.
68
+ --
69
+ -- @param set The set to get an element from.
70
+ -- @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
71
+ -- `RNG.Next` method will be called. Default is `getRandomSeed()`.
72
+ -- @param exceptions Optional. An array of elements to skip over if selected.
51
73
  function ____exports.getRandomSetElement(self, set, seedOrRNG, exceptions)
52
74
  if seedOrRNG == nil then
53
75
  seedOrRNG = getRandomSeed(nil)