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
@@ -1,79 +1,110 @@
1
1
  /**
2
- * A function that creates the value for your default map. For example, if it was a default map
3
- * containing maps, the factory function would be: `() => new Map()`
2
+ * A function that creates the default value for your `DefaultMap`. For example, if it was a
3
+ * `DefaultMap` containing maps, the factory function would be: `() => new Map()`
4
4
  */
5
5
  export declare type FactoryFunction<V, Args extends unknown[]> = (...extraArgs: Args) => V;
6
- declare type FirstArg<K, V, Args extends unknown[]> = Iterable<[K, V]> | V | FactoryFunction<V, Args>;
7
- declare type SecondArg<V, Args extends unknown[]> = V | FactoryFunction<V, Args>;
8
6
  /**
9
- * An extended `Map` with some new methods:
7
+ * `DefaultMap` is a data structure that makes working with default values easier.
10
8
  *
11
- * - `getAndSetDefault` - If the key exists, this will return the same thing as the `get` method.
12
- * Otherwise, it will set a default value to the key, and then return the default value.
13
- * - `getDefaultValue` - Returns the default value to be used for a new key. (If a factory function
14
- * was provided during instantiation, this will execute the factory function.)
15
- * - `getConstructorArg` - Helper method for cloning the map. Returns either the default value or
16
- * the reference to the factory function.
9
+ * It is a common pattern to look up a value in a `Map`, and then, if the value does not exist, set
10
+ * a default value for the key, and then return the default value. `DefaultMap` abstracts this
11
+ * operation away by providing the `getAndSetDefault` method.
17
12
  *
18
- * When instantiating a new DefaultMap, you must specify either a default value or a function that
19
- * returns a default value.
13
+ * Using a `DefaultMap` is nice because it makes code more declarative, since you specify what the
14
+ * default value is alongside the types of the keys/values.
20
15
  *
21
- * For example:
16
+ * When instantiating a new `DefaultMap`, you must specify default value as the first argument. (The
17
+ * default value is the initial value that will be assigned to every new entry in the
18
+ * `getAndSetDefault` method.) For example:
22
19
  *
23
20
  * ```ts
24
21
  * // Initializes a new empty DefaultMap with a default value of "foo".
25
- * const defaultMapWithPrimitive = new DefaultMap<string, string>("foo");
22
+ * const defaultMapWithString = new DefaultMap<string, string>("foo");
26
23
  *
27
- * // Initializes a new empty DefaultMap with a default value of a new Map.
28
- * const defaultMapWithFactory = new DefaultMap<string, Map<string, string>>(() => {
29
- * return new Map();
30
- * })
24
+ * const value = defaultMapWithString.getAndSetDefault("bar");
25
+ * // value is now "foo" and an entry for "bar" is now set.
26
+ * ```
31
27
  *
32
- * // Initializes a DefaultMap with some initial values and a default value of "bar".
33
- * const defaultMapWithInitialValues = new DefaultMap<string, string>([
34
- * ["a1", "a2"],
35
- * ["b1", "b2"],
36
- * ], "bar");
28
+ * Sometimes, instead of having a static initial value for every entry in the map, you will want a
29
+ * dynamic initial value that is contingent upon the key or some other variable. In these cases, you
30
+ * can instead specify that the `DefaultMap` should run a function that will return the initial
31
+ * value. (This is referred to as a "factory function".) For example:
32
+ *
33
+ * ```ts
34
+ * // Initializes a new empty DefaultMap with a default value based on "someGlobalVariable".
35
+ * const factoryFunction = () => someGlobalVariable ? 0 : 1;
36
+ * const defaultMapWithFactoryFunction = new DefaultMap<string, string>(factoryFunction);
37
37
  * ```
38
38
  *
39
- * If specified, the first argument of a factory function must always be equal to the key:
39
+ * Note that in TypeScript and Lua, booleans, numbers, and strings are "passed by value". This means
40
+ * that when the `DefaultMap` creates a new entry, if the default value is one of these 3 types, the
41
+ * values will be copied. On the other hand, arrays and maps and other complex data structures are
42
+ * "passed by reference". This means that when the `DefaultMap` creates a new entry, if the default
43
+ * value is an array, then it would not be copied. Instead, the same shared array would be assigned
44
+ * to every entry. Thus, to solve this problem, any variable that is passed by reference must be
45
+ * created using a factory function to ensure that each copy is unique. For example:
40
46
  *
41
47
  * ```ts
42
- * const defaultMapWithConditionalDefaultValue = new DefaultMap<number, number>((key: number) => {
43
- * return isOdd(key) ? 0 : 1;
44
- * });
48
+ * // Initializes a new empty DefaultMap with a default value of a new empty array.
49
+ * const factoryFunction = () => [] as ;
50
+ * const defaultMapWithArray = new DefaultMap<string, string[]>(factoryFunction);
45
51
  * ```
46
52
  *
47
- * You can also specify a factory function that takes a generic amount of arguments beyond the
48
- * first:
53
+ * In the previous two examples, the factory functions did not have any arguments. But you can also
54
+ * specify a factory function that takes one or more arguments:
49
55
  *
50
56
  * ```ts
51
57
  * const factoryFunction = (arg: boolean) => arg ? 0 : 1;
52
- * const defaultMapWithExtraArgs = new DefaultMap<string, string, [arg: boolean]>(factoryFunction);
58
+ * const defaultMapWithArg = new DefaultMap<string, string, [arg: boolean]>(factoryFunction);
53
59
  * ```
60
+ *
61
+ * Similar to a normal `Map`, you can also include an initializer list in the constructor as the
62
+ * second argument:
63
+ *
64
+ * ```ts
65
+ * // Initializes a DefaultMap with a default value of "foo" and some initial values.
66
+ * const defaultMapWithInitialValues = new DefaultMap<string, string>("foo", [
67
+ * ["a1", "a2"],
68
+ * ["b1", "b2"],
69
+ * ], );
70
+ * ```
71
+ *
72
+ * Finally, note that `DefaultMap` has the following additional utility methods:
73
+ *
74
+ * - `getAndSetDefault` - The method that is called inside the overridden `get` method. In most
75
+ * cases, you can use the overridden `get` method instead of calling this function directly.
76
+ * However, if a factory function was provided during instantiation, and the factory function has
77
+ * one or more arguments, then you must call this method instead (and provide the corresponding
78
+ * arguments).
79
+ * - `getWithoutDefault` - Calls the original `Map.get` function (without setting the default
80
+ * value).
81
+ * - `getDefaultValue` - Returns the default value to be used for a new key. (If a factory function
82
+ * was provided during instantiation, this will execute the factory function.)
83
+ * - `getConstructorArg` - Helper method for cloning the map. Returns either the default value or
84
+ * the reference to the factory function.
54
85
  */
55
- export declare class DefaultMap<K, V, Args extends unknown[] = []> extends Map<K, V> {
86
+ export declare class DefaultMap<Key, Value, Args extends unknown[] = []> extends Map<Key, Value> {
56
87
  private defaultValue;
57
88
  private defaultValueFactory;
58
89
  /**
59
90
  * See the main `DefaultMap` documentation:
60
91
  * https://isaacscript.github.io/isaacscript-common/classes/classes_DefaultMap.DefaultMap
61
92
  */
62
- constructor(iterableOrDefaultValueOrDefaultValueFactory: FirstArg<K, V, Args>, defaultValueOrDefaultValueFactory?: SecondArg<V, Args>);
93
+ constructor(defaultValueOrFactoryFunction: Value | FactoryFunction<Value, Args>, initializerArray?: Iterable<[Key, Value]>);
63
94
  /**
64
- * If the key exists, this will return the same thing as the `get` method. Otherwise, it will set
65
- * a default value to the key, and then return the default value.
95
+ * If the key exists, this will return the same thing as the normal `Map.get` method. Otherwise,
96
+ * it will set a default value for the provided key, and then return the default value.
66
97
  */
67
- getAndSetDefault(key: K, ...extraArgs: Args): V;
98
+ getAndSetDefault(key: Key, ...extraArgs: Args): Value;
99
+ getWithoutDefault(key: Key): Value | undefined;
68
100
  /**
69
101
  * Returns the default value to be used for a new key. (If a factory function was provided during
70
102
  * instantiation, this will execute the factory function.)
71
103
  */
72
- getDefaultValue(...extraArgs: Args): V;
104
+ getDefaultValue(...extraArgs: Args): Value;
73
105
  /**
74
106
  * Helper method for cloning the map. Returns either the default value or a reference to the
75
107
  * factory function.
76
108
  */
77
- getConstructorArg(): V | FactoryFunction<V, Args>;
109
+ getConstructorArg(): Value | FactoryFunction<Value, Args>;
78
110
  }
79
- export {};
@@ -4,58 +4,106 @@ local Map = ____lualib.Map
4
4
  local __TS__ClassExtends = ____lualib.__TS__ClassExtends
5
5
  local __TS__TypeOf = ____lualib.__TS__TypeOf
6
6
  local ____exports = {}
7
- local parseArguments, parseArgumentsOne, parseArgumentsTwo, parseDefaultValueOrDefaultValueFactory
8
- function parseArguments(self, firstArg, secondArg)
9
- return secondArg == nil and parseArgumentsOne(nil, firstArg) or parseArgumentsTwo(nil, firstArg, secondArg)
10
- end
11
- function parseArgumentsOne(self, firstArg)
12
- local arg = firstArg
13
- local ____parseDefaultValueOrDefaultValueFactory_result_1 = parseDefaultValueOrDefaultValueFactory(nil, arg)
14
- local defaultValue = ____parseDefaultValueOrDefaultValueFactory_result_1.defaultValue
15
- local defaultValueFactory = ____parseDefaultValueOrDefaultValueFactory_result_1.defaultValueFactory
16
- return {iterable = nil, defaultValue = defaultValue, defaultValueFactory = defaultValueFactory}
17
- end
18
- function parseArgumentsTwo(self, firstArg, secondArg)
19
- local firstArgType = type(firstArg)
20
- if firstArgType ~= "table" then
21
- error("A DefaultMap constructor with two arguments must have the first argument be the initializer list.")
22
- end
23
- local ____parseDefaultValueOrDefaultValueFactory_result_2 = parseDefaultValueOrDefaultValueFactory(nil, secondArg)
24
- local defaultValue = ____parseDefaultValueOrDefaultValueFactory_result_2.defaultValue
25
- local defaultValueFactory = ____parseDefaultValueOrDefaultValueFactory_result_2.defaultValueFactory
26
- return {iterable = firstArg, defaultValue = defaultValue, defaultValueFactory = defaultValueFactory}
27
- end
28
- function parseDefaultValueOrDefaultValueFactory(self, arg)
29
- if type(arg) == "function" then
30
- return {defaultValue = nil, defaultValueFactory = arg}
31
- end
32
- if type(arg) == "boolean" or type(arg) == "number" or type(arg) == "string" then
33
- return {defaultValue = arg, defaultValueFactory = nil}
34
- end
35
- return error("A DefaultMap was instantiated with an unknown type of: " .. __TS__TypeOf(arg))
36
- end
7
+ --- `DefaultMap` is a data structure that makes working with default values easier.
8
+ --
9
+ -- It is a common pattern to look up a value in a `Map`, and then, if the value does not exist, set
10
+ -- a default value for the key, and then return the default value. `DefaultMap` abstracts this
11
+ -- operation away by providing the `getAndSetDefault` method.
12
+ --
13
+ -- Using a `DefaultMap` is nice because it makes code more declarative, since you specify what the
14
+ -- default value is alongside the types of the keys/values.
15
+ --
16
+ -- When instantiating a new `DefaultMap`, you must specify default value as the first argument. (The
17
+ -- default value is the initial value that will be assigned to every new entry in the
18
+ -- `getAndSetDefault` method.) For example:
19
+ --
20
+ -- ```ts
21
+ -- // Initializes a new empty DefaultMap with a default value of "foo".
22
+ -- const defaultMapWithString = new DefaultMap<string, string>("foo");
23
+ --
24
+ -- const value = defaultMapWithString.getAndSetDefault("bar");
25
+ -- // value is now "foo" and an entry for "bar" is now set.
26
+ -- ```
27
+ --
28
+ -- Sometimes, instead of having a static initial value for every entry in the map, you will want a
29
+ -- dynamic initial value that is contingent upon the key or some other variable. In these cases, you
30
+ -- can instead specify that the `DefaultMap` should run a function that will return the initial
31
+ -- value. (This is referred to as a "factory function".) For example:
32
+ --
33
+ -- ```ts
34
+ -- // Initializes a new empty DefaultMap with a default value based on "someGlobalVariable".
35
+ -- const factoryFunction = () => someGlobalVariable ? 0 : 1;
36
+ -- const defaultMapWithFactoryFunction = new DefaultMap<string, string>(factoryFunction);
37
+ -- ```
38
+ --
39
+ -- Note that in TypeScript and Lua, booleans, numbers, and strings are "passed by value". This means
40
+ -- that when the `DefaultMap` creates a new entry, if the default value is one of these 3 types, the
41
+ -- values will be copied. On the other hand, arrays and maps and other complex data structures are
42
+ -- "passed by reference". This means that when the `DefaultMap` creates a new entry, if the default
43
+ -- value is an array, then it would not be copied. Instead, the same shared array would be assigned
44
+ -- to every entry. Thus, to solve this problem, any variable that is passed by reference must be
45
+ -- created using a factory function to ensure that each copy is unique. For example:
46
+ --
47
+ -- ```ts
48
+ -- // Initializes a new empty DefaultMap with a default value of a new empty array.
49
+ -- const factoryFunction = () => [] as ;
50
+ -- const defaultMapWithArray = new DefaultMap<string, string[]>(factoryFunction);
51
+ -- ```
52
+ --
53
+ -- In the previous two examples, the factory functions did not have any arguments. But you can also
54
+ -- specify a factory function that takes one or more arguments:
55
+ --
56
+ -- ```ts
57
+ -- const factoryFunction = (arg: boolean) => arg ? 0 : 1;
58
+ -- const defaultMapWithArg = new DefaultMap<string, string, [arg: boolean]>(factoryFunction);
59
+ -- ```
60
+ --
61
+ -- Similar to a normal `Map`, you can also include an initializer list in the constructor as the
62
+ -- second argument:
63
+ --
64
+ -- ```ts
65
+ -- // Initializes a DefaultMap with a default value of "foo" and some initial values.
66
+ -- const defaultMapWithInitialValues = new DefaultMap<string, string>("foo", [
67
+ -- ["a1", "a2"],
68
+ -- ["b1", "b2"],
69
+ -- ], );
70
+ -- ```
71
+ --
72
+ -- Finally, note that `DefaultMap` has the following additional utility methods:
73
+ --
74
+ -- - `getAndSetDefault` - The method that is called inside the overridden `get` method. In most
75
+ -- cases, you can use the overridden `get` method instead of calling this function directly.
76
+ -- However, if a factory function was provided during instantiation, and the factory function has
77
+ -- one or more arguments, then you must call this method instead (and provide the corresponding
78
+ -- arguments).
79
+ -- - `getWithoutDefault` - Calls the original `Map.get` function (without setting the default
80
+ -- value).
81
+ -- - `getDefaultValue` - Returns the default value to be used for a new key. (If a factory function
82
+ -- was provided during instantiation, this will execute the factory function.)
83
+ -- - `getConstructorArg` - Helper method for cloning the map. Returns either the default value or
84
+ -- the reference to the factory function.
37
85
  ____exports.DefaultMap = __TS__Class()
38
86
  local DefaultMap = ____exports.DefaultMap
39
87
  DefaultMap.name = "DefaultMap"
40
88
  __TS__ClassExtends(DefaultMap, Map)
41
- function DefaultMap.prototype.____constructor(self, iterableOrDefaultValueOrDefaultValueFactory, defaultValueOrDefaultValueFactory)
42
- local ____parseArguments_result_0 = parseArguments(nil, iterableOrDefaultValueOrDefaultValueFactory, defaultValueOrDefaultValueFactory)
43
- local iterable = ____parseArguments_result_0.iterable
44
- local defaultValue = ____parseArguments_result_0.defaultValue
45
- local defaultValueFactory = ____parseArguments_result_0.defaultValueFactory
46
- if defaultValue == nil and defaultValueFactory == nil then
47
- error("A DefaultMap must be instantiated with either a default value or a function that returns a default value.")
89
+ function DefaultMap.prototype.____constructor(self, defaultValueOrFactoryFunction, initializerArray)
90
+ local argType = __TS__TypeOf(defaultValueOrFactoryFunction)
91
+ local argIsPrimitive = argType == "boolean" or argType == "number" or argType == "string"
92
+ local argIsFunction = argType == "function"
93
+ if not argIsPrimitive and not argIsFunction then
94
+ error(("Failed to instantiate a DefaultMap since the provided default value was of type \"" .. argType) .. "\". This error usually means that you are trying to use an array (or some other non-primitive data structure that is passed by reference) as the default value. Instead, return the data structure in a factory function, like \"() => []\". See the DefaultMap documentation for more details.")
48
95
  end
49
- if iterable == nil then
50
- Map.prototype.____constructor(self)
96
+ Map.prototype.____constructor(self, initializerArray)
97
+ if argIsFunction then
98
+ self.defaultValue = nil
99
+ self.defaultValueFactory = defaultValueOrFactoryFunction
51
100
  else
52
- Map.prototype.____constructor(self, iterable)
101
+ self.defaultValue = defaultValueOrFactoryFunction
102
+ self.defaultValueFactory = nil
53
103
  end
54
- self.defaultValue = defaultValue
55
- self.defaultValueFactory = defaultValueFactory
56
104
  end
57
105
  function DefaultMap.prototype.getAndSetDefault(self, key, ...)
58
- local value = self:get(key)
106
+ local value = Map.prototype.get(self, key)
59
107
  if value ~= nil then
60
108
  return value
61
109
  end
@@ -63,6 +111,9 @@ function DefaultMap.prototype.getAndSetDefault(self, key, ...)
63
111
  self:set(key, defaultValue)
64
112
  return defaultValue
65
113
  end
114
+ function DefaultMap.prototype.getWithoutDefault(self, key)
115
+ return Map.prototype.get(self, key)
116
+ end
66
117
  function DefaultMap.prototype.getDefaultValue(self, ...)
67
118
  if self.defaultValue ~= nil then
68
119
  return self.defaultValue
@@ -2,9 +2,9 @@ import { ModCallback } from "isaac-typescript-definitions";
2
2
  import { ModCallbackCustom } from "../enums/ModCallbackCustom";
3
3
  import { AddCallbackParameterCustom } from "../interfaces/AddCallbackParameterCustom";
4
4
  /**
5
- * `isaacscript-common` has many custom callbacks that you can use in your mods. Instead of
6
- * hijacking the vanilla `Mod` object, we provide a `ModUpgraded` object for you to use, which
7
- * extends the base class and adds a new method of `AddCallbackCustom`.
5
+ * `isaacscript-common` has many {@link ModCallbackCustom custom callbacks} that you can use in your
6
+ * mods. Instead of hijacking the vanilla `Mod` object, we provide a `ModUpgraded` object for you to
7
+ * use, which extends the base class and adds a new method of `AddCallbackCustom`.
8
8
  *
9
9
  * To upgrade your mod, use the `upgradeMod` helper function.
10
10
  */
@@ -3,6 +3,11 @@ local __TS__Class = ____lualib.__TS__Class
3
3
  local ____exports = {}
4
4
  local ____callbackRegisterFunctions = require("objects.callbackRegisterFunctions")
5
5
  local CALLBACK_REGISTER_FUNCTIONS = ____callbackRegisterFunctions.CALLBACK_REGISTER_FUNCTIONS
6
+ --- `isaacscript-common` has many {@link ModCallbackCustomcustom callbacks} that you can use in your
7
+ -- mods. Instead of hijacking the vanilla `Mod` object, we provide a `ModUpgraded` object for you to
8
+ -- use, which extends the base class and adds a new method of `AddCallbackCustom`.
9
+ --
10
+ -- To upgrade your mod, use the `upgradeMod` helper function.
6
11
  ____exports.ModUpgraded = __TS__Class()
7
12
  local ModUpgraded = ____exports.ModUpgraded
8
13
  ModUpgraded.name = "ModUpgraded"
package/constants.lua CHANGED
@@ -8,38 +8,79 @@ local TrinketSlot = ____isaac_2Dtypescript_2Ddefinitions.TrinketSlot
8
8
  local ____enums = require("functions.enums")
9
9
  local getEnumLength = ____enums.getEnumLength
10
10
  local getLastEnumValue = ____enums.getLastEnumValue
11
+ --- The distance of the laser when Azazel does not have any range up items yet. For more info, see
12
+ -- the documentation for the `getAzazelBrimstoneDistance` function.
11
13
  ____exports.AZAZEL_DEFAULT_BRIMSTONE_DISTANCE = 75.125
14
+ --- The path to the png file for collectible items during Curse of the Blind, making them appear with
15
+ -- a red question mark.
12
16
  ____exports.BLIND_ITEM_PNG_PATH = "gfx/items/collectibles/questionmark.png"
17
+ --- Bombs explode when their frame count is equal to this value.
13
18
  ____exports.BOMB_EXPLODE_FRAME = 45
14
19
  ____exports.DEFAULT_ITEM_POOL_TYPE = ItemPoolType.TREASURE
20
+ --- This is also the distance that a player spawns from the door that they enter a room from.
15
21
  ____exports.DISTANCE_OF_GRID_TILE = 40
16
22
  ____exports.DOOR_HITBOX_RADIUS = 11
23
+ --- When Eggies take fatal damage, they go into NpcState.STATE_SUICIDE and spawn 14 Swarm Spiders
24
+ -- while their StateFrame ticks upwards. The 14th spider appears when the StateFrame is at this
25
+ -- value.
17
26
  ____exports.EGGY_STATE_FRAME_OF_FINAL_SPIDER = 45
27
+ --- A non-existent or completely transparent PNG file for use in clearing sprites. For more
28
+ -- information, see the documentation for the `clearSprite` helper function.
18
29
  ____exports.EMPTY_PNG_PATH = "gfx/none.png"
30
+ --- The random items that appear when the player has TMTRAINER are generated on the fly as they are
31
+ -- encountered by the player. The first TMTRAINER item takes the final possible 32 bit number. The
32
+ -- second TMTRAINER item subtracts one from that, and so on.
19
33
  ____exports.FIRST_GLITCHED_COLLECTIBLE_TYPE = (1 << 32) - 1
20
34
  ____exports.GAME_FRAMES_PER_SECOND = 30
21
35
  ____exports.GRID_INDEX_CENTER_OF_1X1_ROOM = 67
22
36
  ____exports.ISAAC_FRAMES_PER_SECOND = 60
37
+ --- The floor is represented by a 13x13 grid. Room indexes start at 0. The first column is
38
+ -- represented by grid indexes 0, 13, 26, and so on.
23
39
  ____exports.LEVEL_GRID_COLUMN_HEIGHT = 13
40
+ --- The floor is represented by a 13x13 grid. Room indexes start at 0. The first row is represented
41
+ -- by grid indexes from 0 to 12. The second row is represented by grid indexes from 13 to 25, and so
42
+ -- on.
24
43
  ____exports.LEVEL_GRID_ROW_WIDTH = 13
44
+ --- The floor is represented by a 13x13 grid. Room indexes start at 0. The first row is represented
45
+ -- by grid indexes from 0 to 12. The second row is represented by grid indexes from 13 to 25, and so
46
+ -- on. The maximum room index possible is 168. (It is not 169 because we start at 0 instead of 1.)
25
47
  ____exports.MAX_LEVEL_GRID_INDEX = 168
48
+ --- The game has a limit on the number of currently spawned familiars and will refuse to spawn any
49
+ -- more if it reaches the limit. Blue flies and blue spiders have a lower priority and will be
50
+ -- deleted to make room for other familiars.
26
51
  ____exports.MAX_NUM_FAMILIARS = 64
52
+ --- The game can only handle up to four different players.
27
53
  ____exports.MAX_NUM_INPUTS = 4
54
+ --- With Birthright, it is possible for Magdalene to have 18 heart containers.
28
55
  ____exports.MAX_PLAYER_HEART_CONTAINERS = 18
56
+ --- As the player continues to move in a direction, they will accelerate. When going from one wall to
57
+ -- another in a 2x2 room at 2.0 speed (the maximum that the speed stat can rise to), the amount of
58
+ -- units moved per update frame will climb to around 9.797 as they hit the opposite wall. The
59
+ -- constant specifies a value of 9.8 to be safe.
29
60
  ____exports.MAX_PLAYER_SPEED_IN_UNITS = 9.8
30
61
  ____exports.MAX_PLAYER_TRINKET_SLOTS = getEnumLength(nil, TrinketSlot)
31
62
  ____exports.FIRST_ROOM_TYPE = RoomType.DEFAULT
32
63
  ____exports.LAST_ROOM_TYPE = getLastEnumValue(nil, RoomType)
64
+ --- The maximum speed stat that a player can have. Any additional speed beyond this will not take
65
+ -- effect.
33
66
  ____exports.MAX_SPEED_STAT = 2
34
67
  ____exports.FIRST_STAGE = LevelStage.BASEMENT_1
35
68
  ____exports.LAST_STAGE = getLastEnumValue(nil, LevelStage)
69
+ --- Corresponds to the maximum value for `EntityPlayer.SamsonBerserkCharge`.
36
70
  ____exports.MAX_TAINTED_SAMSON_BERSERK_CHARGE = 100000
37
71
  ____exports.NUM_DIMENSIONS = getEnumLength(nil, Dimension) - 1
38
72
  ____exports.SECOND_IN_MILLISECONDS = 1000
39
73
  ____exports.MINUTE_IN_MILLISECONDS = 60 * ____exports.SECOND_IN_MILLISECONDS
40
74
  ____exports.ONE_BY_ONE_ROOM_GRID_SIZE = 135
75
+ --- After taking damage, `EntityPlayer.SamsonBerserkCharge` is incremented by this amount.
41
76
  ____exports.TAINTED_SAMSON_BERSERK_CHARGE_FROM_TAKING_DAMAGE = 10000
77
+ --- This is the number of draw coordinates that each heart spans on the UI in the upper left hand
78
+ -- corner.
42
79
  ____exports.UI_HEART_WIDTH = 12
80
+ --- This is a safer version of the `Vector.One` constant. (Other mods can mutate this `Vector.One`,
81
+ -- so it is not safe to use.)
43
82
  ____exports.VectorOne = Vector(1, 1)
83
+ --- This is a safer version of the `Vector.Zero` constant. (Other mods can mutate `Vector.Zero`
84
+ -- vector, so it is not safe to use.)
44
85
  ____exports.VectorZero = Vector(0, 0)
45
86
  return ____exports
@@ -11,40 +11,103 @@ local itemConfig = ____cachedClasses.itemConfig
11
11
  local ____enums = require("functions.enums")
12
12
  local getEnumLength = ____enums.getEnumLength
13
13
  local getLastEnumValue = ____enums.getLastEnumValue
14
+ --- Equal to `CollectibleType.SAD_ONION`.
14
15
  ____exports.FIRST_COLLECTIBLE_TYPE = CollectibleType.SAD_ONION
16
+ --- Will change depending on how many modded collectibles there are.
17
+ --
18
+ -- Equal to `itemConfig.GetCollectibles().Size - 1`. (`Size` includes invalid collectibles. We
19
+ -- subtract one to account for `CollectibleType.NULL`.)
15
20
  ____exports.LAST_COLLECTIBLE_TYPE = itemConfig:GetCollectibles().Size - 1
21
+ --- Calculated from the `CollectibleType` enum.
22
+ --
23
+ -- Note that this cannot be calculated from the length of the enum, because unlike all of the other
24
+ -- enums, collectible types are not contiguous.
16
25
  ____exports.LAST_VANILLA_COLLECTIBLE_TYPE = getLastEnumValue(nil, CollectibleType)
26
+ --- If there are no modded collectibles, this constant will represent a collectible type that does
27
+ -- not exist.
17
28
  ____exports.FIRST_MODDED_COLLECTIBLE_TYPE = ____exports.LAST_VANILLA_COLLECTIBLE_TYPE + 1
29
+ --- Calculated from the `CollectibleType` enum. `CollectibleType.NULL` is not included.
18
30
  ____exports.NUM_VANILLA_COLLECTIBLE_TYPES = getEnumLength(nil, CollectibleType) - 1
31
+ --- Unlike vanilla collectible types, modded collectible types are always contiguous.
19
32
  ____exports.NUM_MODDED_COLLECTIBLE_TYPES = ____exports.LAST_COLLECTIBLE_TYPE - ____exports.LAST_VANILLA_COLLECTIBLE_TYPE
20
33
  ____exports.NUM_COLLECTIBLE_TYPES = ____exports.NUM_VANILLA_COLLECTIBLE_TYPES + ____exports.NUM_MODDED_COLLECTIBLE_TYPES
34
+ --- Will change depending on how many modded cards there are.
35
+ --
36
+ -- Equal to `itemConfig.GetTrinkets().Size - 1`. (We subtract one to account for
37
+ -- `TrinketType.NULL`.)
21
38
  ____exports.NUM_TRINKET_TYPES = itemConfig:GetTrinkets().Size - 1
39
+ --- Calculated from the `TrinketType` enum. `TrinketType.NULL` is not included.
22
40
  ____exports.NUM_VANILLA_TRINKET_TYPES = getEnumLength(nil, TrinketType) - 1
23
41
  ____exports.NUM_MODDED_TRINKET_TYPES = ____exports.NUM_TRINKET_TYPES - ____exports.NUM_VANILLA_TRINKET_TYPES
42
+ --- Equal to `TrinketType.SWALLOWED_PENNY`.
24
43
  ____exports.FIRST_TRINKET_TYPE = TrinketType.SWALLOWED_PENNY
44
+ --- Will change depending on how many modded cards there are.
45
+ --
46
+ -- Equal to `itemConfig.GetTrinkets().Size - 1`. (We subtract one to account for
47
+ -- `TrinketType.NULL`.)
25
48
  ____exports.LAST_TRINKET_TYPE = ____exports.NUM_TRINKET_TYPES
49
+ --- Calculated from the `TrinketType` enum.
26
50
  ____exports.LAST_VANILLA_TRINKET_TYPE = getLastEnumValue(nil, TrinketType)
51
+ --- If there are no modded trinkets, this constant will represent a trinket type that does not exist.
27
52
  ____exports.FIRST_MODDED_TRINKET_TYPE = ____exports.LAST_VANILLA_TRINKET_TYPE + 1
53
+ --- Will change depending on how many modded cards there are.
54
+ --
55
+ -- Equal to `itemConfig.GetCards().Size - 1`. (We subtract one to account for `Card.NULL`.)
28
56
  ____exports.NUM_CARDS = itemConfig:GetCards().Size - 1
57
+ --- Calculated from the `Card` enum. `Card.NULL` is not included.
29
58
  ____exports.NUM_VANILLA_CARDS = getEnumLength(nil, Card) - 1
30
59
  ____exports.NUM_MODDED_CARDS = ____exports.NUM_CARDS - ____exports.NUM_VANILLA_CARDS
60
+ --- Equal to `Card.FOOL`.
31
61
  ____exports.FIRST_CARD = Card.FOOL
62
+ --- Will change depending on how many modded cards there are.
63
+ --
64
+ -- Equal to `itemConfig.GetCards().Size - 1`. (We subtract one to account for `Card.NULL`.)
32
65
  ____exports.LAST_CARD = ____exports.NUM_CARDS
66
+ --- Calculated from the `Card` enum.
33
67
  ____exports.MAX_VANILLA_CARD = getLastEnumValue(nil, Card)
68
+ --- If there are no modded cards, this constant will represent a card that does not exist.
34
69
  ____exports.FIRST_MODDED_CARD = ____exports.MAX_VANILLA_CARD + 1
70
+ --- Will change depending on how many modded pill effects there are.
71
+ --
72
+ -- Equal to `itemConfig.GetPillEffects().Size - 1`. (We subtract one to account for
73
+ -- `PillEffect.NULL`.)
35
74
  ____exports.NUM_PILL_EFFECTS = itemConfig:GetPillEffects().Size - 1
75
+ --- Calculated from the `PillEffect` enum.
76
+ --
77
+ -- (There is no `PillEffect.NULL` in the custom enum, so we don't have to subtract one here.)
36
78
  ____exports.NUM_VANILLA_PILL_EFFECTS = getEnumLength(nil, PillEffect)
37
79
  ____exports.NUM_MODDED_PILL_EFFECTS = ____exports.NUM_PILL_EFFECTS - ____exports.NUM_VANILLA_PILL_EFFECTS
80
+ --- Equal to `PillEffect.BAD_GAS`.
38
81
  ____exports.FIRST_PILL_EFFECT = PillEffect.BAD_GAS
82
+ --- Will change depending on how many modded pill effects there are.
83
+ --
84
+ -- Equal to `itemConfig.GetPillEffects().Size - 1`. (We subtract one to account for
85
+ -- `PillEffect.NULL`.)
39
86
  ____exports.LAST_PILL_EFFECT = ____exports.NUM_PILL_EFFECTS
87
+ --- Calculated from the `PillEffect` enum.
40
88
  ____exports.LAST_VANILLA_PILL_EFFECT = getLastEnumValue(nil, PillEffect)
89
+ --- If there are no modded pill effects, this constant will represent a pill effect that does not
90
+ -- exist.
41
91
  ____exports.FIRST_MODDED_PILL_EFFECT = ____exports.LAST_VANILLA_PILL_EFFECT + 1
92
+ --- Equal to `PillColor.BLUE_BLUE`.
42
93
  ____exports.FIRST_PILL_COLOR = PillColor.BLUE_BLUE
94
+ --- Equal to `PillColor.WHITE_YELLOW`.
95
+ --
96
+ -- Note that `PillColor.GOLD` is technically higher, but that is not considered for the purposes of
97
+ -- this constant.
43
98
  ____exports.LAST_NORMAL_PILL_COLOR = PillColor.WHITE_YELLOW
99
+ --- Equal to `PillColor.HORSE_BLUE_BLUE`.
44
100
  ____exports.FIRST_HORSE_PILL_COLOR = PillColor.HORSE_BLUE_BLUE
101
+ --- Equal to `PillColor.HORSE_WHITE_YELLOW`.
102
+ --
103
+ -- Note that `PillColor.HORSE_GOLD` is technically higher, but that is not considered for the
104
+ -- purposes of this constant.
45
105
  ____exports.LAST_HORSE_PILL_COLOR = PillColor.HORSE_WHITE_YELLOW
46
106
  ____exports.NUM_NORMAL_PILL_COLORS = ____exports.LAST_NORMAL_PILL_COLOR - ____exports.FIRST_PILL_COLOR
107
+ --- Equal to `PlayerType.ISAAC`.
47
108
  ____exports.FIRST_CHARACTER = PlayerType.ISAAC
109
+ --- Calculated from the `PlayerType` enum.
48
110
  ____exports.LAST_VANILLA_CHARACTER = getLastEnumValue(nil, PlayerType)
111
+ --- If there are no modded characters, this constant will represent a character that does not exist.
49
112
  ____exports.FIRST_MODDED_CHARACTER = ____exports.LAST_VANILLA_CHARACTER + 1
50
113
  return ____exports
@@ -1,4 +1,7 @@
1
1
  local ____exports = {}
2
+ --- This represents the type of health that is either given or taken away from a player. Note that we
3
+ -- cannot use the `HeartSubType` enum for this purpose this since it has no value for broken hearts
4
+ -- or max hearts.
2
5
  ____exports.HealthType = {}
3
6
  ____exports.HealthType.RED = 0
4
7
  ____exports.HealthType[____exports.HealthType.RED] = "RED"