isaacscript-common 14.1.2 → 14.2.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 (494) hide show
  1. package/dist/index.d.ts +954 -158
  2. package/dist/isaacscript-common.lua +4099 -1066
  3. package/dist/src/callbacks.d.ts +102 -20
  4. package/dist/src/callbacks.d.ts.map +1 -1
  5. package/dist/src/callbacks.lua +124 -1
  6. package/dist/src/classes/ModFeature.d.ts +16 -4
  7. package/dist/src/classes/ModFeature.d.ts.map +1 -1
  8. package/dist/src/classes/ModFeature.lua +67 -4
  9. package/dist/src/classes/ModUpgraded.d.ts +10 -10
  10. package/dist/src/classes/ModUpgraded.d.ts.map +1 -1
  11. package/dist/src/classes/ModUpgraded.lua +35 -16
  12. package/dist/src/classes/callbacks/PostCustomRevive.d.ts +5 -2
  13. package/dist/src/classes/callbacks/PostCustomRevive.d.ts.map +1 -1
  14. package/dist/src/classes/callbacks/PostCustomRevive.lua +12 -4
  15. package/dist/src/classes/callbacks/PostGridEntityBroken.lua +1 -1
  16. package/dist/src/classes/callbacks/PostGridEntityCollision.lua +1 -1
  17. package/dist/src/classes/callbacks/PostGridEntityCustomBroken.lua +1 -1
  18. package/dist/src/classes/callbacks/PostGridEntityCustomCollision.lua +1 -1
  19. package/dist/src/classes/callbacks/PostGridEntityCustomInit.lua +1 -1
  20. package/dist/src/classes/callbacks/PostGridEntityCustomRemove.lua +1 -1
  21. package/dist/src/classes/callbacks/PostGridEntityCustomRender.d.ts +6 -0
  22. package/dist/src/classes/callbacks/PostGridEntityCustomRender.d.ts.map +1 -0
  23. package/dist/src/classes/callbacks/PostGridEntityCustomRender.lua +17 -0
  24. package/dist/src/classes/callbacks/PostGridEntityCustomStateChanged.lua +1 -1
  25. package/dist/src/classes/callbacks/PostGridEntityCustomUpdate.lua +1 -1
  26. package/dist/src/classes/callbacks/PostGridEntityInit.lua +1 -1
  27. package/dist/src/classes/callbacks/PostGridEntityRemove.lua +1 -1
  28. package/dist/src/classes/callbacks/PostGridEntityRender.d.ts +6 -0
  29. package/dist/src/classes/callbacks/PostGridEntityRender.d.ts.map +1 -0
  30. package/dist/src/classes/callbacks/PostGridEntityRender.lua +17 -0
  31. package/dist/src/classes/callbacks/PostGridEntityStateChanged.lua +1 -1
  32. package/dist/src/classes/callbacks/PostGridEntityUpdate.lua +1 -1
  33. package/dist/src/classes/callbacks/PostHolyMantleRemoved.d.ts +1 -1
  34. package/dist/src/classes/callbacks/PostHolyMantleRemoved.d.ts.map +1 -1
  35. package/dist/src/classes/callbacks/PostHolyMantleRemoved.lua +3 -4
  36. package/dist/src/classes/callbacks/PostItemDischarge.d.ts +43 -0
  37. package/dist/src/classes/callbacks/PostItemDischarge.d.ts.map +1 -0
  38. package/dist/src/classes/callbacks/PostItemDischarge.lua +113 -0
  39. package/dist/src/classes/callbacks/PostItemPickup.d.ts +6 -0
  40. package/dist/src/classes/callbacks/PostItemPickup.d.ts.map +1 -0
  41. package/dist/src/classes/callbacks/PostItemPickup.lua +17 -0
  42. package/dist/src/classes/callbacks/PostLaserInitLate.d.ts +12 -0
  43. package/dist/src/classes/callbacks/PostLaserInitLate.d.ts.map +1 -0
  44. package/dist/src/classes/callbacks/PostLaserInitLate.lua +27 -0
  45. package/dist/src/classes/callbacks/PostNPCInitLate.d.ts +12 -0
  46. package/dist/src/classes/callbacks/PostNPCInitLate.d.ts.map +1 -0
  47. package/dist/src/classes/callbacks/PostNPCInitLate.lua +27 -0
  48. package/dist/src/classes/callbacks/PostNPCStateChanged.d.ts +14 -0
  49. package/dist/src/classes/callbacks/PostNPCStateChanged.d.ts.map +1 -0
  50. package/dist/src/classes/callbacks/PostNPCStateChanged.lua +33 -0
  51. package/dist/src/classes/callbacks/PostPickupCollect.d.ts +12 -0
  52. package/dist/src/classes/callbacks/PostPickupCollect.d.ts.map +1 -0
  53. package/dist/src/classes/callbacks/PostPickupCollect.lua +35 -0
  54. package/dist/src/classes/callbacks/PostPickupInitFirst.d.ts +12 -0
  55. package/dist/src/classes/callbacks/PostPickupInitFirst.d.ts.map +1 -0
  56. package/dist/src/classes/callbacks/PostPickupInitFirst.lua +32 -0
  57. package/dist/src/classes/callbacks/PostPickupInitLate.d.ts +12 -0
  58. package/dist/src/classes/callbacks/PostPickupInitLate.d.ts.map +1 -0
  59. package/dist/src/classes/callbacks/PostPickupInitLate.lua +27 -0
  60. package/dist/src/classes/callbacks/PostPickupStateChanged.d.ts +13 -0
  61. package/dist/src/classes/callbacks/PostPickupStateChanged.d.ts.map +1 -0
  62. package/dist/src/classes/callbacks/PostPickupStateChanged.lua +33 -0
  63. package/dist/src/classes/callbacks/PostPitUpdate.d.ts +7 -0
  64. package/dist/src/classes/callbacks/PostPitUpdate.d.ts.map +1 -0
  65. package/dist/src/classes/callbacks/PostPitUpdate.lua +24 -0
  66. package/dist/src/classes/callbacks/PostPlayerChangeHealth.d.ts +15 -0
  67. package/dist/src/classes/callbacks/PostPlayerChangeHealth.d.ts.map +1 -0
  68. package/dist/src/classes/callbacks/PostPlayerChangeHealth.lua +52 -0
  69. package/dist/src/classes/callbacks/PostPlayerChangeStat.d.ts +16 -0
  70. package/dist/src/classes/callbacks/PostPlayerChangeStat.d.ts.map +1 -0
  71. package/dist/src/classes/callbacks/PostPlayerChangeStat.lua +94 -0
  72. package/dist/src/classes/callbacks/PostPlayerChangeType.d.ts +15 -0
  73. package/dist/src/classes/callbacks/PostPlayerChangeType.d.ts.map +1 -0
  74. package/dist/src/classes/callbacks/PostPlayerChangeType.lua +37 -0
  75. package/dist/src/classes/callbacks/PostPlayerCollectibleAdded.d.ts +6 -0
  76. package/dist/src/classes/callbacks/PostPlayerCollectibleAdded.d.ts.map +1 -0
  77. package/dist/src/classes/callbacks/PostPlayerCollectibleAdded.lua +17 -0
  78. package/dist/src/classes/callbacks/PostPlayerCollectibleRemoved.d.ts +6 -0
  79. package/dist/src/classes/callbacks/PostPlayerCollectibleRemoved.d.ts.map +1 -0
  80. package/dist/src/classes/callbacks/PostPlayerCollectibleRemoved.lua +17 -0
  81. package/dist/src/classes/callbacks/PostPlayerInitFirst.d.ts +8 -0
  82. package/dist/src/classes/callbacks/PostPlayerInitFirst.d.ts.map +1 -0
  83. package/dist/src/classes/callbacks/PostPlayerInitFirst.lua +39 -0
  84. package/dist/src/classes/callbacks/PostPlayerInitLate.d.ts +13 -0
  85. package/dist/src/classes/callbacks/PostPlayerInitLate.d.ts.map +1 -0
  86. package/dist/src/classes/callbacks/PostPlayerInitLate.lua +29 -0
  87. package/dist/src/classes/callbacks/PostPoopRender.d.ts +7 -0
  88. package/dist/src/classes/callbacks/PostPoopRender.d.ts.map +1 -0
  89. package/dist/src/classes/callbacks/PostPoopRender.lua +24 -0
  90. package/dist/src/classes/callbacks/PostPoopUpdate.d.ts +7 -0
  91. package/dist/src/classes/callbacks/PostPoopUpdate.d.ts.map +1 -0
  92. package/dist/src/classes/callbacks/PostPoopUpdate.lua +24 -0
  93. package/dist/src/classes/callbacks/PostPressurePlateRender.d.ts +7 -0
  94. package/dist/src/classes/callbacks/PostPressurePlateRender.d.ts.map +1 -0
  95. package/dist/src/classes/callbacks/PostPressurePlateRender.lua +24 -0
  96. package/dist/src/classes/callbacks/PostPressurePlateUpdate.d.ts +7 -0
  97. package/dist/src/classes/callbacks/PostPressurePlateUpdate.d.ts.map +1 -0
  98. package/dist/src/classes/callbacks/PostPressurePlateUpdate.lua +24 -0
  99. package/dist/src/classes/callbacks/PostProjectileInitLate.d.ts +12 -0
  100. package/dist/src/classes/callbacks/PostProjectileInitLate.d.ts.map +1 -0
  101. package/dist/src/classes/callbacks/PostProjectileInitLate.lua +27 -0
  102. package/dist/src/classes/callbacks/PostPurchase.d.ts +18 -0
  103. package/dist/src/classes/callbacks/PostPurchase.d.ts.map +1 -0
  104. package/dist/src/classes/callbacks/PostPurchase.lua +56 -0
  105. package/dist/src/classes/callbacks/PostRockRender.d.ts +7 -0
  106. package/dist/src/classes/callbacks/PostRockRender.d.ts.map +1 -0
  107. package/dist/src/classes/callbacks/PostRockRender.lua +24 -0
  108. package/dist/src/classes/callbacks/PostRockUpdate.d.ts +7 -0
  109. package/dist/src/classes/callbacks/PostRockUpdate.d.ts.map +1 -0
  110. package/dist/src/classes/callbacks/PostRockUpdate.lua +24 -0
  111. package/dist/src/classes/callbacks/PostSacrifice.d.ts +15 -0
  112. package/dist/src/classes/callbacks/PostSacrifice.d.ts.map +1 -0
  113. package/dist/src/classes/callbacks/PostSacrifice.lua +52 -0
  114. package/dist/src/classes/callbacks/PostSlotAnimationChanged.d.ts +6 -0
  115. package/dist/src/classes/callbacks/PostSlotAnimationChanged.d.ts.map +1 -0
  116. package/dist/src/classes/callbacks/PostSlotAnimationChanged.lua +17 -0
  117. package/dist/src/classes/callbacks/PostSlotCollision.d.ts +7 -0
  118. package/dist/src/classes/callbacks/PostSlotCollision.d.ts.map +1 -0
  119. package/dist/src/classes/callbacks/PostSlotCollision.lua +25 -0
  120. package/dist/src/classes/callbacks/PostSlotDestroyed.d.ts +14 -0
  121. package/dist/src/classes/callbacks/PostSlotDestroyed.d.ts.map +1 -0
  122. package/dist/src/classes/callbacks/PostSlotDestroyed.lua +65 -0
  123. package/dist/src/classes/callbacks/PostSlotInit.d.ts +6 -0
  124. package/dist/src/classes/callbacks/PostSlotInit.d.ts.map +1 -0
  125. package/dist/src/classes/callbacks/PostSlotInit.lua +17 -0
  126. package/dist/src/classes/callbacks/PostSlotRender.d.ts +6 -0
  127. package/dist/src/classes/callbacks/PostSlotRender.d.ts.map +1 -0
  128. package/dist/src/classes/callbacks/PostSlotRender.lua +17 -0
  129. package/dist/src/classes/callbacks/PostSlotUpdate.d.ts +6 -0
  130. package/dist/src/classes/callbacks/PostSlotUpdate.d.ts.map +1 -0
  131. package/dist/src/classes/callbacks/PostSlotUpdate.lua +17 -0
  132. package/dist/src/classes/callbacks/PostSpikesUpdate.d.ts +7 -0
  133. package/dist/src/classes/callbacks/PostSpikesUpdate.d.ts.map +1 -0
  134. package/dist/src/classes/callbacks/PostSpikesUpdate.lua +24 -0
  135. package/dist/src/classes/callbacks/PostTNTRender.d.ts +7 -0
  136. package/dist/src/classes/callbacks/PostTNTRender.d.ts.map +1 -0
  137. package/dist/src/classes/callbacks/PostTNTRender.lua +24 -0
  138. package/dist/src/classes/callbacks/PostTNTUpdate.d.ts +7 -0
  139. package/dist/src/classes/callbacks/PostTNTUpdate.d.ts.map +1 -0
  140. package/dist/src/classes/callbacks/PostTNTUpdate.lua +24 -0
  141. package/dist/src/classes/callbacks/PostTearInitLate.d.ts +12 -0
  142. package/dist/src/classes/callbacks/PostTearInitLate.d.ts.map +1 -0
  143. package/dist/src/classes/callbacks/PostTearInitLate.lua +27 -0
  144. package/dist/src/classes/callbacks/PostTearInitVeryLate.d.ts +12 -0
  145. package/dist/src/classes/callbacks/PostTearInitVeryLate.d.ts.map +1 -0
  146. package/dist/src/classes/callbacks/PostTearInitVeryLate.lua +30 -0
  147. package/dist/src/classes/callbacks/PostTransformation.d.ts +18 -0
  148. package/dist/src/classes/callbacks/PostTransformation.d.ts.map +1 -0
  149. package/dist/src/classes/callbacks/PostTransformation.lua +53 -0
  150. package/dist/src/classes/callbacks/PreBerserkDeath.d.ts +1 -1
  151. package/dist/src/classes/callbacks/PreBerserkDeath.d.ts.map +1 -1
  152. package/dist/src/classes/callbacks/PreBerserkDeath.lua +3 -4
  153. package/dist/src/classes/callbacks/PreItemPickup.d.ts +6 -0
  154. package/dist/src/classes/callbacks/PreItemPickup.d.ts.map +1 -0
  155. package/dist/src/classes/callbacks/PreItemPickup.lua +17 -0
  156. package/dist/src/classes/callbacks/validation/CustomCallbackCollectibleType.d.ts +10 -0
  157. package/dist/src/classes/callbacks/validation/CustomCallbackCollectibleType.d.ts.map +1 -0
  158. package/dist/src/classes/callbacks/validation/CustomCallbackCollectibleType.lua +19 -0
  159. package/dist/src/classes/callbacks/validation/CustomCallbackItemPickup.d.ts +11 -0
  160. package/dist/src/classes/callbacks/validation/CustomCallbackItemPickup.d.ts.map +1 -0
  161. package/dist/src/classes/callbacks/validation/CustomCallbackItemPickup.lua +22 -0
  162. package/dist/src/classes/callbacks/validation/CustomCallbackLaser.d.ts +10 -0
  163. package/dist/src/classes/callbacks/validation/CustomCallbackLaser.d.ts.map +1 -0
  164. package/dist/src/classes/callbacks/validation/CustomCallbackLaser.lua +19 -0
  165. package/dist/src/classes/callbacks/validation/{CustomCallbackRevive.d.ts → CustomCallbackNPC.d.ts} +4 -4
  166. package/dist/src/classes/callbacks/validation/CustomCallbackNPC.d.ts.map +1 -0
  167. package/dist/src/classes/callbacks/validation/CustomCallbackNPC.lua +22 -0
  168. package/dist/src/classes/callbacks/validation/CustomCallbackPickup.d.ts +12 -0
  169. package/dist/src/classes/callbacks/validation/CustomCallbackPickup.d.ts.map +1 -0
  170. package/dist/src/classes/callbacks/validation/CustomCallbackPickup.lua +22 -0
  171. package/dist/src/classes/callbacks/validation/CustomCallbackPlayer.d.ts +5 -2
  172. package/dist/src/classes/callbacks/validation/CustomCallbackPlayer.d.ts.map +1 -1
  173. package/dist/src/classes/callbacks/validation/CustomCallbackPoop.d.ts +10 -0
  174. package/dist/src/classes/callbacks/validation/CustomCallbackPoop.d.ts.map +1 -0
  175. package/dist/src/classes/callbacks/validation/CustomCallbackPoop.lua +20 -0
  176. package/dist/src/classes/callbacks/validation/CustomCallbackPressurePlate.d.ts +10 -0
  177. package/dist/src/classes/callbacks/validation/CustomCallbackPressurePlate.d.ts.map +1 -0
  178. package/dist/src/classes/callbacks/validation/CustomCallbackPressurePlate.lua +20 -0
  179. package/dist/src/classes/callbacks/validation/CustomCallbackProjectile.d.ts +10 -0
  180. package/dist/src/classes/callbacks/validation/CustomCallbackProjectile.d.ts.map +1 -0
  181. package/dist/src/classes/callbacks/validation/CustomCallbackProjectile.lua +19 -0
  182. package/dist/src/classes/callbacks/validation/CustomCallbackRock.d.ts +10 -0
  183. package/dist/src/classes/callbacks/validation/CustomCallbackRock.d.ts.map +1 -0
  184. package/dist/src/classes/callbacks/validation/CustomCallbackRock.lua +20 -0
  185. package/dist/src/classes/callbacks/validation/CustomCallbackSlot.d.ts +12 -0
  186. package/dist/src/classes/callbacks/validation/CustomCallbackSlot.d.ts.map +1 -0
  187. package/dist/src/classes/callbacks/validation/CustomCallbackSlot.lua +19 -0
  188. package/dist/src/classes/callbacks/validation/CustomCallbackSpikes.lua +4 -4
  189. package/dist/src/classes/callbacks/validation/CustomCallbackTNT.d.ts +10 -0
  190. package/dist/src/classes/callbacks/validation/CustomCallbackTNT.d.ts.map +1 -0
  191. package/dist/src/classes/callbacks/validation/CustomCallbackTNT.lua +20 -0
  192. package/dist/src/classes/callbacks/validation/CustomCallbackTear.d.ts +10 -0
  193. package/dist/src/classes/callbacks/validation/CustomCallbackTear.d.ts.map +1 -0
  194. package/dist/src/classes/callbacks/validation/CustomCallbackTear.lua +19 -0
  195. package/dist/src/classes/features/callbackLogic/CustomGridEntities.d.ts +1 -1
  196. package/dist/src/classes/features/callbackLogic/CustomGridEntities.d.ts.map +1 -1
  197. package/dist/src/classes/features/callbackLogic/CustomGridEntities.lua +27 -30
  198. package/dist/src/classes/features/callbackLogic/CustomRevive.d.ts +2 -2
  199. package/dist/src/classes/features/callbackLogic/CustomRevive.d.ts.map +1 -1
  200. package/dist/src/classes/features/callbackLogic/CustomRevive.lua +6 -6
  201. package/dist/src/classes/features/callbackLogic/EsauJrDetection.d.ts.map +1 -1
  202. package/dist/src/classes/features/callbackLogic/GameReorderedCallbacks.d.ts.map +1 -1
  203. package/dist/src/classes/features/callbackLogic/GameReorderedCallbacks.lua +3 -18
  204. package/dist/src/classes/features/callbackLogic/GridEntityCollisionDetection.d.ts.map +1 -1
  205. package/dist/src/classes/features/callbackLogic/GridEntityRenderDetection.d.ts +12 -0
  206. package/dist/src/classes/features/callbackLogic/GridEntityRenderDetection.d.ts.map +1 -0
  207. package/dist/src/classes/features/callbackLogic/GridEntityRenderDetection.lua +33 -0
  208. package/dist/src/classes/features/callbackLogic/{GridEntityDetection.d.ts → GridEntityUpdateDetection.d.ts} +3 -3
  209. package/dist/src/classes/features/callbackLogic/GridEntityUpdateDetection.d.ts.map +1 -0
  210. package/dist/src/classes/features/callbackLogic/{GridEntityDetection.lua → GridEntityUpdateDetection.lua} +11 -14
  211. package/dist/src/classes/features/callbackLogic/ItemPickupDetection.d.ts +20 -0
  212. package/dist/src/classes/features/callbackLogic/ItemPickupDetection.d.ts.map +1 -0
  213. package/dist/src/classes/features/callbackLogic/ItemPickupDetection.lua +60 -0
  214. package/dist/src/classes/features/callbackLogic/PlayerCollectibleDetection.d.ts +47 -0
  215. package/dist/src/classes/features/callbackLogic/PlayerCollectibleDetection.d.ts.map +1 -0
  216. package/dist/src/classes/features/callbackLogic/PlayerCollectibleDetection.lua +154 -0
  217. package/dist/src/classes/features/callbackLogic/SlotRenderDetection.d.ts +18 -0
  218. package/dist/src/classes/features/callbackLogic/SlotRenderDetection.d.ts.map +1 -0
  219. package/dist/src/classes/features/callbackLogic/SlotRenderDetection.lua +51 -0
  220. package/dist/src/classes/features/callbackLogic/SlotUpdateDetection.d.ts +17 -0
  221. package/dist/src/classes/features/callbackLogic/SlotUpdateDetection.d.ts.map +1 -0
  222. package/dist/src/classes/features/callbackLogic/SlotUpdateDetection.lua +45 -0
  223. package/dist/src/classes/features/other/RunInNFrames.d.ts.map +1 -1
  224. package/dist/src/classes/features/other/RunInNFrames.lua +9 -0
  225. package/dist/src/classes/features/other/SaveDataManager.d.ts +215 -0
  226. package/dist/src/classes/features/other/SaveDataManager.d.ts.map +1 -0
  227. package/dist/src/classes/features/other/SaveDataManager.lua +190 -0
  228. package/dist/src/classes/features/other/saveDataManager/glowingHourGlass.d.ts +6 -0
  229. package/dist/src/classes/features/other/saveDataManager/glowingHourGlass.d.ts.map +1 -0
  230. package/dist/src/classes/features/other/saveDataManager/glowingHourGlass.lua +98 -0
  231. package/dist/src/classes/features/other/saveDataManager/loadFromDisk.d.ts +6 -0
  232. package/dist/src/classes/features/other/saveDataManager/loadFromDisk.d.ts.map +1 -0
  233. package/dist/src/classes/features/other/saveDataManager/loadFromDisk.lua +81 -0
  234. package/dist/src/classes/features/other/saveDataManager/restoreDefaults.d.ts +7 -0
  235. package/dist/src/classes/features/other/saveDataManager/restoreDefaults.d.ts.map +1 -0
  236. package/dist/src/classes/features/other/saveDataManager/restoreDefaults.lua +69 -0
  237. package/dist/src/classes/features/other/saveDataManager/saveToDisk.d.ts +5 -0
  238. package/dist/src/classes/features/other/saveDataManager/saveToDisk.d.ts.map +1 -0
  239. package/dist/src/classes/features/other/saveDataManager/saveToDisk.lua +46 -0
  240. package/dist/src/classes/private/CustomCallback.d.ts +2 -3
  241. package/dist/src/classes/private/CustomCallback.d.ts.map +1 -1
  242. package/dist/src/classes/private/CustomCallback.lua +2 -5
  243. package/dist/src/classes/private/Feature.d.ts +1 -0
  244. package/dist/src/classes/private/Feature.d.ts.map +1 -1
  245. package/dist/src/classes/private/Feature.lua +1 -0
  246. package/dist/src/core/upgradeMod.d.ts +2 -5
  247. package/dist/src/core/upgradeMod.d.ts.map +1 -1
  248. package/dist/src/decorators.d.ts +1 -1
  249. package/dist/src/decorators.d.ts.map +1 -1
  250. package/dist/src/decorators.lua +6 -8
  251. package/dist/src/enums/ISCFeature.d.ts +15 -9
  252. package/dist/src/enums/ISCFeature.d.ts.map +1 -1
  253. package/dist/src/enums/ISCFeature.lua +30 -9
  254. package/dist/src/enums/ModCallbackCustom.d.ts +34 -20
  255. package/dist/src/enums/ModCallbackCustom.d.ts.map +1 -1
  256. package/dist/src/enums/ModCallbackCustom2.d.ts +61 -20
  257. package/dist/src/enums/ModCallbackCustom2.d.ts.map +1 -1
  258. package/dist/src/enums/ModCallbackCustom2.lua +102 -20
  259. package/dist/src/enums/{private/SerializationBrand.d.ts → SerializationBrand.d.ts} +6 -1
  260. package/dist/src/enums/SerializationBrand.d.ts.map +1 -0
  261. package/dist/src/enums/{private/SerializationBrand.lua → SerializationBrand.lua} +1 -0
  262. package/dist/src/features/customItemPool.d.ts +52 -0
  263. package/dist/src/features/customItemPool.d.ts.map +1 -0
  264. package/dist/src/features/customItemPool.lua +111 -0
  265. package/dist/src/features/deployJSONRoom.d.ts +6 -4
  266. package/dist/src/features/deployJSONRoom.d.ts.map +1 -1
  267. package/dist/src/features/deployJSONRoom.lua +6 -4
  268. package/dist/src/features/fadeInRemover.d.ts.map +1 -1
  269. package/dist/src/features/fadeInRemover.lua +4 -16
  270. package/dist/src/features/saveDataManager/exports.d.ts +14 -4
  271. package/dist/src/features/saveDataManager/exports.d.ts.map +1 -1
  272. package/dist/src/features/saveDataManager/exports.lua +38 -0
  273. package/dist/src/features/saveDataManager/load.d.ts +2 -1
  274. package/dist/src/features/saveDataManager/load.d.ts.map +1 -1
  275. package/dist/src/features/saveDataManager/load.lua +10 -4
  276. package/dist/src/features/saveDataManager/main.d.ts.map +1 -1
  277. package/dist/src/features/saveDataManager/main.lua +12 -5
  278. package/dist/src/features/saveDataManager/maps.d.ts +14 -0
  279. package/dist/src/features/saveDataManager/maps.d.ts.map +1 -1
  280. package/dist/src/features/saveDataManager/maps.lua +7 -0
  281. package/dist/src/features.d.ts +31 -12
  282. package/dist/src/features.d.ts.map +1 -1
  283. package/dist/src/features.lua +24 -6
  284. package/dist/src/functions/array.d.ts.map +1 -1
  285. package/dist/src/functions/array.lua +4 -5
  286. package/dist/src/functions/bitSet128.d.ts +2 -2
  287. package/dist/src/functions/bitSet128.lua +3 -3
  288. package/dist/src/functions/color.d.ts +2 -2
  289. package/dist/src/functions/color.lua +3 -3
  290. package/dist/src/functions/decorators.d.ts +28 -6
  291. package/dist/src/functions/decorators.d.ts.map +1 -1
  292. package/dist/src/functions/decorators.lua +24 -5
  293. package/dist/src/functions/deepCopy.d.ts +11 -4
  294. package/dist/src/functions/deepCopy.d.ts.map +1 -1
  295. package/dist/src/functions/deepCopy.lua +84 -32
  296. package/dist/src/functions/deepCopyTests.lua +1 -1
  297. package/dist/src/functions/initArray.d.ts +4 -4
  298. package/dist/src/functions/initArray.d.ts.map +1 -1
  299. package/dist/src/functions/initArray.lua +6 -12
  300. package/dist/src/functions/jsonRoom.d.ts +11 -0
  301. package/dist/src/functions/jsonRoom.d.ts.map +1 -1
  302. package/dist/src/functions/jsonRoom.lua +11 -0
  303. package/dist/src/functions/kColor.d.ts +2 -2
  304. package/dist/src/functions/kColor.lua +3 -3
  305. package/dist/src/functions/logMisc.d.ts +9 -2
  306. package/dist/src/functions/logMisc.d.ts.map +1 -1
  307. package/dist/src/functions/logMisc.lua +32 -2
  308. package/dist/src/functions/merge.d.ts +40 -0
  309. package/dist/src/functions/merge.d.ts.map +1 -0
  310. package/dist/src/{features/saveDataManager → functions}/merge.lua +84 -37
  311. package/dist/src/functions/mergeTests.d.ts +1 -2
  312. package/dist/src/functions/mergeTests.d.ts.map +1 -1
  313. package/dist/src/functions/mergeTests.lua +3 -4
  314. package/dist/src/functions/rng.d.ts +2 -2
  315. package/dist/src/functions/rng.lua +3 -3
  316. package/dist/src/functions/serialization.d.ts.map +1 -1
  317. package/dist/src/functions/serialization.lua +22 -0
  318. package/dist/src/functions/tstlClass.d.ts +0 -10
  319. package/dist/src/functions/tstlClass.d.ts.map +1 -1
  320. package/dist/src/functions/tstlClass.lua +2 -42
  321. package/dist/src/functions/vector.d.ts +2 -2
  322. package/dist/src/functions/vector.lua +3 -3
  323. package/dist/src/functions/weighted.d.ts +12 -1
  324. package/dist/src/functions/weighted.d.ts.map +1 -1
  325. package/dist/src/functions/weighted.lua +27 -10
  326. package/dist/src/index.d.ts +5 -0
  327. package/dist/src/index.d.ts.map +1 -1
  328. package/dist/src/index.lua +24 -0
  329. package/dist/src/interfaces/SaveData.d.ts +3 -7
  330. package/dist/src/interfaces/SaveData.d.ts.map +1 -1
  331. package/dist/src/interfaces/SaveData.lua +0 -11
  332. package/dist/src/interfaces/private/AddCallbackParametersCustom2.d.ts +195 -2
  333. package/dist/src/interfaces/private/AddCallbackParametersCustom2.d.ts.map +1 -1
  334. package/dist/src/objects/isaacAPIClassTypeToBrand.d.ts +1 -1
  335. package/dist/src/objects/isaacAPIClassTypeToBrand.d.ts.map +1 -1
  336. package/dist/src/objects/isaacAPIClassTypeToBrand.lua +1 -1
  337. package/dist/src/types/AnyClass.d.ts +2 -0
  338. package/dist/src/types/AnyClass.d.ts.map +1 -0
  339. package/dist/src/types/AnyClass.lua +2 -0
  340. package/dist/src/types/AnyFunction.d.ts +6 -0
  341. package/dist/src/types/AnyFunction.d.ts.map +1 -0
  342. package/dist/src/types/AnyFunction.lua +2 -0
  343. package/dist/src/types/FunctionTuple.d.ts +2 -4
  344. package/dist/src/types/FunctionTuple.d.ts.map +1 -1
  345. package/dist/src/types/HasFunction.d.ts +5 -0
  346. package/dist/src/types/HasFunction.d.ts.map +1 -0
  347. package/dist/src/types/HasFunction.lua +2 -0
  348. package/package.json +1 -1
  349. package/src/callbacks.ts +88 -5
  350. package/src/classes/ModFeature.ts +96 -6
  351. package/src/classes/ModUpgraded.ts +57 -32
  352. package/src/classes/callbacks/PostCustomRevive.ts +22 -2
  353. package/src/classes/callbacks/PostGridEntityBroken.ts +1 -1
  354. package/src/classes/callbacks/PostGridEntityCollision.ts +1 -1
  355. package/src/classes/callbacks/PostGridEntityCustomBroken.ts +1 -1
  356. package/src/classes/callbacks/PostGridEntityCustomCollision.ts +1 -1
  357. package/src/classes/callbacks/PostGridEntityCustomInit.ts +1 -1
  358. package/src/classes/callbacks/PostGridEntityCustomRemove.ts +1 -1
  359. package/src/classes/callbacks/PostGridEntityCustomRender.ts +11 -0
  360. package/src/classes/callbacks/PostGridEntityCustomStateChanged.ts +1 -1
  361. package/src/classes/callbacks/PostGridEntityCustomUpdate.ts +1 -1
  362. package/src/classes/callbacks/PostGridEntityInit.ts +1 -1
  363. package/src/classes/callbacks/PostGridEntityRemove.ts +1 -1
  364. package/src/classes/callbacks/PostGridEntityRender.ts +11 -0
  365. package/src/classes/callbacks/PostGridEntityStateChanged.ts +1 -1
  366. package/src/classes/callbacks/PostGridEntityUpdate.ts +1 -1
  367. package/src/classes/callbacks/PostHolyMantleRemoved.ts +5 -8
  368. package/src/classes/callbacks/PostItemDischarge.ts +181 -0
  369. package/src/classes/callbacks/PostItemPickup.ts +11 -0
  370. package/src/classes/callbacks/PostLaserInitLate.ts +28 -0
  371. package/src/classes/callbacks/PostNPCInitLate.ts +28 -0
  372. package/src/classes/callbacks/PostNPCStateChanged.ts +37 -0
  373. package/src/classes/callbacks/PostPickupCollect.ts +37 -0
  374. package/src/classes/callbacks/PostPickupInitFirst.ts +34 -0
  375. package/src/classes/callbacks/PostPickupInitLate.ts +28 -0
  376. package/src/classes/callbacks/PostPickupStateChanged.ts +35 -0
  377. package/src/classes/callbacks/PostPitUpdate.ts +21 -0
  378. package/src/classes/callbacks/PostPlayerChangeHealth.ts +57 -0
  379. package/src/classes/callbacks/PostPlayerChangeStat.ts +102 -0
  380. package/src/classes/callbacks/PostPlayerChangeType.ts +44 -0
  381. package/src/classes/callbacks/PostPlayerCollectibleAdded.ts +11 -0
  382. package/src/classes/callbacks/PostPlayerCollectibleRemoved.ts +11 -0
  383. package/src/classes/callbacks/PostPlayerInitFirst.ts +44 -0
  384. package/src/classes/callbacks/PostPlayerInitLate.ts +32 -0
  385. package/src/classes/callbacks/PostPoopRender.ts +21 -0
  386. package/src/classes/callbacks/PostPoopUpdate.ts +21 -0
  387. package/src/classes/callbacks/PostPressurePlateRender.ts +21 -0
  388. package/src/classes/callbacks/PostPressurePlateUpdate.ts +21 -0
  389. package/src/classes/callbacks/PostProjectileInitLate.ts +28 -0
  390. package/src/classes/callbacks/PostPurchase.ts +87 -0
  391. package/src/classes/callbacks/PostRockRender.ts +21 -0
  392. package/src/classes/callbacks/PostRockUpdate.ts +21 -0
  393. package/src/classes/callbacks/PostSacrifice.ts +89 -0
  394. package/src/classes/callbacks/PostSlotAnimationChanged.ts +11 -0
  395. package/src/classes/callbacks/PostSlotCollision.ts +26 -0
  396. package/src/classes/callbacks/PostSlotDestroyed.ts +79 -0
  397. package/src/classes/callbacks/PostSlotInit.ts +11 -0
  398. package/src/classes/callbacks/PostSlotRender.ts +11 -0
  399. package/src/classes/callbacks/PostSlotUpdate.ts +11 -0
  400. package/src/classes/callbacks/PostSpikesUpdate.ts +21 -0
  401. package/src/classes/callbacks/PostTNTRender.ts +21 -0
  402. package/src/classes/callbacks/PostTNTUpdate.ts +21 -0
  403. package/src/classes/callbacks/PostTearInitLate.ts +28 -0
  404. package/src/classes/callbacks/PostTearInitVeryLate.ts +33 -0
  405. package/src/classes/callbacks/PostTransformation.ts +71 -0
  406. package/src/classes/callbacks/PreBerserkDeath.ts +5 -8
  407. package/src/classes/callbacks/PreItemPickup.ts +11 -0
  408. package/src/classes/callbacks/validation/CustomCallbackCollectibleType.ts +32 -0
  409. package/src/classes/callbacks/validation/CustomCallbackItemPickup.ts +48 -0
  410. package/src/classes/callbacks/validation/CustomCallbackLaser.ts +27 -0
  411. package/src/classes/callbacks/validation/CustomCallbackNPC.ts +34 -0
  412. package/src/classes/callbacks/validation/CustomCallbackPickup.ts +41 -0
  413. package/src/classes/callbacks/validation/CustomCallbackPlayer.ts +25 -2
  414. package/src/classes/callbacks/validation/CustomCallbackPoop.ts +28 -0
  415. package/src/classes/callbacks/validation/CustomCallbackPressurePlate.ts +31 -0
  416. package/src/classes/callbacks/validation/CustomCallbackProjectile.ts +28 -0
  417. package/src/classes/callbacks/validation/CustomCallbackRock.ts +30 -0
  418. package/src/classes/callbacks/validation/CustomCallbackSlot.ts +37 -0
  419. package/src/classes/callbacks/validation/CustomCallbackSpikes.ts +4 -4
  420. package/src/classes/callbacks/validation/CustomCallbackTNT.ts +28 -0
  421. package/src/classes/callbacks/validation/CustomCallbackTear.ts +27 -0
  422. package/src/classes/features/callbackLogic/CustomGridEntities.ts +32 -36
  423. package/src/classes/features/callbackLogic/CustomRevive.ts +14 -21
  424. package/src/classes/features/callbackLogic/EsauJrDetection.ts +0 -4
  425. package/src/classes/features/callbackLogic/GameReorderedCallbacks.ts +7 -9
  426. package/src/classes/features/callbackLogic/GridEntityCollisionDetection.ts +0 -4
  427. package/src/classes/features/callbackLogic/GridEntityRenderDetection.ts +42 -0
  428. package/src/classes/features/callbackLogic/{GridEntityDetection.ts → GridEntityUpdateDetection.ts} +4 -20
  429. package/src/classes/features/callbackLogic/ItemPickupDetection.ts +91 -0
  430. package/src/classes/features/callbackLogic/PlayerCollectibleDetection.ts +245 -0
  431. package/src/classes/features/callbackLogic/SlotRenderDetection.ts +64 -0
  432. package/src/classes/features/callbackLogic/SlotUpdateDetection.ts +57 -0
  433. package/src/classes/features/other/RunInNFrames.ts +7 -0
  434. package/src/classes/features/other/SaveDataManager.ts +492 -0
  435. package/src/classes/features/other/saveDataManager/glowingHourGlass.ts +138 -0
  436. package/src/classes/features/other/saveDataManager/loadFromDisk.ts +99 -0
  437. package/src/classes/features/other/saveDataManager/restoreDefaults.ts +116 -0
  438. package/src/classes/features/other/saveDataManager/saveToDisk.ts +70 -0
  439. package/src/classes/private/CustomCallback.ts +2 -6
  440. package/src/classes/private/Feature.ts +1 -0
  441. package/src/core/upgradeMod.ts +6 -13
  442. package/src/decorators.ts +17 -16
  443. package/src/enums/ISCFeature.ts +44 -39
  444. package/src/enums/ModCallbackCustom.ts +34 -20
  445. package/src/enums/ModCallbackCustom2.ts +53 -5
  446. package/src/enums/{private/SerializationBrand.ts → SerializationBrand.ts} +8 -2
  447. package/src/features/customItemPool.ts +133 -0
  448. package/src/features/deployJSONRoom.ts +6 -4
  449. package/src/features/fadeInRemover.ts +4 -22
  450. package/src/features/saveDataManager/exports.ts +62 -3
  451. package/src/features/saveDataManager/load.ts +4 -1
  452. package/src/features/saveDataManager/main.ts +5 -3
  453. package/src/features/saveDataManager/maps.ts +16 -0
  454. package/src/features.ts +39 -4
  455. package/src/functions/array.ts +8 -9
  456. package/src/functions/bitSet128.ts +3 -3
  457. package/src/functions/color.ts +3 -3
  458. package/src/functions/decorators.ts +83 -12
  459. package/src/functions/deepCopy.ts +83 -17
  460. package/src/functions/deepCopyTests.ts +1 -1
  461. package/src/functions/initArray.ts +6 -11
  462. package/src/functions/jsonRoom.ts +11 -0
  463. package/src/functions/kColor.ts +3 -3
  464. package/src/functions/logMisc.ts +28 -2
  465. package/src/{features/saveDataManager → functions}/merge.ts +79 -45
  466. package/src/functions/mergeTests.ts +2 -3
  467. package/src/functions/rng.ts +3 -3
  468. package/src/functions/serialization.ts +25 -1
  469. package/src/functions/table.ts +1 -1
  470. package/src/functions/tstlClass.ts +3 -57
  471. package/src/functions/vector.ts +3 -3
  472. package/src/functions/weighted.ts +28 -11
  473. package/src/index.ts +5 -0
  474. package/src/interfaces/SaveData.ts +3 -34
  475. package/src/interfaces/private/AddCallbackParametersCustom2.ts +298 -7
  476. package/src/objects/isaacAPIClassTypeToBrand.ts +1 -1
  477. package/src/types/AnyClass.ts +1 -0
  478. package/src/types/AnyFunction.ts +5 -0
  479. package/src/types/FunctionTuple.ts +3 -4
  480. package/src/types/HasFunction.ts +7 -0
  481. package/dist/src/classes/callbacks/validation/CustomCallbackRevive.d.ts.map +0 -1
  482. package/dist/src/classes/callbacks/validation/CustomCallbackRevive.lua +0 -19
  483. package/dist/src/classes/features/callbackLogic/GridEntityDetection.d.ts.map +0 -1
  484. package/dist/src/enums/private/SerializationBrand.d.ts.map +0 -1
  485. package/dist/src/features/saveDataManager/merge.d.ts +0 -26
  486. package/dist/src/features/saveDataManager/merge.d.ts.map +0 -1
  487. package/dist/src/features/saveDataManager/serializationBrands.d.ts +0 -2
  488. package/dist/src/features/saveDataManager/serializationBrands.d.ts.map +0 -1
  489. package/dist/src/features/saveDataManager/serializationBrands.lua +0 -19
  490. package/dist/src/indexLua.d.ts +0 -199
  491. package/dist/src/indexLua.d.ts.map +0 -1
  492. package/dist/src/indexLua.lua +0 -1354
  493. package/src/classes/callbacks/validation/CustomCallbackRevive.ts +0 -27
  494. package/src/features/saveDataManager/serializationBrands.ts +0 -16
@@ -19,6 +19,8 @@ interface JSONObject {
19
19
  /**
20
20
  * Helper function to calculate what the resulting `BitFlags<DoorSlotFlag>` value would be for a
21
21
  * given JSON room.
22
+ *
23
+ * (A JSON room is an XML file converted to JSON so that it can be directly imported into your mod.)
22
24
  */
23
25
  export function getJSONRoomDoorSlotFlags(
24
26
  jsonRoom: JSONRoom,
@@ -75,6 +77,8 @@ export function getJSONRoomDoorSlotFlags(
75
77
  /**
76
78
  * Helper function to find a specific room from an array of JSON rooms.
77
79
  *
80
+ * (A JSON room is an XML file converted to JSON so that it can be directly imported into your mod.)
81
+ *
78
82
  * @param jsonRooms The array of rooms to search through.
79
83
  * @param variant The room variant to select. (The room variant can be thought of as the ID of the
80
84
  * room.)
@@ -107,6 +111,8 @@ export function getJSONRoomOfVariant(
107
111
  /**
108
112
  * Helper function to find all of the JSON rooms that match the sub-type provided.
109
113
  *
114
+ * (A JSON room is an XML file converted to JSON so that it can be directly imported into your mod.)
115
+ *
110
116
  * @param jsonRooms The array of rooms to search through.
111
117
  * @param subType The sub-type to match.
112
118
  */
@@ -124,6 +130,9 @@ export function getJSONRoomsOfSubType(
124
130
  /**
125
131
  * Helper function to get a random JSON entity from an array of JSON entities.
126
132
  *
133
+ * (A JSON entity is an entity inside of a JSON room. A JSON room is an XML file converted to JSON
134
+ * so that it can be directly imported into your mod.)
135
+ *
127
136
  * Note that this function does not simply choose a random element in the provided array; it will
128
137
  * properly account for each room weight using the algorithm from:
129
138
  * https://stackoverflow.com/questions/1761626/weighted-random-numbers
@@ -163,6 +172,8 @@ export function getRandomJSONEntity(
163
172
  /**
164
173
  * Helper function to get a random JSON room from an array of JSON rooms.
165
174
  *
175
+ * (A JSON room is an XML file converted to JSON so that it can be directly imported into your mod.)
176
+ *
166
177
  * Note that this function does not simply choose a random element in the provided array; it will
167
178
  * properly account for each room weight using the algorithm from:
168
179
  * https://stackoverflow.com/questions/1761626/weighted-random-numbers
@@ -1,5 +1,5 @@
1
1
  import { CopyableIsaacAPIClassType } from "isaac-typescript-definitions";
2
- import { SerializationBrand } from "../enums/private/SerializationBrand";
2
+ import { SerializationBrand } from "../enums/SerializationBrand";
3
3
  import { isaacAPIClassEquals, isIsaacAPIClassOfType } from "./isaacAPIClass";
4
4
  import { getRandom } from "./random";
5
5
  import { getRandomSeed, isRNG, newRNG } from "./rng";
@@ -92,8 +92,8 @@ export function isKColor(object: unknown): object is KColor {
92
92
  }
93
93
 
94
94
  /**
95
- * Used to determine is the given table is a serialized `KColor` object created by the save data
96
- * manager and/or the `deepCopy` function.
95
+ * Used to determine is the given table is a serialized `KColor` object created by the `deepCopy`
96
+ * function.
97
97
  */
98
98
  export function isSerializedKColor(
99
99
  object: unknown,
@@ -307,8 +307,8 @@ export function logSounds(): void {
307
307
  }
308
308
 
309
309
  /**
310
- * Helper function for logging every key and value of a table. This is a deep log; the function will
311
- * recursively call itself if it counters a table within a table.
310
+ * Helper function for logging every key and value of a Lua table. This is a deep log; the function
311
+ * will recursively call itself if it counters a table within a table.
312
312
  *
313
313
  * This function will only work on tables that have string keys (because it logs the keys in order,
314
314
  * instead of randomly). It will throw a run-time error if it encounters a non-string key.
@@ -399,6 +399,32 @@ export function logTableDifferences<K extends AnyNotNil, V>(
399
399
  }
400
400
  }
401
401
 
402
+ /**
403
+ * Helper function to log the keys of a Lua table. This is not a deep log; only the keys of the
404
+ * top-most table will be logged.
405
+ *
406
+ * This function is useful for tables that have recursive references.
407
+ */
408
+ export function logTableKeys(luaTable: unknown): void {
409
+ log("Printing out the keys of a Lua table:");
410
+
411
+ if (!isTable(luaTable)) {
412
+ log(
413
+ ` n/a (encountered a variable of type "${typeof luaTable}" instead of a table)`,
414
+ );
415
+ return;
416
+ }
417
+
418
+ let numElements = 0;
419
+ iterateTableInOrder(luaTable, (key) => {
420
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string
421
+ log(`${key}`);
422
+ numElements++;
423
+ });
424
+
425
+ log(` The size of the table was: ${numElements}`);
426
+ }
427
+
402
428
  /** Helper function for printing out every tear flag that is turned on. Useful when debugging. */
403
429
  export function logTearFlags(flags: TearFlag | BitFlags<TearFlag>): void {
404
430
  logFlags(flags, TearFlag, "tear");
@@ -1,41 +1,55 @@
1
- import { SerializationBrand } from "../../enums/private/SerializationBrand";
2
- import { SerializationType } from "../../enums/SerializationType";
3
- import { isArray } from "../../functions/array";
4
- import { deepCopy } from "../../functions/deepCopy";
5
- import { log } from "../../functions/log";
1
+ import { SerializationBrand } from "../enums/SerializationBrand";
2
+ import { SerializationType } from "../enums/SerializationType";
3
+ import { SAVE_DATA_MANAGER_DEBUG } from "../features/saveDataManager/constants";
4
+ import { AnyClass } from "../types/AnyClass";
5
+ import { isArray } from "./array";
6
+ import { deepCopy } from "./deepCopy";
7
+ import { log } from "./log";
6
8
  import {
7
9
  deserializeIsaacAPIClass,
10
+ isSerializationBrand,
8
11
  isSerializedIsaacAPIClass,
9
- } from "../../functions/serialization";
10
- import { clearTable, iterateTableInOrder } from "../../functions/table";
11
- import { isDefaultMap, isTSTLMap, isTSTLSet } from "../../functions/tstlClass";
12
- import { isTable } from "../../functions/types";
13
- import { getTraversalDescription } from "../../functions/utils";
14
- import { SAVE_DATA_MANAGER_DEBUG } from "./constants";
15
- import { isSerializationBrand } from "./serializationBrands";
12
+ } from "./serialization";
13
+ import { clearTable, iterateTableInOrder } from "./table";
14
+ import { isDefaultMap, isTSTLMap, isTSTLSet } from "./tstlClass";
15
+ import { isTable } from "./types";
16
+ import { getTraversalDescription } from "./utils";
16
17
 
17
18
  /**
18
19
  * `merge` takes the values from a new table and recursively merges them into an old object (while
19
20
  * performing appropriate deserialization).
20
21
  *
21
- * It supports the following object types:
22
+ * This function is used to merge incoming data from the "save#.dat" file into a mod's variables.
23
+ * Merging is useful instead of blowing away a table entirely because mod code often relies on the
24
+ * local table/object references.
22
25
  *
23
- * - Basic TSTL objects / tables
24
- * - TSTL `Map`
25
- * - TSTL `Set`
26
- * - TSTL classes
27
- * - `DefaultMap`
28
- * - Isaac `BitSet128` objects
29
- * - Isaac `Color` objects
30
- * - Isaac `KColor` objects
31
- * - Isaac `RNG` objects
32
- * - Isaac `Vector` objects
26
+ * This function always assumes that the new table is serialized data and will attempt to perform
27
+ * deserialization on the objects within. In other words, unlike the `deepCopy` function, the
28
+ * `merge` function will always operates in the mode of `SerializationType.DESERIALIZE`. For the
29
+ * types of objects that will be deserialized, see the documentation for the `deepCopy` function.
33
30
  *
34
- * Since it is common for a variable to have a type of `something | null`, we must iterate over the
35
- * new object and copy over all of the values. (A value of null transpiles to nil, which means the
36
- * table key does not exist.) The consequence of this is that it can copy over old variables that
37
- * are no longer used in the code, or copy over old variables of a different type, which can cause
38
- * run-time errors. In such cases, users will have to manually delete their save data.
31
+ * This function does not iterate over the old object, like you would naively expect. This is
32
+ * because it is common for a variable to have a type of `something | null`. If this is the case,
33
+ * the key would not appear when iterating over the old object (because a value of null transpiles
34
+ * to nil, which means the table key does not exist). Thus, we must instead iterate over the new
35
+ * object and copy the values backwards. The consequence of this is that `merge` can copy over old
36
+ * variables that are no longer used in the code, or copy over old variables of a different type,
37
+ * which can cause run-time errors. In such cases, users will have to manually delete their save
38
+ * data.
39
+ *
40
+ * @param oldObject The old object to merge the values into. This can be either a Lua table, a TSTL
41
+ * map, or a TSTL set.
42
+ * @param newTable The new table to merge the values from. This must be a Lua table that represents
43
+ * serialized data. In other words, it should be created with the `deepCopy`
44
+ * function using `SerializationType.SERIALIZE`.
45
+ * @param traversalDescription Used to track the current key that we are operating on for debugging
46
+ * purposes. Use a name that corresponds to the name of the merging
47
+ * table.
48
+ * @param classConstructors Optional. A Lua table that maps the name of a user-defined TSTL class to
49
+ * its corresponding constructor. If the `deepCopy` function finds any
50
+ * user-defined TSTL classes when recursively iterating through the given
51
+ * object, it will use this map to instantiate a new class. Default is an
52
+ * empty Lua table.
39
53
  */
40
54
  export function merge(
41
55
  oldObject:
@@ -44,6 +58,7 @@ export function merge(
44
58
  | Set<AnyNotNil>,
45
59
  newTable: LuaMap<AnyNotNil, unknown>,
46
60
  traversalDescription: string,
61
+ classConstructors = new LuaMap<string, AnyClass>(),
47
62
  ): void {
48
63
  if (SAVE_DATA_MANAGER_DEBUG) {
49
64
  log(`merge is traversing: ${traversalDescription}`);
@@ -59,16 +74,31 @@ export function merge(
59
74
 
60
75
  // First, handle the special case of an array with a shallow copy.
61
76
  if (isArray(oldObject) && isArray(newTable)) {
62
- mergeSerializedArray(oldObject, newTable, traversalDescription);
77
+ mergeSerializedArray(
78
+ oldObject,
79
+ newTable,
80
+ traversalDescription,
81
+ classConstructors,
82
+ );
63
83
  return;
64
84
  }
65
85
 
66
86
  // Depending on whether we are working on a Lua table or a TypeScriptToLua object, we need to
67
87
  // iterate in a specific way.
68
88
  if (isTSTLMap(oldObject) || isTSTLSet(oldObject) || isDefaultMap(oldObject)) {
69
- mergeSerializedTSTLObject(oldObject, newTable, traversalDescription);
89
+ mergeSerializedTSTLObject(
90
+ oldObject,
91
+ newTable,
92
+ traversalDescription,
93
+ classConstructors,
94
+ );
70
95
  } else {
71
- mergeSerializedTable(oldObject, newTable, traversalDescription);
96
+ mergeSerializedTable(
97
+ oldObject,
98
+ newTable,
99
+ traversalDescription,
100
+ classConstructors,
101
+ );
72
102
  }
73
103
  }
74
104
 
@@ -76,6 +106,7 @@ function mergeSerializedArray(
76
106
  oldArray: LuaMap<AnyNotNil, unknown>,
77
107
  newArray: LuaMap<AnyNotNil, unknown>,
78
108
  traversalDescription: string,
109
+ classConstructors: LuaMap<string, AnyClass>,
79
110
  ) {
80
111
  if (SAVE_DATA_MANAGER_DEBUG) {
81
112
  log(`merge encountered an array: ${traversalDescription}`);
@@ -87,7 +118,13 @@ function mergeSerializedArray(
87
118
  iterateTableInOrder(
88
119
  newArray,
89
120
  (key, value) => {
90
- oldArray.set(key, value);
121
+ const deserializedValue = deepCopy(
122
+ value,
123
+ SerializationType.DESERIALIZE,
124
+ traversalDescription,
125
+ classConstructors,
126
+ );
127
+ oldArray.set(key, deserializedValue);
91
128
  },
92
129
  SAVE_DATA_MANAGER_DEBUG,
93
130
  );
@@ -97,6 +134,7 @@ function mergeSerializedTSTLObject(
97
134
  oldObject: Map<AnyNotNil, unknown> | Set<AnyNotNil>,
98
135
  newTable: LuaMap<AnyNotNil, unknown>,
99
136
  traversalDescription: string,
137
+ classConstructors: LuaMap<string, AnyClass>,
100
138
  ) {
101
139
  if (SAVE_DATA_MANAGER_DEBUG) {
102
140
  log(`merge encountered a TSTL object: ${traversalDescription}`);
@@ -128,18 +166,13 @@ function mergeSerializedTSTLObject(
128
166
  }
129
167
 
130
168
  if (isTSTLMap(oldObject) || isDefaultMap(oldObject)) {
131
- let valueCopy: unknown;
132
- if (isTable(value)) {
133
- valueCopy = deepCopy(
134
- value,
135
- SerializationType.DESERIALIZE,
136
- traversalDescription,
137
- );
138
- } else {
139
- valueCopy = value;
140
- }
141
-
142
- oldObject.set(keyToUse, valueCopy);
169
+ const deserializedValue = deepCopy(
170
+ value,
171
+ SerializationType.DESERIALIZE,
172
+ traversalDescription,
173
+ classConstructors,
174
+ );
175
+ oldObject.set(keyToUse, deserializedValue);
143
176
  } else if (isTSTLSet(oldObject)) {
144
177
  oldObject.add(keyToUse);
145
178
  }
@@ -152,6 +185,7 @@ function mergeSerializedTable(
152
185
  oldTable: LuaMap<AnyNotNil, unknown>,
153
186
  newTable: LuaMap<AnyNotNil, unknown>,
154
187
  traversalDescription: string,
188
+ classConstructors: LuaMap<string, AnyClass>,
155
189
  ) {
156
190
  if (SAVE_DATA_MANAGER_DEBUG) {
157
191
  log(`merge encountered a Lua table: ${traversalDescription}`);
@@ -194,7 +228,7 @@ function mergeSerializedTable(
194
228
  key,
195
229
  traversalDescription,
196
230
  );
197
- merge(oldValue, value, traversalDescription);
231
+ merge(oldValue, value, traversalDescription, classConstructors);
198
232
  } else {
199
233
  // Base case: copy the value
200
234
  oldTable.set(key, value);
@@ -1,16 +1,15 @@
1
1
  import { DefaultMap } from "../classes/DefaultMap";
2
2
  import { SerializationType } from "../enums/SerializationType";
3
- import { merge } from "../features/saveDataManager/merge";
4
3
  import { deepCopy } from "./deepCopy";
5
4
  import { log } from "./log";
5
+ import { merge } from "./merge";
6
6
  import { isRNG, newRNG } from "./rng";
7
7
  import { isSerializedIsaacAPIClass } from "./serialization";
8
8
  import { printConsole } from "./utils";
9
9
  import { isVector, serializeVector } from "./vector";
10
10
 
11
11
  /**
12
- * Run the suite of tests that prove that the "merge" function works properly. (This function is not
13
- * exported but is used internally in the save data manager.)
12
+ * Run the suite of tests that prove that the "merge" function works properly.
14
13
  *
15
14
  * This function is only useful if you are troubleshooting the save data manager.
16
15
  */
@@ -1,6 +1,6 @@
1
1
  import { CopyableIsaacAPIClassType } from "isaac-typescript-definitions";
2
2
  import { game } from "../core/cachedClasses";
3
- import { SerializationBrand } from "../enums/private/SerializationBrand";
3
+ import { SerializationBrand } from "../enums/SerializationBrand";
4
4
  import { isaacAPIClassEquals, isIsaacAPIClassOfType } from "./isaacAPIClass";
5
5
  import { getNumbersFromTable, tableHasKeys } from "./table";
6
6
  import { isTable } from "./types";
@@ -71,8 +71,8 @@ export function isRNG(object: unknown): object is RNG {
71
71
  }
72
72
 
73
73
  /**
74
- * Used to determine is the given table is a serialized `RNG` object created by the save data
75
- * manager and/or the `deepCopy` function.
74
+ * Used to determine is the given table is a serialized `RNG` object created by the `deepCopy`
75
+ * function.
76
76
  */
77
77
  export function isSerializedRNG(object: unknown): object is SerializedRNG {
78
78
  if (!isTable(object)) {
@@ -1,4 +1,5 @@
1
1
  import { CopyableIsaacAPIClassType } from "isaac-typescript-definitions";
2
+ import { SerializationBrand } from "../enums/SerializationBrand";
2
3
  import { ISAAC_API_CLASS_TYPE_TO_BRAND } from "../objects/isaacAPIClassTypeToBrand";
3
4
  import {
4
5
  CopyableIsaacAPIClass,
@@ -8,8 +9,14 @@ import {
8
9
  ISAAC_API_CLASS_TYPE_TO_FUNCTIONS,
9
10
  SerializedIsaacAPIClass,
10
11
  } from "../objects/isaacAPIClassTypeToFunctions";
12
+ import { getEnumValues } from "./enums";
11
13
  import { getIsaacAPIClassName } from "./isaacAPIClass";
12
- import { isTable, isUserdata } from "./types";
14
+ import { isString, isTable, isUserdata } from "./types";
15
+
16
+ const SERIALIZATION_BRANDS = getEnumValues(SerializationBrand);
17
+ const SERIALIZATION_BRAND_SET: ReadonlySet<string> = new Set(
18
+ SERIALIZATION_BRANDS,
19
+ );
13
20
 
14
21
  /**
15
22
  * Helper function to generically copy an Isaac API class without knowing what specific type of
@@ -136,6 +143,23 @@ export function isCopyableIsaacAPIClass(
136
143
  return isFunctions.some((identityFunction) => identityFunction(object));
137
144
  }
138
145
 
146
+ /**
147
+ * Helper function to check if a key of a table in the "save#.dat" file is a serialization brand
148
+ * inserted by the save data manager (i.e. the `deepCopy` function).
149
+ *
150
+ * This is marked internal because end-users would not normally be iterating through a serialized
151
+ * object directly.
152
+ *
153
+ * @internal
154
+ */
155
+ export function isSerializationBrand(key: unknown): boolean {
156
+ if (!isString(key)) {
157
+ return false;
158
+ }
159
+
160
+ return SERIALIZATION_BRAND_SET.has(key);
161
+ }
162
+
139
163
  /**
140
164
  * Helper function to generically check if a given Lua table is a serialized Isaac API class. (This
141
165
  * is used by the save data manager when reading data from the "save#.dat" file.)
@@ -140,7 +140,7 @@ export function getStringsFromTable(
140
140
  export function isTableEmpty(luaMap: LuaMap<AnyNotNil, unknown>): boolean {
141
141
  // Using `next` does not seem to work properly, so we use `pairs` instead.
142
142
  // eslint-disable-next-line no-unreachable-loop
143
- for (const [_key, _value] of pairs(luaMap)) {
143
+ for (const [_key, _value] of luaMap) {
144
144
  return false;
145
145
  }
146
146
 
@@ -1,15 +1,7 @@
1
1
  import { DefaultMap } from "../classes/DefaultMap";
2
2
  import { TSTLClassMetatable } from "../interfaces/TSTLClassMetatable";
3
3
  import { TSTLClass } from "../types/TSTLClass";
4
- import { isString, isTable } from "./types";
5
-
6
- const VANILLA_TSTL_CLASSES = new Set(["Map", "Set", "WeakMap", "WeakSet"]);
7
-
8
- const TSTL_CLASS_METATABLE_KEYS: ReadonlySet<string> = new Set([
9
- "____constructor",
10
- "__index",
11
- "constructor",
12
- ]);
4
+ import { isTable } from "./types";
13
5
 
14
6
  /**
15
7
  * Helper function to get the constructor from an instantiated TypeScriptToLua class, which is
@@ -64,14 +56,6 @@ export function isDefaultMap(
64
56
  return className === "DefaultMap";
65
57
  }
66
58
 
67
- /**
68
- * Returns whether or not this is a class that is provided by the `isaacscript-common` library, such
69
- * as a `DefaultMap`.
70
- */
71
- export function isIsaacScriptCommonClass(object: unknown): boolean {
72
- return isDefaultMap(object);
73
- }
74
-
75
59
  /**
76
60
  * Helper function to determine if a given object is a TypeScriptToLua `Map`.
77
61
  *
@@ -98,46 +82,8 @@ export function isTSTLSet(object: unknown): object is Set<AnyNotNil> {
98
82
 
99
83
  /** TypeScriptToLua classes are Lua tables that have a metatable with a certain amount of keys. */
100
84
  export function isUserDefinedTSTLClass(object: unknown): object is TSTLClass {
101
- if (isVanillaTSTLClass(object) || isIsaacScriptCommonClass(object)) {
102
- return false;
103
- }
104
-
105
- if (!isTable(object)) {
106
- return false;
107
- }
108
-
109
- const metatable = getmetatable(object);
110
- if (metatable === undefined) {
111
- return false;
112
- }
113
-
114
- let numKeys = 0;
115
- for (const [key] of pairs(metatable)) {
116
- numKeys++;
117
-
118
- if (!isString(key)) {
119
- return false;
120
- }
121
-
122
- if (!TSTL_CLASS_METATABLE_KEYS.has(key)) {
123
- return false;
124
- }
125
- }
126
-
127
- return numKeys === TSTL_CLASS_METATABLE_KEYS.size;
128
- }
129
-
130
- /**
131
- * Returns whether or not this is a class that is provided as part of the TypeScriptToLua
132
- * transpiler, such as a `Map` or a `Set`.
133
- */
134
- export function isVanillaTSTLClass(object: unknown): boolean {
135
- const className = getTSTLClassName(object);
136
- if (className === undefined) {
137
- return false;
138
- }
139
-
140
- return VANILLA_TSTL_CLASSES.has(className);
85
+ const tstlClassName = getTSTLClassName(object);
86
+ return tstlClassName !== undefined;
141
87
  }
142
88
 
143
89
  /**
@@ -2,7 +2,7 @@ import {
2
2
  CopyableIsaacAPIClassType,
3
3
  Direction,
4
4
  } from "isaac-typescript-definitions";
5
- import { SerializationBrand } from "../enums/private/SerializationBrand";
5
+ import { SerializationBrand } from "../enums/SerializationBrand";
6
6
  import { angleToDirection } from "./direction";
7
7
  import { isaacAPIClassEquals, isIsaacAPIClassOfType } from "./isaacAPIClass";
8
8
  import { getRandomFloat } from "./random";
@@ -82,8 +82,8 @@ export function getRandomVector(
82
82
  }
83
83
 
84
84
  /**
85
- * Used to determine is the given table is a serialized `Vector` object created by the save data
86
- * manager and/or the `deepCopy` function.
85
+ * Used to determine is the given table is a serialized `Vector` object created by the `deepCopy`
86
+ * function.
87
87
  */
88
88
  export function isSerializedVector(
89
89
  object: unknown,
@@ -1,16 +1,35 @@
1
1
  import { WeightedArray } from "../types/WeightedArray";
2
- import { arrayToString, sumArray } from "./array";
2
+ import { sumArray } from "./array";
3
3
  import { getRandomFloat } from "./random";
4
4
  import { getRandomSeed } from "./rng";
5
5
 
6
- /** Get a random value from a `WeightedArray`. (The second element in the array is the weight.) */
6
+ /**
7
+ * Get a random value from a `WeightedArray`. (A `WeightedArray` is an array of tuples, where the
8
+ * first element in the tuple is a value, and the second element in the tuple is a float
9
+ * corresponding to the value's weight.)
10
+ */
7
11
  export function getRandomFromWeightedArray<T>(
8
12
  weightedArray: WeightedArray<T>,
9
13
  seedOrRNG: Seed | RNG = getRandomSeed(),
10
14
  ): T {
15
+ const randomIndex = getRandomIndexFromWeightedArray(weightedArray, seedOrRNG);
16
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
17
+ const randomElement = weightedArray[randomIndex]!;
18
+ return randomElement[0];
19
+ }
20
+
21
+ /**
22
+ * Get a random index from a `WeightedArray`. (A `WeightedArray` is an array of tuples, where the
23
+ * first element in the tuple is a value, and the second element in the tuple is a float
24
+ * corresponding to the value's weight.)
25
+ */
26
+ export function getRandomIndexFromWeightedArray<T>(
27
+ weightedArray: WeightedArray<T>,
28
+ seedOrRNG: Seed | RNG = getRandomSeed(),
29
+ ): int {
11
30
  if (weightedArray.length === 0) {
12
31
  error(
13
- "Failed to get a random element from a weighted array since the provided array was empty.",
32
+ "Failed to get a random index from a weighted array since the provided array was empty.",
14
33
  );
15
34
  }
16
35
 
@@ -19,18 +38,16 @@ export function getRandomFromWeightedArray<T>(
19
38
  const randomWeight = getRandomFloat(0, totalWeight, seedOrRNG);
20
39
 
21
40
  let weightAccumulator = 0;
22
- for (const tuple of weightedArray) {
23
- const [element, weight] = tuple;
41
+ for (let i = 0; i < weightedArray.length; i++) {
42
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
43
+ const tuple = weightedArray[i]!;
44
+ const [_element, weight] = tuple;
24
45
 
25
46
  weightAccumulator += weight;
26
47
  if (weightAccumulator >= randomWeight) {
27
- return element;
48
+ return i;
28
49
  }
29
50
  }
30
51
 
31
- error(
32
- `Failed to get a random element from a weighted array: ${arrayToString(
33
- weightedArray,
34
- )}`,
35
- );
52
+ error("Failed to get a random index from a weighted array.");
36
53
  }
package/src/index.ts CHANGED
@@ -15,6 +15,7 @@ export * from "./enums/ModCallbackCustom2";
15
15
  export * from "./enums/PocketItemType";
16
16
  export * from "./enums/RockAltType";
17
17
  export * from "./enums/SaveDataKey";
18
+ export * from "./enums/SerializationBrand";
18
19
  export * from "./enums/SerializationType";
19
20
  export * from "./enums/SlotDestructionType";
20
21
  export * from "./enums/StatType";
@@ -23,6 +24,7 @@ export * from "./features/characterStats";
23
24
  export * from "./features/collectibleItemPoolType";
24
25
  export * from "./features/customGridEntity";
25
26
  export * from "./features/customHotkeys";
27
+ export * from "./features/customItemPool";
26
28
  export * from "./features/customPickup";
27
29
  export * from "./features/customStage/exports";
28
30
  export * from "./features/customTrapdoor/exports";
@@ -107,6 +109,7 @@ export * from "./functions/logEntities";
107
109
  export * from "./functions/logMisc";
108
110
  export * from "./functions/map";
109
111
  export * from "./functions/math";
112
+ export * from "./functions/merge";
110
113
  export * from "./functions/mergeTests";
111
114
  export * from "./functions/minimap";
112
115
  export * from "./functions/nextStage";
@@ -179,11 +182,13 @@ export * from "./objects/kColors";
179
182
  export * from "./types/AllButFirst";
180
183
  export * from "./types/AllButLast";
181
184
  export * from "./types/AnyEntity";
185
+ export * from "./types/AnyFunction";
182
186
  export * from "./types/AnyGridEntity";
183
187
  export * from "./types/CollectibleIndex";
184
188
  export * from "./types/Constructor";
185
189
  export * from "./types/FunctionTuple";
186
190
  export * from "./types/HasAllEnumKeys";
191
+ export * from "./types/HasFunction";
187
192
  export * from "./types/Immutable";
188
193
  export * from "./types/LowercaseKeys";
189
194
  export * from "./types/PickingUpItem";