isaacscript-common 84.0.0 → 84.1.0

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 (568) hide show
  1. package/dist/arrays/cachedEnumValues.js +33 -0
  2. package/dist/callbackClasses.js +289 -0
  3. package/dist/callbacks.js +181 -0
  4. package/dist/classes/DefaultMap.js +171 -0
  5. package/dist/classes/ModFeature.js +244 -0
  6. package/dist/classes/ModUpgraded.js +324 -0
  7. package/dist/classes/callbacks/EntityTakeDmgFilter.js +19 -0
  8. package/dist/classes/callbacks/EntityTakeDmgPlayer.js +29 -0
  9. package/dist/classes/callbacks/InputActionFilter.js +24 -0
  10. package/dist/classes/callbacks/InputActionPlayer.js +37 -0
  11. package/dist/classes/callbacks/PostAmbushFinished.js +40 -0
  12. package/dist/classes/callbacks/PostAmbushStarted.js +40 -0
  13. package/dist/classes/callbacks/PostBombExploded.js +24 -0
  14. package/dist/classes/callbacks/PostBombInitFilter.js +21 -0
  15. package/dist/classes/callbacks/PostBombInitLate.js +31 -0
  16. package/dist/classes/callbacks/PostBombRenderFilter.js +21 -0
  17. package/dist/classes/callbacks/PostBombUpdateFilter.js +21 -0
  18. package/dist/classes/callbacks/PostBoneSwing.js +53 -0
  19. package/dist/classes/callbacks/PostCollectibleEmpty.js +50 -0
  20. package/dist/classes/callbacks/PostCursedTeleport.js +119 -0
  21. package/dist/classes/callbacks/PostCustomRevive.js +17 -0
  22. package/dist/classes/callbacks/PostDiceRoomActivated.js +50 -0
  23. package/dist/classes/callbacks/PostDoorRender.js +24 -0
  24. package/dist/classes/callbacks/PostDoorUpdate.js +24 -0
  25. package/dist/classes/callbacks/PostEffectInitFilter.js +21 -0
  26. package/dist/classes/callbacks/PostEffectInitLate.js +31 -0
  27. package/dist/classes/callbacks/PostEffectRenderFilter.js +21 -0
  28. package/dist/classes/callbacks/PostEffectStateChanged.js +34 -0
  29. package/dist/classes/callbacks/PostEffectUpdateFilter.js +21 -0
  30. package/dist/classes/callbacks/PostEntityKillFilter.js +21 -0
  31. package/dist/classes/callbacks/PostEsauJr.js +12 -0
  32. package/dist/classes/callbacks/PostFamiliarInitFilter.js +21 -0
  33. package/dist/classes/callbacks/PostFamiliarInitLate.js +31 -0
  34. package/dist/classes/callbacks/PostFamiliarRenderFilter.js +21 -0
  35. package/dist/classes/callbacks/PostFamiliarStateChanged.js +34 -0
  36. package/dist/classes/callbacks/PostFamiliarUpdateFilter.js +21 -0
  37. package/dist/classes/callbacks/PostFirstEsauJr.js +12 -0
  38. package/dist/classes/callbacks/PostFirstFlip.js +12 -0
  39. package/dist/classes/callbacks/PostFlip.js +12 -0
  40. package/dist/classes/callbacks/PostGameEndFilter.js +21 -0
  41. package/dist/classes/callbacks/PostGameStartedReordered.js +14 -0
  42. package/dist/classes/callbacks/PostGameStartedReorderedLast.js +14 -0
  43. package/dist/classes/callbacks/PostGreedModeWave.js +35 -0
  44. package/dist/classes/callbacks/PostGridEntityBroken.js +14 -0
  45. package/dist/classes/callbacks/PostGridEntityCollision.js +28 -0
  46. package/dist/classes/callbacks/PostGridEntityCustomBroken.js +14 -0
  47. package/dist/classes/callbacks/PostGridEntityCustomCollision.js +24 -0
  48. package/dist/classes/callbacks/PostGridEntityCustomInit.js +14 -0
  49. package/dist/classes/callbacks/PostGridEntityCustomRemove.js +18 -0
  50. package/dist/classes/callbacks/PostGridEntityCustomRender.js +14 -0
  51. package/dist/classes/callbacks/PostGridEntityCustomStateChanged.js +14 -0
  52. package/dist/classes/callbacks/PostGridEntityCustomUpdate.js +14 -0
  53. package/dist/classes/callbacks/PostGridEntityInit.js +14 -0
  54. package/dist/classes/callbacks/PostGridEntityRemove.js +19 -0
  55. package/dist/classes/callbacks/PostGridEntityRender.js +14 -0
  56. package/dist/classes/callbacks/PostGridEntityStateChanged.js +14 -0
  57. package/dist/classes/callbacks/PostGridEntityUpdate.js +14 -0
  58. package/dist/classes/callbacks/PostHolyMantleRemoved.js +43 -0
  59. package/dist/classes/callbacks/PostItemDischarge.js +122 -0
  60. package/dist/classes/callbacks/PostItemPickup.js +14 -0
  61. package/dist/classes/callbacks/PostKeyboardChanged.js +46 -0
  62. package/dist/classes/callbacks/PostKnifeInitFilter.js +21 -0
  63. package/dist/classes/callbacks/PostKnifeInitLate.js +31 -0
  64. package/dist/classes/callbacks/PostKnifeRenderFilter.js +21 -0
  65. package/dist/classes/callbacks/PostKnifeUpdateFilter.js +21 -0
  66. package/dist/classes/callbacks/PostLaserInitFilter.js +21 -0
  67. package/dist/classes/callbacks/PostLaserInitLate.js +31 -0
  68. package/dist/classes/callbacks/PostLaserRenderFilter.js +21 -0
  69. package/dist/classes/callbacks/PostLaserUpdateFilter.js +21 -0
  70. package/dist/classes/callbacks/PostNPCDeathFilter.js +21 -0
  71. package/dist/classes/callbacks/PostNPCInitFilter.js +21 -0
  72. package/dist/classes/callbacks/PostNPCInitLate.js +31 -0
  73. package/dist/classes/callbacks/PostNPCRenderFilter.js +21 -0
  74. package/dist/classes/callbacks/PostNPCStateChanged.js +34 -0
  75. package/dist/classes/callbacks/PostNPCUpdateFilter.js +21 -0
  76. package/dist/classes/callbacks/PostNewLevelReordered.js +14 -0
  77. package/dist/classes/callbacks/PostNewRoomEarly.js +74 -0
  78. package/dist/classes/callbacks/PostNewRoomReordered.js +14 -0
  79. package/dist/classes/callbacks/PostPEffectUpdateReordered.js +14 -0
  80. package/dist/classes/callbacks/PostPickupChanged.js +14 -0
  81. package/dist/classes/callbacks/PostPickupCollect.js +38 -0
  82. package/dist/classes/callbacks/PostPickupInitFilter.js +21 -0
  83. package/dist/classes/callbacks/PostPickupInitFirst.js +33 -0
  84. package/dist/classes/callbacks/PostPickupInitLate.js +31 -0
  85. package/dist/classes/callbacks/PostPickupRenderFilter.js +21 -0
  86. package/dist/classes/callbacks/PostPickupSelectionFilter.js +29 -0
  87. package/dist/classes/callbacks/PostPickupStateChanged.js +34 -0
  88. package/dist/classes/callbacks/PostPickupUpdateFilter.js +21 -0
  89. package/dist/classes/callbacks/PostPitRender.js +24 -0
  90. package/dist/classes/callbacks/PostPitUpdate.js +24 -0
  91. package/dist/classes/callbacks/PostPlayerChangeHealth.js +47 -0
  92. package/dist/classes/callbacks/PostPlayerChangeStat.js +79 -0
  93. package/dist/classes/callbacks/PostPlayerChangeType.js +36 -0
  94. package/dist/classes/callbacks/PostPlayerCollectibleAdded.js +14 -0
  95. package/dist/classes/callbacks/PostPlayerCollectibleRemoved.js +14 -0
  96. package/dist/classes/callbacks/PostPlayerFatalDamage.js +83 -0
  97. package/dist/classes/callbacks/PostPlayerInitFirst.js +41 -0
  98. package/dist/classes/callbacks/PostPlayerInitLate.js +33 -0
  99. package/dist/classes/callbacks/PostPlayerRenderReordered.js +14 -0
  100. package/dist/classes/callbacks/PostPlayerUpdateReordered.js +14 -0
  101. package/dist/classes/callbacks/PostPoopRender.js +24 -0
  102. package/dist/classes/callbacks/PostPoopUpdate.js +24 -0
  103. package/dist/classes/callbacks/PostPressurePlateRender.js +24 -0
  104. package/dist/classes/callbacks/PostPressurePlateUpdate.js +24 -0
  105. package/dist/classes/callbacks/PostProjectileInitFilter.js +21 -0
  106. package/dist/classes/callbacks/PostProjectileInitLate.js +31 -0
  107. package/dist/classes/callbacks/PostProjectileKill.js +52 -0
  108. package/dist/classes/callbacks/PostProjectileRenderFilter.js +21 -0
  109. package/dist/classes/callbacks/PostProjectileUpdateFilter.js +21 -0
  110. package/dist/classes/callbacks/PostPurchase.js +90 -0
  111. package/dist/classes/callbacks/PostRockRender.js +24 -0
  112. package/dist/classes/callbacks/PostRockUpdate.js +24 -0
  113. package/dist/classes/callbacks/PostRoomClearChanged.js +46 -0
  114. package/dist/classes/callbacks/PostSacrifice.js +36 -0
  115. package/dist/classes/callbacks/PostSlotAnimationChanged.js +14 -0
  116. package/dist/classes/callbacks/PostSlotCollision.js +25 -0
  117. package/dist/classes/callbacks/PostSlotDestroyed.js +14 -0
  118. package/dist/classes/callbacks/PostSlotInit.js +14 -0
  119. package/dist/classes/callbacks/PostSlotRender.js +14 -0
  120. package/dist/classes/callbacks/PostSlotUpdate.js +14 -0
  121. package/dist/classes/callbacks/PostSpikesRender.js +24 -0
  122. package/dist/classes/callbacks/PostSpikesUpdate.js +24 -0
  123. package/dist/classes/callbacks/PostTNTRender.js +24 -0
  124. package/dist/classes/callbacks/PostTNTUpdate.js +24 -0
  125. package/dist/classes/callbacks/PostTearInitFilter.js +21 -0
  126. package/dist/classes/callbacks/PostTearInitLate.js +31 -0
  127. package/dist/classes/callbacks/PostTearInitVeryLate.js +35 -0
  128. package/dist/classes/callbacks/PostTearKill.js +52 -0
  129. package/dist/classes/callbacks/PostTearRenderFilter.js +21 -0
  130. package/dist/classes/callbacks/PostTearUpdateFilter.js +21 -0
  131. package/dist/classes/callbacks/PostTransformation.js +47 -0
  132. package/dist/classes/callbacks/PostTrinketBreak.js +70 -0
  133. package/dist/classes/callbacks/PostUsePillFilter.js +76 -0
  134. package/dist/classes/callbacks/PreBerserkDeath.js +41 -0
  135. package/dist/classes/callbacks/PreBombCollisionFilter.js +19 -0
  136. package/dist/classes/callbacks/PreCustomRevive.js +14 -0
  137. package/dist/classes/callbacks/PreEntitySpawnFilter.js +24 -0
  138. package/dist/classes/callbacks/PreFamiliarCollisionFilter.js +19 -0
  139. package/dist/classes/callbacks/PreGetPedestal.js +46 -0
  140. package/dist/classes/callbacks/PreItemPickup.js +14 -0
  141. package/dist/classes/callbacks/PreKnifeCollisionFilter.js +19 -0
  142. package/dist/classes/callbacks/PreNPCCollisionFilter.js +19 -0
  143. package/dist/classes/callbacks/PreNPCUpdateFilter.js +19 -0
  144. package/dist/classes/callbacks/PreNewLevel.js +51 -0
  145. package/dist/classes/callbacks/PreProjectileCollisionFilter.js +19 -0
  146. package/dist/classes/callbacks/PreRoomEntitySpawnFilter.js +26 -0
  147. package/dist/classes/callbacks/PreTearCollisionFilter.js +19 -0
  148. package/dist/classes/features/callbackLogic/CustomGridEntities.js +359 -0
  149. package/dist/classes/features/callbackLogic/CustomRevive.js +170 -0
  150. package/dist/classes/features/callbackLogic/EsauJrDetection.js +70 -0
  151. package/dist/classes/features/callbackLogic/FlipDetection.js +61 -0
  152. package/dist/classes/features/callbackLogic/GameReorderedCallbacks.js +220 -0
  153. package/dist/classes/features/callbackLogic/GridEntityCollisionDetection.js +62 -0
  154. package/dist/classes/features/callbackLogic/GridEntityRenderDetection.js +35 -0
  155. package/dist/classes/features/callbackLogic/GridEntityUpdateDetection.js +147 -0
  156. package/dist/classes/features/callbackLogic/ItemPickupDetection.js +68 -0
  157. package/dist/classes/features/callbackLogic/PickupChangeDetection.js +43 -0
  158. package/dist/classes/features/callbackLogic/PlayerCollectibleDetection.js +193 -0
  159. package/dist/classes/features/callbackLogic/PlayerReorderedCallbacks.js +109 -0
  160. package/dist/classes/features/callbackLogic/SlotDestroyedDetection.js +95 -0
  161. package/dist/classes/features/callbackLogic/SlotRenderDetection.js +48 -0
  162. package/dist/classes/features/callbackLogic/SlotUpdateDetection.js +52 -0
  163. package/dist/classes/features/other/CharacterHealthConversion.js +112 -0
  164. package/dist/classes/features/other/CharacterStats.js +68 -0
  165. package/dist/classes/features/other/CollectibleItemPoolType.js +75 -0
  166. package/dist/classes/features/other/CustomHotkeys.js +144 -0
  167. package/dist/classes/features/other/CustomItemPools.js +128 -0
  168. package/dist/classes/features/other/CustomPickups.js +118 -0
  169. package/dist/classes/features/other/CustomStages.js +471 -0
  170. package/dist/classes/features/other/CustomTrapdoors.js +596 -0
  171. package/dist/classes/features/other/DebugDisplay.js +699 -0
  172. package/dist/classes/features/other/DeployJSONRoom.js +301 -0
  173. package/dist/classes/features/other/DisableAllSound.js +90 -0
  174. package/dist/classes/features/other/DisableInputs.js +249 -0
  175. package/dist/classes/features/other/EdenStartingStatsHealth.js +197 -0
  176. package/dist/classes/features/other/ExtraConsoleCommands.js +292 -0
  177. package/dist/classes/features/other/FadeInRemover.js +67 -0
  178. package/dist/classes/features/other/FastReset.js +88 -0
  179. package/dist/classes/features/other/FlyingDetection.js +64 -0
  180. package/dist/classes/features/other/ForgottenSwitch.js +43 -0
  181. package/dist/classes/features/other/ItemPoolDetection.js +187 -0
  182. package/dist/classes/features/other/ModdedElementDetection.js +399 -0
  183. package/dist/classes/features/other/ModdedElementSets.js +1251 -0
  184. package/dist/classes/features/other/NoSirenSteal.js +88 -0
  185. package/dist/classes/features/other/Pause.js +197 -0
  186. package/dist/classes/features/other/PersistentEntities.js +168 -0
  187. package/dist/classes/features/other/PickupIndexCreation.js +229 -0
  188. package/dist/classes/features/other/PlayerCollectibleTracking.js +102 -0
  189. package/dist/classes/features/other/PonyDetection.js +86 -0
  190. package/dist/classes/features/other/PressInput.js +71 -0
  191. package/dist/classes/features/other/PreventChildEntities.js +60 -0
  192. package/dist/classes/features/other/PreventGridEntityRespawn.js +159 -0
  193. package/dist/classes/features/other/RerunDetection.js +69 -0
  194. package/dist/classes/features/other/RoomClearFrame.js +94 -0
  195. package/dist/classes/features/other/RoomHistory.js +196 -0
  196. package/dist/classes/features/other/RunInNFrames.js +323 -0
  197. package/dist/classes/features/other/RunNextRoom.js +53 -0
  198. package/dist/classes/features/other/RunNextRun.js +60 -0
  199. package/dist/classes/features/other/SaveDataManager.js +383 -0
  200. package/dist/classes/features/other/SpawnRockAltRewards.js +469 -0
  201. package/dist/classes/features/other/StageHistory.js +244 -0
  202. package/dist/classes/features/other/StartAmbush.js +62 -0
  203. package/dist/classes/features/other/TaintedLazarusPlayers.js +115 -0
  204. package/dist/classes/features/other/UnlockAchievementsDetection.js +60 -0
  205. package/dist/classes/features/other/customStages/backdrop.js +195 -0
  206. package/dist/classes/features/other/customStages/constants.js +19 -0
  207. package/dist/classes/features/other/customStages/gridEntities.js +177 -0
  208. package/dist/classes/features/other/customStages/shadows.js +67 -0
  209. package/dist/classes/features/other/customStages/streakText.js +222 -0
  210. package/dist/classes/features/other/customStages/utils.js +65 -0
  211. package/dist/classes/features/other/customStages/v.js +27 -0
  212. package/dist/classes/features/other/customStages/versusScreen.js +227 -0
  213. package/dist/classes/features/other/debugDisplay/DebugDisplayBomb.js +23 -0
  214. package/dist/classes/features/other/debugDisplay/DebugDisplayDoor.js +22 -0
  215. package/dist/classes/features/other/debugDisplay/DebugDisplayEffect.js +23 -0
  216. package/dist/classes/features/other/debugDisplay/DebugDisplayFamiliar.js +23 -0
  217. package/dist/classes/features/other/debugDisplay/DebugDisplayKnife.js +23 -0
  218. package/dist/classes/features/other/debugDisplay/DebugDisplayLaser.js +23 -0
  219. package/dist/classes/features/other/debugDisplay/DebugDisplayNPC.js +23 -0
  220. package/dist/classes/features/other/debugDisplay/DebugDisplayPickup.js +23 -0
  221. package/dist/classes/features/other/debugDisplay/DebugDisplayPit.js +22 -0
  222. package/dist/classes/features/other/debugDisplay/DebugDisplayPlayer.js +25 -0
  223. package/dist/classes/features/other/debugDisplay/DebugDisplayPoop.js +22 -0
  224. package/dist/classes/features/other/debugDisplay/DebugDisplayPressurePlate.js +25 -0
  225. package/dist/classes/features/other/debugDisplay/DebugDisplayProjectile.js +23 -0
  226. package/dist/classes/features/other/debugDisplay/DebugDisplayRock.js +22 -0
  227. package/dist/classes/features/other/debugDisplay/DebugDisplaySlot.js +22 -0
  228. package/dist/classes/features/other/debugDisplay/DebugDisplaySpikes.js +22 -0
  229. package/dist/classes/features/other/debugDisplay/DebugDisplayTNT.js +22 -0
  230. package/dist/classes/features/other/debugDisplay/DebugDisplayTear.js +23 -0
  231. package/dist/classes/features/other/debugDisplay/utils.js +13 -0
  232. package/dist/classes/features/other/extraConsoleCommands/commands.js +1598 -0
  233. package/dist/classes/features/other/extraConsoleCommands/subroutines.js +135 -0
  234. package/dist/classes/features/other/extraConsoleCommands/v.js +30 -0
  235. package/dist/classes/features/other/saveDataManager/constants.js +4 -0
  236. package/dist/classes/features/other/saveDataManager/glowingHourGlass.js +106 -0
  237. package/dist/classes/features/other/saveDataManager/loadFromDisk.js +69 -0
  238. package/dist/classes/features/other/saveDataManager/restoreDefaults.js +69 -0
  239. package/dist/classes/features/other/saveDataManager/saveToDisk.js +46 -0
  240. package/dist/classes/private/CustomCallback.js +59 -0
  241. package/dist/classes/private/Feature.js +39 -0
  242. package/dist/core/cachedClasses.js +61 -0
  243. package/dist/core/constants.js +289 -0
  244. package/dist/core/constantsFirstLast.js +98 -0
  245. package/dist/core/constantsVanilla.js +131 -0
  246. package/dist/core/upgradeMod.js +71 -0
  247. package/dist/customStageMetadata.json +1 -0
  248. package/dist/data/itempools.json +16625 -0
  249. package/dist/decorators.js +21 -0
  250. package/dist/enums/AmbushType.js +9 -0
  251. package/dist/enums/CornerType.js +11 -0
  252. package/dist/enums/HealthType.js +20 -0
  253. package/dist/enums/ISCFeature.js +65 -0
  254. package/dist/enums/LadderSubTypeCustom.js +20 -0
  255. package/dist/enums/ModCallbackCustom.js +2477 -0
  256. package/dist/enums/MysteriousPaperEffect.js +16 -0
  257. package/dist/enums/PlayerStat.js +37 -0
  258. package/dist/enums/PocketItemType.js +13 -0
  259. package/dist/enums/RockAltType.js +23 -0
  260. package/dist/enums/SaveDataKey.js +14 -0
  261. package/dist/enums/SerializationType.js +10 -0
  262. package/dist/enums/SlotDestructionType.js +22 -0
  263. package/dist/enums/private/GridEntityTypeCustom.js +10 -0
  264. package/dist/enums/private/SerializationBrand.js +42 -0
  265. package/dist/enums/private/StageTravelState.js +13 -0
  266. package/dist/enums/private/TrapdoorAnimation.js +9 -0
  267. package/dist/enums/private/UIStreakAnimation.js +10 -0
  268. package/dist/features.js +150 -0
  269. package/dist/functions/ambush.js +26 -0
  270. package/dist/functions/array.js +586 -0
  271. package/dist/functions/arrayLua.js +81 -0
  272. package/dist/functions/benchmark.js +36 -0
  273. package/dist/functions/bitSet128.js +64 -0
  274. package/dist/functions/bitwise.js +82 -0
  275. package/dist/functions/bombs.js +14 -0
  276. package/dist/functions/bosses.js +238 -0
  277. package/dist/functions/cards.js +164 -0
  278. package/dist/functions/challenges.js +117 -0
  279. package/dist/functions/characters.js +182 -0
  280. package/dist/functions/charge.js +251 -0
  281. package/dist/functions/chargeBar.js +54 -0
  282. package/dist/functions/collectibleTag.js +24 -0
  283. package/dist/functions/collectibles.js +581 -0
  284. package/dist/functions/color.js +88 -0
  285. package/dist/functions/console.js +18 -0
  286. package/dist/functions/curses.js +37 -0
  287. package/dist/functions/debugFunctions.js +108 -0
  288. package/dist/functions/decorators.js +113 -0
  289. package/dist/functions/deepCopy.js +406 -0
  290. package/dist/functions/deepCopyTests.js +361 -0
  291. package/dist/functions/dimensions.js +30 -0
  292. package/dist/functions/direction.js +78 -0
  293. package/dist/functions/doors.js +524 -0
  294. package/dist/functions/easing.js +327 -0
  295. package/dist/functions/effects.js +14 -0
  296. package/dist/functions/emptyRoom.js +79 -0
  297. package/dist/functions/entities.js +529 -0
  298. package/dist/functions/entitiesSpecific.js +582 -0
  299. package/dist/functions/entityTypes.js +9 -0
  300. package/dist/functions/enums.js +244 -0
  301. package/dist/functions/external.js +59 -0
  302. package/dist/functions/familiars.js +136 -0
  303. package/dist/functions/flag.js +146 -0
  304. package/dist/functions/frames.js +166 -0
  305. package/dist/functions/globals.js +291 -0
  306. package/dist/functions/gridEntities.js +990 -0
  307. package/dist/functions/gridEntitiesSpecific.js +456 -0
  308. package/dist/functions/gridIndex.js +35 -0
  309. package/dist/functions/hash.js +75 -0
  310. package/dist/functions/hex.js +57 -0
  311. package/dist/functions/input.js +185 -0
  312. package/dist/functions/isaacAPIClass.js +157 -0
  313. package/dist/functions/itemPool.js +118 -0
  314. package/dist/functions/jsonHelpers.js +73 -0
  315. package/dist/functions/jsonRoom.js +184 -0
  316. package/dist/functions/kColor.js +89 -0
  317. package/dist/functions/language.js +16 -0
  318. package/dist/functions/level.js +66 -0
  319. package/dist/functions/levelGrid.js +497 -0
  320. package/dist/functions/log.js +86 -0
  321. package/dist/functions/logEntities.js +308 -0
  322. package/dist/functions/logMisc.js +510 -0
  323. package/dist/functions/map.js +121 -0
  324. package/dist/functions/math.js +149 -0
  325. package/dist/functions/merge.js +159 -0
  326. package/dist/functions/mergeTests.js +313 -0
  327. package/dist/functions/minimap.js +204 -0
  328. package/dist/functions/modFeatures.js +39 -0
  329. package/dist/functions/newArray.js +30 -0
  330. package/dist/functions/nextStage.js +169 -0
  331. package/dist/functions/npcDataStructures.js +146 -0
  332. package/dist/functions/npcs.js +132 -0
  333. package/dist/functions/pickupVariants.js +63 -0
  334. package/dist/functions/pickups.js +168 -0
  335. package/dist/functions/pickupsSpecific.js +376 -0
  336. package/dist/functions/pills.js +200 -0
  337. package/dist/functions/playerCenter.js +53 -0
  338. package/dist/functions/playerCollectibles.js +300 -0
  339. package/dist/functions/playerDataStructures.js +145 -0
  340. package/dist/functions/playerEffects.js +63 -0
  341. package/dist/functions/playerHealth.js +604 -0
  342. package/dist/functions/playerIndex.js +186 -0
  343. package/dist/functions/playerTrinkets.js +149 -0
  344. package/dist/functions/players.js +471 -0
  345. package/dist/functions/pocketItems.js +165 -0
  346. package/dist/functions/positionVelocity.js +158 -0
  347. package/dist/functions/pressurePlate.js +26 -0
  348. package/dist/functions/projectiles.js +57 -0
  349. package/dist/functions/random.js +90 -0
  350. package/dist/functions/readOnly.js +33 -0
  351. package/dist/functions/render.js +36 -0
  352. package/dist/functions/revive.js +151 -0
  353. package/dist/functions/rng.js +140 -0
  354. package/dist/functions/rockAlt.js +50 -0
  355. package/dist/functions/roomData.js +155 -0
  356. package/dist/functions/roomGrid.js +97 -0
  357. package/dist/functions/roomShape.js +143 -0
  358. package/dist/functions/roomShapeWalls.js +187 -0
  359. package/dist/functions/roomTransition.js +43 -0
  360. package/dist/functions/rooms.js +782 -0
  361. package/dist/functions/run.js +121 -0
  362. package/dist/functions/seeds.js +22 -0
  363. package/dist/functions/serialization.js +98 -0
  364. package/dist/functions/set.js +215 -0
  365. package/dist/functions/slots.js +41 -0
  366. package/dist/functions/sort.js +158 -0
  367. package/dist/functions/sound.js +45 -0
  368. package/dist/functions/spawnCollectible.js +112 -0
  369. package/dist/functions/sprites.js +130 -0
  370. package/dist/functions/stage.js +540 -0
  371. package/dist/functions/stats.js +104 -0
  372. package/dist/functions/storyBosses.js +63 -0
  373. package/dist/functions/string.js +194 -0
  374. package/dist/functions/table.js +162 -0
  375. package/dist/functions/tears.js +128 -0
  376. package/dist/functions/transformations.js +89 -0
  377. package/dist/functions/trinketGive.js +145 -0
  378. package/dist/functions/trinkets.js +213 -0
  379. package/dist/functions/tstlClass.js +97 -0
  380. package/dist/functions/types.js +225 -0
  381. package/dist/functions/ui.js +148 -0
  382. package/dist/functions/utils.d.ts +4 -1
  383. package/dist/functions/utils.d.ts.map +1 -1
  384. package/dist/functions/utils.js +195 -0
  385. package/dist/functions/utils.lua +6 -2
  386. package/dist/functions/vector.js +150 -0
  387. package/dist/functions/versusScreen.js +58 -0
  388. package/dist/functions/weighted.js +57 -0
  389. package/dist/index.js +219 -0
  390. package/dist/index.rollup.d.ts +4 -1
  391. package/dist/indexLua.js +220 -0
  392. package/dist/interfaces/ChargeBarSprites.js +2 -0
  393. package/dist/interfaces/Corner.js +2 -0
  394. package/dist/interfaces/CustomStageTSConfig.js +2 -0
  395. package/dist/interfaces/GridEntityCustomData.js +2 -0
  396. package/dist/interfaces/JSONRoomsFile.js +2 -0
  397. package/dist/interfaces/PlayerHealth.js +2 -0
  398. package/dist/interfaces/PlayerStats.js +4 -0
  399. package/dist/interfaces/PocketItemDescription.js +2 -0
  400. package/dist/interfaces/RoomDescription.js +2 -0
  401. package/dist/interfaces/SaveData.js +98 -0
  402. package/dist/interfaces/StageHistoryEntry.js +2 -0
  403. package/dist/interfaces/TSTLClassMetatable.js +2 -0
  404. package/dist/interfaces/TrinketSituation.js +2 -0
  405. package/dist/interfaces/private/AddCallbackParametersCustom.js +4 -0
  406. package/dist/interfaces/private/CustomStage.js +2 -0
  407. package/dist/interfaces/private/CustomTrapdoorDescription.js +2 -0
  408. package/dist/interfaces/private/ModUpgradedInterface.js +2 -0
  409. package/dist/isaacscript-common.lua +7 -3
  410. package/dist/maps/PHDPillConversionsMap.js +23 -0
  411. package/dist/maps/cardNameToTypeMap.js +211 -0
  412. package/dist/maps/characterNameToTypeMap.js +91 -0
  413. package/dist/maps/collectibleNameToTypeMap.js +19 -0
  414. package/dist/maps/defaultPlayerStatMap.js +17 -0
  415. package/dist/maps/entityTypeVariantToBossIDMap.js +11 -0
  416. package/dist/maps/falsePHDPillConversionsMap.js +37 -0
  417. package/dist/maps/gridEntityTypeToBrokenStateMap.js +32 -0
  418. package/dist/maps/gridEntityXMLMap.js +133 -0
  419. package/dist/maps/itemPoolTypeToItemPoolName.js +38 -0
  420. package/dist/maps/keyboardToStringMap.js +71 -0
  421. package/dist/maps/pillNameToEffectMap.js +91 -0
  422. package/dist/maps/roomNameToTypeMap.js +43 -0
  423. package/dist/maps/roomShapeToTopLeftWallGridIndexMap.js +17 -0
  424. package/dist/maps/transformationNameToPlayerFormMap.js +35 -0
  425. package/dist/maps/trinketNameToTypeMap.js +19 -0
  426. package/dist/objects/LRoomShapeToRectangles.js +43 -0
  427. package/dist/objects/backdropTypeToRockAltType.js +68 -0
  428. package/dist/objects/batteryNames.js +13 -0
  429. package/dist/objects/bombNames.js +17 -0
  430. package/dist/objects/bossIDToEntityTypeVariant.js +228 -0
  431. package/dist/objects/bossNamePNGFileNames.js +120 -0
  432. package/dist/objects/bossNames.js +119 -0
  433. package/dist/objects/bossPortraitPNGFileNames.js +123 -0
  434. package/dist/objects/cardDescriptions.js +106 -0
  435. package/dist/objects/cardNames.js +106 -0
  436. package/dist/objects/challengeBosses.js +60 -0
  437. package/dist/objects/challengeCharacters.js +58 -0
  438. package/dist/objects/challengeCollectibleTypes.js +255 -0
  439. package/dist/objects/challengeNames.js +54 -0
  440. package/dist/objects/challengeTrinketType.js +58 -0
  441. package/dist/objects/characterDamageMultipliers.js +49 -0
  442. package/dist/objects/characterNames.js +48 -0
  443. package/dist/objects/characterSpritePNGFileNames.js +50 -0
  444. package/dist/objects/characterStartingCollectibleTypes.js +105 -0
  445. package/dist/objects/characterStartingTrinketTypes.js +90 -0
  446. package/dist/objects/chestNames.js +20 -0
  447. package/dist/objects/coinNames.js +16 -0
  448. package/dist/objects/coinSubTypeToValue.js +15 -0
  449. package/dist/objects/collectibleDescriptions.js +742 -0
  450. package/dist/objects/collectibleNames.js +745 -0
  451. package/dist/objects/colors.js +26 -0
  452. package/dist/objects/directionNames.js +11 -0
  453. package/dist/objects/directionToDegrees.js +11 -0
  454. package/dist/objects/directionToMoveAction.js +11 -0
  455. package/dist/objects/directionToShootAction.js +11 -0
  456. package/dist/objects/directionToVector.js +13 -0
  457. package/dist/objects/doorSlotFlagToDoorSlot.js +15 -0
  458. package/dist/objects/doorSlotToDirection.js +15 -0
  459. package/dist/objects/doorSlotToDoorSlotFlag.js +15 -0
  460. package/dist/objects/gridEntityTypeToANM2Name.js +37 -0
  461. package/dist/objects/heartNames.js +21 -0
  462. package/dist/objects/isaacAPIClassTypeToBrand.js +12 -0
  463. package/dist/objects/isaacAPIClassTypeToFunctions.js +46 -0
  464. package/dist/objects/itemPoolTypeToCollectibleTypesSet.js +57 -0
  465. package/dist/objects/kColors.js +27 -0
  466. package/dist/objects/keyNames.js +13 -0
  467. package/dist/objects/languageNames.js +13 -0
  468. package/dist/objects/oppositeDoorSlots.js +15 -0
  469. package/dist/objects/pillEffectClasses.js +57 -0
  470. package/dist/objects/pillEffectNames.js +57 -0
  471. package/dist/objects/pillEffectTypeToPillEffects.js +23 -0
  472. package/dist/objects/pillEffectTypes.js +57 -0
  473. package/dist/objects/playerNamePNGFileNames.js +57 -0
  474. package/dist/objects/playerPortraitPNGFileNames.js +54 -0
  475. package/dist/objects/roomShapeBounds.js +48 -0
  476. package/dist/objects/roomShapeCorners.js +330 -0
  477. package/dist/objects/roomShapeLayoutSizes.js +41 -0
  478. package/dist/objects/roomShapeToBottomRightPosition.js +25 -0
  479. package/dist/objects/roomShapeToDoorSlotCoordinates.js +111 -0
  480. package/dist/objects/roomShapeToDoorSlots.js +72 -0
  481. package/dist/objects/roomShapeToDoorSlotsToGridIndexDelta.js +118 -0
  482. package/dist/objects/roomShapeToGridWidth.js +20 -0
  483. package/dist/objects/roomShapeToTopLeftPosition.js +26 -0
  484. package/dist/objects/roomShapeVolumes.js +32 -0
  485. package/dist/objects/roomTypeNames.js +35 -0
  486. package/dist/objects/roomTypeSpecialGotoPrefixes.js +35 -0
  487. package/dist/objects/sackNames.js +11 -0
  488. package/dist/objects/slotNames.js +26 -0
  489. package/dist/objects/stageIDNames.js +43 -0
  490. package/dist/objects/stageToMusic.js +91 -0
  491. package/dist/objects/stageToStageID.js +117 -0
  492. package/dist/objects/stageTypeSuffixes.js +14 -0
  493. package/dist/objects/transformationNames.js +20 -0
  494. package/dist/objects/trinketDescriptions.js +199 -0
  495. package/dist/objects/trinketNames.js +202 -0
  496. package/dist/objects/versusScreenBackgroundColors.js +46 -0
  497. package/dist/objects/versusScreenDirtSpotColors.js +46 -0
  498. package/dist/patchErrorFunctions.js +65 -0
  499. package/dist/serialization.js +21 -0
  500. package/dist/sets/LRoomShapesSet.js +11 -0
  501. package/dist/sets/bigRoomShapesSet.js +14 -0
  502. package/dist/sets/bossSets.js +465 -0
  503. package/dist/sets/charactersThatStartWithAnActiveItemSet.js +18 -0
  504. package/dist/sets/charactersWithBlackHeartFromEternalHeartSet.js +9 -0
  505. package/dist/sets/charactersWithFreeDevilDealsSet.js +6 -0
  506. package/dist/sets/charactersWithNoRedHeartsSet.js +19 -0
  507. package/dist/sets/charactersWithNoSoulHeartsSet.js +16 -0
  508. package/dist/sets/consoleCommandsSet.js +64 -0
  509. package/dist/sets/entitiesWithArmorSet.js +59 -0
  510. package/dist/sets/familiarsThatShootPlayerTearsSet.js +15 -0
  511. package/dist/sets/itemConfigCardTypesForCards.js +14 -0
  512. package/dist/sets/lostStyleCharactersSet.js +16 -0
  513. package/dist/sets/mineShaftRoomSubTypesSet.js +12 -0
  514. package/dist/sets/narrowRoomShapesSet.js +11 -0
  515. package/dist/sets/poopGridEntityXMLTypesSet.js +16 -0
  516. package/dist/sets/redHeartSubTypesSet.js +10 -0
  517. package/dist/sets/repentanceBossIDsSet.js +30 -0
  518. package/dist/sets/sinEntityTypesSet.js +14 -0
  519. package/dist/sets/singleUseActiveCollectibleTypesSet.js +15 -0
  520. package/dist/shaderCrashFix.js +24 -0
  521. package/dist/shouldFire.js +226 -0
  522. package/dist/types/AddSubtract.js +2 -0
  523. package/dist/types/AllButFirst.js +2 -0
  524. package/dist/types/AllButLast.js +2 -0
  525. package/dist/types/AnyClass.js +2 -0
  526. package/dist/types/AnyEntity.js +2 -0
  527. package/dist/types/AnyFunction.js +2 -0
  528. package/dist/types/AnyGridEntity.js +2 -0
  529. package/dist/types/CompositionTypeSatisfiesEnum.js +11 -0
  530. package/dist/types/ConversionHeartSubType.js +2 -0
  531. package/dist/types/Decrement.js +2 -0
  532. package/dist/types/ERange.js +2 -0
  533. package/dist/types/EntityID.js +2 -0
  534. package/dist/types/FunctionTuple.js +2 -0
  535. package/dist/types/GridEntityID.js +2 -0
  536. package/dist/types/HasFunction.js +2 -0
  537. package/dist/types/IRange.js +2 -0
  538. package/dist/types/Immutable.js +2 -0
  539. package/dist/types/Increment.js +2 -0
  540. package/dist/types/LowercaseKeys.js +2 -0
  541. package/dist/types/NaturalNumbersLessThan.js +2 -0
  542. package/dist/types/NaturalNumbersLessThanOrEqualTo.js +2 -0
  543. package/dist/types/PickingUpItem.js +44 -0
  544. package/dist/types/PickupIndex.js +2 -0
  545. package/dist/types/PlayerIndex.js +2 -0
  546. package/dist/types/PossibleStatType.js +2 -0
  547. package/dist/types/PublicInterface.js +2 -0
  548. package/dist/types/ReadonlyMap.js +6 -0
  549. package/dist/types/ReadonlyRecord.js +2 -0
  550. package/dist/types/ReadonlySet.js +6 -0
  551. package/dist/types/StartsWithLowercase.js +2 -0
  552. package/dist/types/StartsWithUppercase.js +2 -0
  553. package/dist/types/TSTLClass.js +2 -0
  554. package/dist/types/Tuple.js +2 -0
  555. package/dist/types/TupleKeys.js +2 -0
  556. package/dist/types/TupleToIntersection.js +2 -0
  557. package/dist/types/TupleToUnion.js +2 -0
  558. package/dist/types/TupleWithLengthBetween.js +22 -0
  559. package/dist/types/TupleWithMaxLength.js +27 -0
  560. package/dist/types/UnionToIntersection.js +2 -0
  561. package/dist/types/UppercaseKeys.js +2 -0
  562. package/dist/types/WeightedArray.js +2 -0
  563. package/dist/types/WidenLiteral.js +2 -0
  564. package/dist/types/Writable.js +2 -0
  565. package/dist/types/private/CallbackTuple.js +2 -0
  566. package/dist/types/private/ModUpgradedWithFeatures.js +2 -0
  567. package/package.json +1 -1
  568. package/src/functions/utils.ts +6 -2
@@ -0,0 +1,171 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DefaultMap = void 0;
4
+ const types_1 = require("../functions/types");
5
+ /**
6
+ * `DefaultMap` is a data structure that makes working with default values easier. It extends a
7
+ * `Map` and adds additional methods.
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 = () => [];
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
+ * - `getDefaultValue` - Returns the default value to be used for a new key. (If a factory function
80
+ * was provided during instantiation, this will execute the factory function.)
81
+ * - `getConstructorArg` - Helper method for cloning the map. Returns either the default value or
82
+ * the reference to the factory function.
83
+ */
84
+ class DefaultMap extends Map {
85
+ defaultValue;
86
+ defaultValueFactory;
87
+ /**
88
+ * See the main `DefaultMap` documentation:
89
+ * https://isaacscript.github.io/isaacscript-common/other/classes/DefaultMap
90
+ */
91
+ constructor(defaultValueOrFactoryFunction, initializerArray) {
92
+ const argIsPrimitive = (0, types_1.isPrimitive)(defaultValueOrFactoryFunction);
93
+ const argIsFunction = (0, types_1.isFunction)(defaultValueOrFactoryFunction);
94
+ if (!argIsPrimitive && !argIsFunction) {
95
+ error(`Failed to instantiate a DefaultMap since the provided default value was of type "${typeof defaultValueOrFactoryFunction}". 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.`);
96
+ }
97
+ super(initializerArray);
98
+ if (argIsFunction) {
99
+ this.defaultValue = undefined;
100
+ this.defaultValueFactory = defaultValueOrFactoryFunction;
101
+ }
102
+ else {
103
+ this.defaultValue = defaultValueOrFactoryFunction;
104
+ this.defaultValueFactory = undefined;
105
+ }
106
+ }
107
+ /**
108
+ * If the key exists, this will return the same thing as the normal `Map.get` method. Otherwise,
109
+ * it will set a default value for the provided key, and then return the default value.
110
+ *
111
+ * @allowEmptyVariadic
112
+ */
113
+ getAndSetDefault(key, ...args) {
114
+ const value = super.get(key);
115
+ if (value !== undefined) {
116
+ return value;
117
+ }
118
+ const defaultValue = this.getDefaultValue(...args);
119
+ this.set(key, defaultValue);
120
+ return defaultValue;
121
+ }
122
+ /**
123
+ * Returns the default value to be used for a new key. (If a factory function was provided during
124
+ * instantiation, this will execute the factory function.)
125
+ */
126
+ getDefaultValue(...args) {
127
+ if (this.defaultValue !== undefined) {
128
+ return this.defaultValue;
129
+ }
130
+ if (this.defaultValueFactory !== undefined) {
131
+ return this.defaultValueFactory(...args);
132
+ }
133
+ error("A DefaultMap was incorrectly instantiated.");
134
+ }
135
+ /**
136
+ * Helper method for cloning the map. Returns either the default value or a reference to the
137
+ * factory function.
138
+ */
139
+ getConstructorArg() {
140
+ if (this.defaultValue !== undefined) {
141
+ return this.defaultValue;
142
+ }
143
+ if (this.defaultValueFactory !== undefined) {
144
+ return this.defaultValueFactory;
145
+ }
146
+ error("A DefaultMap was incorrectly instantiated.");
147
+ }
148
+ }
149
+ exports.DefaultMap = DefaultMap;
150
+ /* eslint-disable @typescript-eslint/no-unused-vars */
151
+ function test() {
152
+ // Boolean
153
+ const myDefaultMapBoolean = new DefaultMap(false);
154
+ const myDefaultMapBooleanFactory = new DefaultMap(() => false);
155
+ const myDefaultMapBooleanWithoutParams = new DefaultMap(false);
156
+ // Number
157
+ const myDefaultMapNumber = new DefaultMap(123);
158
+ const myDefaultMapNumberFactory = new DefaultMap(() => 123);
159
+ const myDefaultMapNumberWithoutParams = new DefaultMap(123);
160
+ // String
161
+ const myDefaultMapString = new DefaultMap("foo");
162
+ const myDefaultMapStringFactory = new DefaultMap(() => "foo");
163
+ const myDefaultMapStringWithoutParams = new DefaultMap("foo");
164
+ // Array
165
+ const myDefaultMapArray = new DefaultMap(() => []);
166
+ const myDefaultMapArrayWithoutParams = new DefaultMap(() => []);
167
+ // Map
168
+ const myDefaultMapMap = new DefaultMap(() => new Map());
169
+ const myDefaultMapMapWithoutParams = new DefaultMap(() => new Map());
170
+ }
171
+ /* eslint-enable @typescript-eslint/no-unused-vars */
@@ -0,0 +1,244 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ModFeature = exports.MOD_FEATURE_CUSTOM_CALLBACKS_KEY = exports.MOD_FEATURE_CALLBACKS_KEY = void 0;
4
+ const array_1 = require("../functions/array");
5
+ const tstlClass_1 = require("../functions/tstlClass");
6
+ const types_1 = require("../functions/types");
7
+ const utils_1 = require("../functions/utils");
8
+ exports.MOD_FEATURE_CALLBACKS_KEY = "__callbacks";
9
+ exports.MOD_FEATURE_CUSTOM_CALLBACKS_KEY = "__customCallbacks";
10
+ const WRAPPED_CALLBACK_METHODS_KEY = "__wrappedCallbackMethods";
11
+ const WRAPPED_CUSTOM_CALLBACK_METHODS_KEY = "__wrappedCustomCallbacksMethods";
12
+ /**
13
+ * Helper class for mods that want to represent their individual features as classes. Extend your
14
+ * mod features from this class in order to enable the `@Callback` and `@CustomCallback` decorators
15
+ * that automatically subscribe to callbacks.
16
+ *
17
+ * It is recommended that you use the `initModFeatures` helper function to instantiate all of your
18
+ * mod classes (instead of instantiating them yourself). This is so that any attached `v` objects
19
+ * are properly registered with the save data manager; see below.
20
+ *
21
+ * If you are manually instantiating a mod feature yourself, then:
22
+ *
23
+ * - You must pass your upgraded mod as the first argument to the constructor.
24
+ * - In almost all cases, you will want the callback functions to be immediately subscribed after
25
+ * instantiating the class. However, if this is not the case, you can pass `false` as the optional
26
+ * second argument to the constructor.
27
+ *
28
+ * If your mod feature has a property called `v`, it will be assumed that these are variables that
29
+ * should be managed by the save data manager. Unfortunately, due to technical limitations with
30
+ * classes, this registration will only occur if you initialize the class with the `initModFeatures`
31
+ * helper function. (This is because the parent class does not have access to the child's properties
32
+ * upon first construction.)
33
+ */
34
+ class ModFeature {
35
+ mod;
36
+ /**
37
+ * An optional method that allows for conditional callback execution. If specified, any class
38
+ * method that is annotated with a `@Callback` or `@CallbackCustom` decorator will only be fired
39
+ * if the executed conditional function returns true.
40
+ *
41
+ * This property is used to easily turn entire mod features on and off (rather than repeating
42
+ * conditional logic and early returning at the beginning of every callback function).
43
+ *
44
+ * Since the specific information for the firing callback is passed as arguments into the
45
+ * conditional method, you can also write logic that would only apply to a specific type of
46
+ * callback.
47
+ *
48
+ * By default, this is set to null, which means that all callback methods will fire
49
+ * unconditionally. Override this property in your class if you need to use it.
50
+ *
51
+ * The function has the following signature:
52
+ *
53
+ * ```ts
54
+ * <T extends boolean>(
55
+ * vanilla: T, // Whether this is a vanilla or custom callback.
56
+ * modCallback: T extends true ? ModCallback : ModCallbackCustom,
57
+ * ...callbackArgs: unknown[] // This would be e.g. `pickup: EntityPickup` for the `POST_PICKUP_INIT` callback.
58
+ * ) => boolean;
59
+ * ```
60
+ */
61
+ shouldCallbackMethodsFire = null;
62
+ /**
63
+ * Whether the feature has registered its callbacks yet.
64
+ *
65
+ * This will almost always be equal to true unless you explicitly passed `false` to the second
66
+ * argument of the constructor.
67
+ */
68
+ initialized = false;
69
+ constructor(mod, init = true) {
70
+ this.mod = mod;
71
+ if (init) {
72
+ this.init();
73
+ }
74
+ }
75
+ /**
76
+ * Runs the `Mod.AddCallback` and `ModUpgraded.AddCallbackCustom` methods for all of the decorated
77
+ * callbacks. Also registers/unregisters the "v" variable on the save data manager.
78
+ *
79
+ * @param init Optional. Whether to initialize or uninitialize. Default is true.
80
+ */
81
+ init(init = true) {
82
+ if (this.initialized === init) {
83
+ return;
84
+ }
85
+ this.initialized = init;
86
+ const constructor = (0, tstlClass_1.getTSTLClassConstructor)(this);
87
+ (0, utils_1.assertDefined)(constructor, "Failed to get the TSTL class constructor for a mod feature.");
88
+ const tstlClassName = (0, tstlClass_1.getTSTLClassName)(this);
89
+ (0, utils_1.assertDefined)(tstlClassName, "Failed to get the TSTL class name for a mod feature.");
90
+ initDecoratedCallbacks(this, constructor, tstlClassName, true, init);
91
+ initDecoratedCallbacks(this, constructor, tstlClassName, false, init);
92
+ initSaveDataManager(this, tstlClassName, init);
93
+ }
94
+ /**
95
+ * Runs the `Mod.RemoveCallback` and `ModUpgraded.RemoveCallbackCustom` methods for all of the
96
+ * decorated callbacks.
97
+ *
98
+ * This is just an alias for `ModFeature.init(false)`.
99
+ */
100
+ uninit() {
101
+ this.init(false);
102
+ }
103
+ }
104
+ exports.ModFeature = ModFeature;
105
+ function initDecoratedCallbacks(modFeature, constructor, tstlClassName, vanilla, init) {
106
+ const modFeatureConstructor = constructor;
107
+ const callbackTuplesKey = vanilla
108
+ ? exports.MOD_FEATURE_CALLBACKS_KEY
109
+ : exports.MOD_FEATURE_CUSTOM_CALLBACKS_KEY;
110
+ const callbackTuples = modFeatureConstructor[callbackTuplesKey];
111
+ if (callbackTuples === undefined) {
112
+ return;
113
+ }
114
+ if (!(0, array_1.isArray)(callbackTuples)) {
115
+ error(`Failed to initialize/uninitialize the decorated callbacks on a mod feature since the callback arguments on the key of "${callbackTuplesKey}" was not an array and was instead of type: ${type(callbackTuples)}`);
116
+ }
117
+ for (const callbackTuple of callbackTuples) {
118
+ if (!(0, array_1.isArray)(callbackTuple)) {
119
+ error(`Failed to initialize/uninitialize the decorated callbacks on a mod feature since one of the callback arguments on the key of "${callbackTuplesKey}" was not an array and was instead of type: ${type(callbackTuple)}`);
120
+ }
121
+ const modCallback = callbackTuple[0];
122
+ if (!(0, types_1.isInteger)(modCallback)) {
123
+ error(`Failed to get the callback number from the callback tuple for class: ${tstlClassName}`);
124
+ }
125
+ const priority = callbackTuple[1];
126
+ if (!(0, types_1.isInteger)(priority)) {
127
+ error(`Failed to get the callback priority from the callback tuple for class: ${tstlClassName}`);
128
+ }
129
+ const callback = callbackTuple[2];
130
+ if (!(0, types_1.isFunction)(callback)) {
131
+ error(`Failed to get the callback function from the callback tuple for class: ${tstlClassName}`);
132
+ }
133
+ const parameters = callbackTuple[3];
134
+ // We must pass false as the second argument to `isArray` since the callback parameters may not
135
+ // necessarily be contiguous. (They might be separated by `undefined` values.)
136
+ if (!(0, array_1.isArray)(parameters, false)) {
137
+ error(`Failed to get the callback parameters from the callback tuple for class: ${tstlClassName}`);
138
+ }
139
+ // eslint-disable-next-line @typescript-eslint/dot-notation, @typescript-eslint/prefer-destructuring
140
+ const mod = modFeature["mod"];
141
+ if (init) {
142
+ addCallback(modFeature, modFeatureConstructor, mod, modCallback, // eslint-disable-line isaacscript/strict-enums
143
+ priority, callback, parameters, vanilla);
144
+ }
145
+ else {
146
+ removeCallback(modFeatureConstructor, mod, modCallback, // eslint-disable-line isaacscript/strict-enums
147
+ vanilla);
148
+ }
149
+ }
150
+ }
151
+ function addCallback(modFeature, modFeatureConstructor, mod, modCallback, priority, callback, // eslint-disable-line @typescript-eslint/ban-types
152
+ parameters, vanilla) {
153
+ // We need to wrap the callback in a new function so that we can explicitly pass the class as the
154
+ // first argument. (Otherwise, the method will not be able to properly access `this`.
155
+ const wrappedCallback = (...callbackArgs) => {
156
+ // eslint-disable-next-line @typescript-eslint/dot-notation
157
+ const conditionalFunc = modFeature["shouldCallbackMethodsFire"];
158
+ if (conditionalFunc !== null) {
159
+ const shouldRun = conditionalFunc(vanilla, modCallback, ...callbackArgs);
160
+ if (!shouldRun) {
161
+ return undefined;
162
+ }
163
+ }
164
+ const castedCallback = callback;
165
+ return castedCallback(modFeature, ...callbackArgs);
166
+ };
167
+ // We need to save the wrapped function for later (so we can unregister them).
168
+ if (vanilla) {
169
+ const modCallbackVanilla = modCallback;
170
+ let wrappedMethodsMap = modFeatureConstructor[WRAPPED_CALLBACK_METHODS_KEY];
171
+ if (wrappedMethodsMap === undefined) {
172
+ wrappedMethodsMap = new Map();
173
+ modFeatureConstructor[WRAPPED_CALLBACK_METHODS_KEY] = wrappedMethodsMap;
174
+ }
175
+ wrappedMethodsMap.set(modCallbackVanilla, wrappedCallback);
176
+ }
177
+ else {
178
+ const modCallbackCustom = modCallback;
179
+ let wrappedMethodsMap = modFeatureConstructor[WRAPPED_CUSTOM_CALLBACK_METHODS_KEY];
180
+ if (wrappedMethodsMap === undefined) {
181
+ wrappedMethodsMap = new Map();
182
+ modFeatureConstructor[WRAPPED_CUSTOM_CALLBACK_METHODS_KEY] =
183
+ wrappedMethodsMap;
184
+ }
185
+ wrappedMethodsMap.set(modCallbackCustom, wrappedCallback);
186
+ }
187
+ if (vanilla) {
188
+ mod.AddPriorityCallback(modCallback, priority, wrappedCallback, ...parameters);
189
+ }
190
+ else {
191
+ mod.AddPriorityCallbackCustom(modCallback, priority, wrappedCallback, ...parameters);
192
+ }
193
+ }
194
+ function removeCallback(modFeatureConstructor, mod, modCallback, vanilla) {
195
+ if (vanilla) {
196
+ const modCallbackVanilla = modCallback;
197
+ const wrappedMethodsMap = modFeatureConstructor[WRAPPED_CALLBACK_METHODS_KEY];
198
+ if (wrappedMethodsMap === undefined) {
199
+ return;
200
+ }
201
+ const wrappedCallback = wrappedMethodsMap.get(modCallbackVanilla);
202
+ mod.RemoveCallback(modCallback, wrappedCallback);
203
+ }
204
+ else {
205
+ const modCallbackCustom = modCallback;
206
+ const wrappedMethodsMap = modFeatureConstructor[WRAPPED_CUSTOM_CALLBACK_METHODS_KEY];
207
+ if (wrappedMethodsMap === undefined) {
208
+ return;
209
+ }
210
+ const wrappedCallback = wrappedMethodsMap.get(modCallbackCustom);
211
+ mod.RemoveCallbackCustom(modCallback, wrappedCallback);
212
+ }
213
+ }
214
+ /**
215
+ * This will only work for end-users who are calling the `ModFeature.init` method explicitly. (See
216
+ * the discussion in the `ModFeature` comment.)
217
+ */
218
+ function initSaveDataManager(modFeature, tstlClassName, init) {
219
+ // Do nothing if this class does not have any variables.
220
+ const { v } = modFeature;
221
+ if (v === undefined) {
222
+ return;
223
+ }
224
+ if (!(0, types_1.isTable)(v)) {
225
+ error('Failed to initialize a mod feature class due to having a "v" property that is not an object. (The "v" property is supposed to be an object that holds the variables for the class, managed by the save data manager.)');
226
+ }
227
+ // Do nothing if we have not enabled the save data manager.
228
+ // eslint-disable-next-line @typescript-eslint/dot-notation
229
+ const mod = modFeature["mod"];
230
+ const saveDataManagerMethodName = init
231
+ ? "saveDataManager"
232
+ : "saveDataManagerRemove";
233
+ const saveDataManagerMethod = mod[saveDataManagerMethodName];
234
+ (0, utils_1.assertDefined)(saveDataManagerMethod, 'Failed to initialize a mod feature class due to having a "v" object and not having the save data manager initialized. You must pass "ISCFeature.SAVE_DATA_MANAGER" to the "upgradeMod" function.');
235
+ if (typeof saveDataManagerMethod !== "function") {
236
+ error(`The "${saveDataManagerMethodName}" property of the "ModUpgraded" object was not a function.`);
237
+ }
238
+ if (init) {
239
+ saveDataManagerMethod(tstlClassName, v);
240
+ }
241
+ else {
242
+ saveDataManagerMethod(tstlClassName);
243
+ }
244
+ }