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
@@ -0,0 +1,40 @@
1
+ /// <reference types="@typescript-to-lua/language-extensions" />
2
+ import { AnyClass } from "../types/AnyClass";
3
+ /**
4
+ * `merge` takes the values from a new table and recursively merges them into an old object (while
5
+ * performing appropriate deserialization).
6
+ *
7
+ * This function is used to merge incoming data from the "save#.dat" file into a mod's variables.
8
+ * Merging is useful instead of blowing away a table entirely because mod code often relies on the
9
+ * local table/object references.
10
+ *
11
+ * This function always assumes that the new table is serialized data and will attempt to perform
12
+ * deserialization on the objects within. In other words, unlike the `deepCopy` function, the
13
+ * `merge` function will always operates in the mode of `SerializationType.DESERIALIZE`. For the
14
+ * types of objects that will be deserialized, see the documentation for the `deepCopy` function.
15
+ *
16
+ * This function does not iterate over the old object, like you would naively expect. This is
17
+ * because it is common for a variable to have a type of `something | null`. If this is the case,
18
+ * the key would not appear when iterating over the old object (because a value of null transpiles
19
+ * to nil, which means the table key does not exist). Thus, we must instead iterate over the new
20
+ * object and copy the values backwards. The consequence of this is that `merge` can copy over old
21
+ * variables that are no longer used in the code, or copy over old variables of a different type,
22
+ * which can cause run-time errors. In such cases, users will have to manually delete their save
23
+ * data.
24
+ *
25
+ * @param oldObject The old object to merge the values into. This can be either a Lua table, a TSTL
26
+ * map, or a TSTL set.
27
+ * @param newTable The new table to merge the values from. This must be a Lua table that represents
28
+ * serialized data. In other words, it should be created with the `deepCopy`
29
+ * function using `SerializationType.SERIALIZE`.
30
+ * @param traversalDescription Used to track the current key that we are operating on for debugging
31
+ * purposes. Use a name that corresponds to the name of the merging
32
+ * table.
33
+ * @param classConstructors Optional. A Lua table that maps the name of a user-defined TSTL class to
34
+ * its corresponding constructor. If the `deepCopy` function finds any
35
+ * user-defined TSTL classes when recursively iterating through the given
36
+ * object, it will use this map to instantiate a new class. Default is an
37
+ * empty Lua table.
38
+ */
39
+ export declare function merge(oldObject: LuaMap<AnyNotNil, unknown> | Map<AnyNotNil, unknown> | Set<AnyNotNil>, newTable: LuaMap<AnyNotNil, unknown>, traversalDescription: string, classConstructors?: LuaMap<string, AnyClass>): void;
40
+ //# sourceMappingURL=merge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../../src/functions/merge.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAc7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,KAAK,CACnB,SAAS,EACL,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,GAC1B,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,GACvB,GAAG,CAAC,SAAS,CAAC,EAClB,QAAQ,EAAE,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,EACpC,oBAAoB,EAAE,MAAM,EAC5B,iBAAiB,2BAAiC,GACjD,IAAI,CAyCN"}
@@ -3,10 +3,12 @@ local Set = ____lualib.Set
3
3
  local Map = ____lualib.Map
4
4
  local ____exports = {}
5
5
  local mergeSerializedArray, mergeSerializedTSTLObject, mergeSerializedTable
6
- local ____SerializationBrand = require("src.enums.private.SerializationBrand")
6
+ local ____SerializationBrand = require("src.enums.SerializationBrand")
7
7
  local SerializationBrand = ____SerializationBrand.SerializationBrand
8
8
  local ____SerializationType = require("src.enums.SerializationType")
9
9
  local SerializationType = ____SerializationType.SerializationType
10
+ local ____constants = require("src.features.saveDataManager.constants")
11
+ local SAVE_DATA_MANAGER_DEBUG = ____constants.SAVE_DATA_MANAGER_DEBUG
10
12
  local ____array = require("src.functions.array")
11
13
  local isArray = ____array.isArray
12
14
  local ____deepCopy = require("src.functions.deepCopy")
@@ -15,6 +17,7 @@ local ____log = require("src.functions.log")
15
17
  local log = ____log.log
16
18
  local ____serialization = require("src.functions.serialization")
17
19
  local deserializeIsaacAPIClass = ____serialization.deserializeIsaacAPIClass
20
+ local isSerializationBrand = ____serialization.isSerializationBrand
18
21
  local isSerializedIsaacAPIClass = ____serialization.isSerializedIsaacAPIClass
19
22
  local ____table = require("src.functions.table")
20
23
  local clearTable = ____table.clearTable
@@ -27,32 +30,44 @@ local ____types = require("src.functions.types")
27
30
  local isTable = ____types.isTable
28
31
  local ____utils = require("src.functions.utils")
29
32
  local getTraversalDescription = ____utils.getTraversalDescription
30
- local ____constants = require("src.features.saveDataManager.constants")
31
- local SAVE_DATA_MANAGER_DEBUG = ____constants.SAVE_DATA_MANAGER_DEBUG
32
- local ____serializationBrands = require("src.features.saveDataManager.serializationBrands")
33
- local isSerializationBrand = ____serializationBrands.isSerializationBrand
34
33
  --- `merge` takes the values from a new table and recursively merges them into an old object (while
35
34
  -- performing appropriate deserialization).
36
35
  --
37
- -- It supports the following object types:
36
+ -- This function is used to merge incoming data from the "save#.dat" file into a mod's variables.
37
+ -- Merging is useful instead of blowing away a table entirely because mod code often relies on the
38
+ -- local table/object references.
38
39
  --
39
- -- - Basic TSTL objects / tables
40
- -- - TSTL `Map`
41
- -- - TSTL `Set`
42
- -- - TSTL classes
43
- -- - `DefaultMap`
44
- -- - Isaac `BitSet128` objects
45
- -- - Isaac `Color` objects
46
- -- - Isaac `KColor` objects
47
- -- - Isaac `RNG` objects
48
- -- - Isaac `Vector` objects
40
+ -- This function always assumes that the new table is serialized data and will attempt to perform
41
+ -- deserialization on the objects within. In other words, unlike the `deepCopy` function, the
42
+ -- `merge` function will always operates in the mode of `SerializationType.DESERIALIZE`. For the
43
+ -- types of objects that will be deserialized, see the documentation for the `deepCopy` function.
49
44
  --
50
- -- Since it is common for a variable to have a type of `something | null`, we must iterate over the
51
- -- new object and copy over all of the values. (A value of null transpiles to nil, which means the
52
- -- table key does not exist.) The consequence of this is that it can copy over old variables that
53
- -- are no longer used in the code, or copy over old variables of a different type, which can cause
54
- -- run-time errors. In such cases, users will have to manually delete their save data.
55
- function ____exports.merge(self, oldObject, newTable, traversalDescription)
45
+ -- This function does not iterate over the old object, like you would naively expect. This is
46
+ -- because it is common for a variable to have a type of `something | null`. If this is the case,
47
+ -- the key would not appear when iterating over the old object (because a value of null transpiles
48
+ -- to nil, which means the table key does not exist). Thus, we must instead iterate over the new
49
+ -- object and copy the values backwards. The consequence of this is that `merge` can copy over old
50
+ -- variables that are no longer used in the code, or copy over old variables of a different type,
51
+ -- which can cause run-time errors. In such cases, users will have to manually delete their save
52
+ -- data.
53
+ --
54
+ -- @param oldObject The old object to merge the values into. This can be either a Lua table, a TSTL
55
+ -- map, or a TSTL set.
56
+ -- @param newTable The new table to merge the values from. This must be a Lua table that represents
57
+ -- serialized data. In other words, it should be created with the `deepCopy`
58
+ -- function using `SerializationType.SERIALIZE`.
59
+ -- @param traversalDescription Used to track the current key that we are operating on for debugging
60
+ -- purposes. Use a name that corresponds to the name of the merging
61
+ -- table.
62
+ -- @param classConstructors Optional. A Lua table that maps the name of a user-defined TSTL class to
63
+ -- its corresponding constructor. If the `deepCopy` function finds any
64
+ -- user-defined TSTL classes when recursively iterating through the given
65
+ -- object, it will use this map to instantiate a new class. Default is an
66
+ -- empty Lua table.
67
+ function ____exports.merge(self, oldObject, newTable, traversalDescription, classConstructors)
68
+ if classConstructors == nil then
69
+ classConstructors = {}
70
+ end
56
71
  if SAVE_DATA_MANAGER_DEBUG then
57
72
  log(nil, "merge is traversing: " .. traversalDescription)
58
73
  end
@@ -63,16 +78,34 @@ function ____exports.merge(self, oldObject, newTable, traversalDescription)
63
78
  error("The second argument given to the merge function is not a table.")
64
79
  end
65
80
  if isArray(nil, oldObject) and isArray(nil, newTable) then
66
- mergeSerializedArray(nil, oldObject, newTable, traversalDescription)
81
+ mergeSerializedArray(
82
+ nil,
83
+ oldObject,
84
+ newTable,
85
+ traversalDescription,
86
+ classConstructors
87
+ )
67
88
  return
68
89
  end
69
90
  if isTSTLMap(nil, oldObject) or isTSTLSet(nil, oldObject) or isDefaultMap(nil, oldObject) then
70
- mergeSerializedTSTLObject(nil, oldObject, newTable, traversalDescription)
91
+ mergeSerializedTSTLObject(
92
+ nil,
93
+ oldObject,
94
+ newTable,
95
+ traversalDescription,
96
+ classConstructors
97
+ )
71
98
  else
72
- mergeSerializedTable(nil, oldObject, newTable, traversalDescription)
99
+ mergeSerializedTable(
100
+ nil,
101
+ oldObject,
102
+ newTable,
103
+ traversalDescription,
104
+ classConstructors
105
+ )
73
106
  end
74
107
  end
75
- function mergeSerializedArray(self, oldArray, newArray, traversalDescription)
108
+ function mergeSerializedArray(self, oldArray, newArray, traversalDescription, classConstructors)
76
109
  if SAVE_DATA_MANAGER_DEBUG then
77
110
  log(nil, "merge encountered an array: " .. traversalDescription)
78
111
  end
@@ -81,12 +114,19 @@ function mergeSerializedArray(self, oldArray, newArray, traversalDescription)
81
114
  nil,
82
115
  newArray,
83
116
  function(____, key, value)
84
- oldArray[key] = value
117
+ local deserializedValue = deepCopy(
118
+ nil,
119
+ value,
120
+ SerializationType.DESERIALIZE,
121
+ traversalDescription,
122
+ classConstructors
123
+ )
124
+ oldArray[key] = deserializedValue
85
125
  end,
86
126
  SAVE_DATA_MANAGER_DEBUG
87
127
  )
88
128
  end
89
- function mergeSerializedTSTLObject(self, oldObject, newTable, traversalDescription)
129
+ function mergeSerializedTSTLObject(self, oldObject, newTable, traversalDescription, classConstructors)
90
130
  if SAVE_DATA_MANAGER_DEBUG then
91
131
  log(nil, "merge encountered a TSTL object: " .. traversalDescription)
92
132
  end
@@ -108,13 +148,14 @@ function mergeSerializedTSTLObject(self, oldObject, newTable, traversalDescripti
108
148
  keyToUse = numberKey
109
149
  end
110
150
  if isTSTLMap(nil, oldObject) or isDefaultMap(nil, oldObject) then
111
- local valueCopy
112
- if isTable(nil, value) then
113
- valueCopy = deepCopy(nil, value, SerializationType.DESERIALIZE, traversalDescription)
114
- else
115
- valueCopy = value
116
- end
117
- oldObject:set(keyToUse, valueCopy)
151
+ local deserializedValue = deepCopy(
152
+ nil,
153
+ value,
154
+ SerializationType.DESERIALIZE,
155
+ traversalDescription,
156
+ classConstructors
157
+ )
158
+ oldObject:set(keyToUse, deserializedValue)
118
159
  elseif isTSTLSet(nil, oldObject) then
119
160
  oldObject:add(keyToUse)
120
161
  end
@@ -122,7 +163,7 @@ function mergeSerializedTSTLObject(self, oldObject, newTable, traversalDescripti
122
163
  SAVE_DATA_MANAGER_DEBUG
123
164
  )
124
165
  end
125
- function mergeSerializedTable(self, oldTable, newTable, traversalDescription)
166
+ function mergeSerializedTable(self, oldTable, newTable, traversalDescription, classConstructors)
126
167
  if SAVE_DATA_MANAGER_DEBUG then
127
168
  log(nil, "merge encountered a Lua table: " .. traversalDescription)
128
169
  end
@@ -152,7 +193,13 @@ function mergeSerializedTable(self, oldTable, newTable, traversalDescription)
152
193
  oldTable[key] = oldValue
153
194
  end
154
195
  traversalDescription = getTraversalDescription(nil, key, traversalDescription)
155
- ____exports.merge(nil, oldValue, value, traversalDescription)
196
+ ____exports.merge(
197
+ nil,
198
+ oldValue,
199
+ value,
200
+ traversalDescription,
201
+ classConstructors
202
+ )
156
203
  else
157
204
  oldTable[key] = value
158
205
  end
@@ -1,6 +1,5 @@
1
1
  /**
2
- * Run the suite of tests that prove that the "merge" function works properly. (This function is not
3
- * exported but is used internally in the save data manager.)
2
+ * Run the suite of tests that prove that the "merge" function works properly.
4
3
  *
5
4
  * This function is only useful if you are troubleshooting the save data manager.
6
5
  */
@@ -1 +1 @@
1
- {"version":3,"file":"mergeTests.d.ts","sourceRoot":"","sources":["../../../src/functions/mergeTests.ts"],"names":[],"mappings":"AAUA;;;;;GAKG;AACH,wBAAgB,aAAa,IAAI,IAAI,CAkBpC"}
1
+ {"version":3,"file":"mergeTests.d.ts","sourceRoot":"","sources":["../../../src/functions/mergeTests.ts"],"names":[],"mappings":"AAUA;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,IAAI,CAkBpC"}
@@ -7,12 +7,12 @@ local ____DefaultMap = require("src.classes.DefaultMap")
7
7
  local DefaultMap = ____DefaultMap.DefaultMap
8
8
  local ____SerializationType = require("src.enums.SerializationType")
9
9
  local SerializationType = ____SerializationType.SerializationType
10
- local ____merge = require("src.features.saveDataManager.merge")
11
- local merge = ____merge.merge
12
10
  local ____deepCopy = require("src.functions.deepCopy")
13
11
  local deepCopy = ____deepCopy.deepCopy
14
12
  local ____log = require("src.functions.log")
15
13
  local log = ____log.log
14
+ local ____merge = require("src.functions.merge")
15
+ local merge = ____merge.merge
16
16
  local ____rng = require("src.functions.rng")
17
17
  local isRNG = ____rng.isRNG
18
18
  local newRNG = ____rng.newRNG
@@ -238,8 +238,7 @@ function oldTableHasRNGSerialized(self)
238
238
  error("The old table's seed not match: " .. tostring(seed))
239
239
  end
240
240
  end
241
- --- Run the suite of tests that prove that the "merge" function works properly. (This function is not
242
- -- exported but is used internally in the save data manager.)
241
+ --- Run the suite of tests that prove that the "merge" function works properly.
243
242
  --
244
243
  -- This function is only useful if you are troubleshooting the save data manager.
245
244
  function ____exports.runMergeTests(self)
@@ -20,8 +20,8 @@ export declare function getRandomSeed(): Seed;
20
20
  /** Helper function to check if something is an instantiated `RNG` object. */
21
21
  export declare function isRNG(object: unknown): object is RNG;
22
22
  /**
23
- * Used to determine is the given table is a serialized `RNG` object created by the save data
24
- * manager and/or the `deepCopy` function.
23
+ * Used to determine is the given table is a serialized `RNG` object created by the `deepCopy`
24
+ * function.
25
25
  */
26
26
  export declare function isSerializedRNG(object: unknown): object is SerializedRNG;
27
27
  /**
@@ -4,7 +4,7 @@ local ____exports = {}
4
4
  local RECOMMENDED_SHIFT_IDX, OBJECT_NAME
5
5
  local ____cachedClasses = require("src.core.cachedClasses")
6
6
  local game = ____cachedClasses.game
7
- local ____SerializationBrand = require("src.enums.private.SerializationBrand")
7
+ local ____SerializationBrand = require("src.enums.SerializationBrand")
8
8
  local SerializationBrand = ____SerializationBrand.SerializationBrand
9
9
  local ____isaacAPIClass = require("src.functions.isaacAPIClass")
10
10
  local isaacAPIClassEquals = ____isaacAPIClass.isaacAPIClassEquals
@@ -72,8 +72,8 @@ function ____exports.deserializeRNG(self, rng)
72
72
  end
73
73
  return ____exports.newRNG(nil, seed)
74
74
  end
75
- --- Used to determine is the given table is a serialized `RNG` object created by the save data
76
- -- manager and/or the `deepCopy` function.
75
+ --- Used to determine is the given table is a serialized `RNG` object created by the `deepCopy`
76
+ -- function.
77
77
  function ____exports.isSerializedRNG(self, object)
78
78
  if not isTable(nil, object) then
79
79
  return false
@@ -1 +1 @@
1
- {"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../../../src/functions/serialization.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,qBAAqB,EAErB,iCAAiC,EACjC,uBAAuB,EAEvB,uBAAuB,EACxB,MAAM,yCAAyC,CAAC;AAIjD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,qBAAqB,EAC/D,aAAa,EAAE,CAAC,GACf,CAAC,CAoCH;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,WAAW,SAAS,uBAAuB,EAE3C,uBAAuB,EAAE,WAAW,GACnC,uBAAuB,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAkChD;AAoBD;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,OAAO,GACd,MAAM,IAAI,qBAAqB,CAIjC;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,OAAO,GACd,MAAM,IAAI,uBAAuB,CAQnC;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,qBAAqB,EACpE,aAAa,EAAE,CAAC,GACf,iCAAiC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAoChD"}
1
+ {"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../../../src/functions/serialization.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,qBAAqB,EAErB,iCAAiC,EACjC,uBAAuB,EAEvB,uBAAuB,EACxB,MAAM,yCAAyC,CAAC;AAUjD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,qBAAqB,EAC/D,aAAa,EAAE,CAAC,GACf,CAAC,CAoCH;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,WAAW,SAAS,uBAAuB,EAE3C,uBAAuB,EAAE,WAAW,GACnC,uBAAuB,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAkChD;AAoBD;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,OAAO,GACd,MAAM,IAAI,qBAAqB,CAIjC;AAmBD;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,OAAO,GACd,MAAM,IAAI,uBAAuB,CAQnC;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,qBAAqB,EACpE,aAAa,EAAE,CAAC,GACf,iCAAiC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAoChD"}
@@ -1,4 +1,6 @@
1
1
  local ____lualib = require("lualib_bundle")
2
+ local Set = ____lualib.Set
3
+ local __TS__New = ____lualib.__TS__New
2
4
  local __TS__TypeOf = ____lualib.__TS__TypeOf
3
5
  local __TS__ObjectEntries = ____lualib.__TS__ObjectEntries
4
6
  local __TS__ObjectValues = ____lualib.__TS__ObjectValues
@@ -6,13 +8,18 @@ local __TS__ArrayMap = ____lualib.__TS__ArrayMap
6
8
  local __TS__ArraySome = ____lualib.__TS__ArraySome
7
9
  local ____exports = {}
8
10
  local getSerializedTableType
11
+ local ____SerializationBrand = require("src.enums.SerializationBrand")
12
+ local SerializationBrand = ____SerializationBrand.SerializationBrand
9
13
  local ____isaacAPIClassTypeToBrand = require("src.objects.isaacAPIClassTypeToBrand")
10
14
  local ISAAC_API_CLASS_TYPE_TO_BRAND = ____isaacAPIClassTypeToBrand.ISAAC_API_CLASS_TYPE_TO_BRAND
11
15
  local ____isaacAPIClassTypeToFunctions = require("src.objects.isaacAPIClassTypeToFunctions")
12
16
  local ISAAC_API_CLASS_TYPE_TO_FUNCTIONS = ____isaacAPIClassTypeToFunctions.ISAAC_API_CLASS_TYPE_TO_FUNCTIONS
17
+ local ____enums = require("src.functions.enums")
18
+ local getEnumValues = ____enums.getEnumValues
13
19
  local ____isaacAPIClass = require("src.functions.isaacAPIClass")
14
20
  local getIsaacAPIClassName = ____isaacAPIClass.getIsaacAPIClassName
15
21
  local ____types = require("src.functions.types")
22
+ local isString = ____types.isString
16
23
  local isTable = ____types.isTable
17
24
  local isUserdata = ____types.isUserdata
18
25
  function getSerializedTableType(self, serializedIsaacAPIClass)
@@ -25,6 +32,8 @@ function getSerializedTableType(self, serializedIsaacAPIClass)
25
32
  end
26
33
  return nil
27
34
  end
35
+ local SERIALIZATION_BRANDS = getEnumValues(nil, SerializationBrand)
36
+ local SERIALIZATION_BRAND_SET = __TS__New(Set, SERIALIZATION_BRANDS)
28
37
  --- Helper function to generically copy an Isaac API class without knowing what specific type of
29
38
  -- class it is. (This is used by the save data manager.)
30
39
  --
@@ -78,6 +87,19 @@ function ____exports.isCopyableIsaacAPIClass(self, object)
78
87
  function(____, identityFunction) return identityFunction(nil, object) end
79
88
  )
80
89
  end
90
+ --- Helper function to check if a key of a table in the "save#.dat" file is a serialization brand
91
+ -- inserted by the save data manager (i.e. the `deepCopy` function).
92
+ --
93
+ -- This is marked internal because end-users would not normally be iterating through a serialized
94
+ -- object directly.
95
+ --
96
+ -- @internal
97
+ function ____exports.isSerializationBrand(self, key)
98
+ if not isString(nil, key) then
99
+ return false
100
+ end
101
+ return SERIALIZATION_BRAND_SET:has(key)
102
+ end
81
103
  --- Helper function to generically check if a given Lua table is a serialized Isaac API class. (This
82
104
  -- is used by the save data manager when reading data from the "save#.dat" file.)
83
105
  --
@@ -27,11 +27,6 @@ export declare function getTSTLClassName(object: unknown): string | undefined;
27
27
  * their own copies of the entire lualib and thus their own instantiated version of a `Map`.
28
28
  */
29
29
  export declare function isDefaultMap(object: unknown): object is DefaultMap<AnyNotNil, unknown>;
30
- /**
31
- * Returns whether or not this is a class that is provided by the `isaacscript-common` library, such
32
- * as a `DefaultMap`.
33
- */
34
- export declare function isIsaacScriptCommonClass(object: unknown): boolean;
35
30
  /**
36
31
  * Helper function to determine if a given object is a TypeScriptToLua `Map`.
37
32
  *
@@ -50,11 +45,6 @@ export declare function isTSTLMap(object: unknown): object is Map<AnyNotNil, unk
50
45
  export declare function isTSTLSet(object: unknown): object is Set<AnyNotNil>;
51
46
  /** TypeScriptToLua classes are Lua tables that have a metatable with a certain amount of keys. */
52
47
  export declare function isUserDefinedTSTLClass(object: unknown): object is TSTLClass;
53
- /**
54
- * Returns whether or not this is a class that is provided as part of the TypeScriptToLua
55
- * transpiler, such as a `Map` or a `Set`.
56
- */
57
- export declare function isVanillaTSTLClass(object: unknown): boolean;
58
48
  /**
59
49
  * Initializes a new TypeScriptToLua class in the situation where you do not know what kind of class
60
50
  * it is. This function requires that you provide an instantiated class of the same type, as it will
@@ -1 +1 @@
1
- {"version":3,"file":"tstlClass.d.ts","sourceRoot":"","sources":["../../../src/functions/tstlClass.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAW/C;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,OAAO,GACd,kBAAkB,CAAC,aAAa,CAAC,GAAG,SAAS,CAW/C;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAOpE;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,OAAO,GACd,MAAM,IAAI,UAAU,CAAC,SAAS,EAAE,OAAO,CAAC,CAG1C;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAEjE;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAG5E;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,GAAG,CAAC,SAAS,CAAC,CAGnE;AAED,kGAAkG;AAClG,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,SAAS,CA4B3E;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAO3D;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,SAAS,GAAG,SAAS,CAiB3D"}
1
+ {"version":3,"file":"tstlClass.d.ts","sourceRoot":"","sources":["../../../src/functions/tstlClass.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG/C;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,OAAO,GACd,kBAAkB,CAAC,aAAa,CAAC,GAAG,SAAS,CAW/C;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAOpE;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,OAAO,GACd,MAAM,IAAI,UAAU,CAAC,SAAS,EAAE,OAAO,CAAC,CAG1C;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAG5E;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,GAAG,CAAC,SAAS,CAAC,CAGnE;AAED,kGAAkG;AAClG,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,SAAS,CAG3E;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,SAAS,GAAG,SAAS,CAiB3D"}
@@ -1,10 +1,5 @@
1
- local ____lualib = require("lualib_bundle")
2
- local Set = ____lualib.Set
3
- local __TS__New = ____lualib.__TS__New
4
1
  local ____exports = {}
5
- local VANILLA_TSTL_CLASSES
6
2
  local ____types = require("src.functions.types")
7
- local isString = ____types.isString
8
3
  local isTable = ____types.isTable
9
4
  --- Helper function to get the constructor from an instantiated TypeScriptToLua class, which is
10
5
  -- located on the metatable.
@@ -35,17 +30,6 @@ function ____exports.getTSTLClassName(self, object)
35
30
  end
36
31
  return constructor.name
37
32
  end
38
- --- Returns whether or not this is a class that is provided as part of the TypeScriptToLua
39
- -- transpiler, such as a `Map` or a `Set`.
40
- function ____exports.isVanillaTSTLClass(self, object)
41
- local className = ____exports.getTSTLClassName(nil, object)
42
- if className == nil then
43
- return false
44
- end
45
- return VANILLA_TSTL_CLASSES:has(className)
46
- end
47
- VANILLA_TSTL_CLASSES = __TS__New(Set, {"Map", "Set", "WeakMap", "WeakSet"})
48
- local TSTL_CLASS_METATABLE_KEYS = __TS__New(Set, {"____constructor", "__index", "constructor"})
49
33
  --- Helper function to determine if a given object is a TypeScriptToLua `Map`.
50
34
  --
51
35
  -- It is not reliable to use the `instanceof` operator to determine this because each Lua module has
@@ -54,11 +38,6 @@ function ____exports.isDefaultMap(self, object)
54
38
  local className = ____exports.getTSTLClassName(nil, object)
55
39
  return className == "DefaultMap"
56
40
  end
57
- --- Returns whether or not this is a class that is provided by the `isaacscript-common` library, such
58
- -- as a `DefaultMap`.
59
- function ____exports.isIsaacScriptCommonClass(self, object)
60
- return ____exports.isDefaultMap(nil, object)
61
- end
62
41
  --- Helper function to determine if a given object is a TypeScriptToLua `Map`.
63
42
  --
64
43
  -- It is not reliable to use the `instanceof` operator to determine this because each Lua module
@@ -79,27 +58,8 @@ function ____exports.isTSTLSet(self, object)
79
58
  end
80
59
  --- TypeScriptToLua classes are Lua tables that have a metatable with a certain amount of keys.
81
60
  function ____exports.isUserDefinedTSTLClass(self, object)
82
- if ____exports.isVanillaTSTLClass(nil, object) or ____exports.isIsaacScriptCommonClass(nil, object) then
83
- return false
84
- end
85
- if not isTable(nil, object) then
86
- return false
87
- end
88
- local metatable = getmetatable(object)
89
- if metatable == nil then
90
- return false
91
- end
92
- local numKeys = 0
93
- for key in pairs(metatable) do
94
- numKeys = numKeys + 1
95
- if not isString(nil, key) then
96
- return false
97
- end
98
- if not TSTL_CLASS_METATABLE_KEYS:has(key) then
99
- return false
100
- end
101
- end
102
- return numKeys == TSTL_CLASS_METATABLE_KEYS.size
61
+ local tstlClassName = ____exports.getTSTLClassName(nil, object)
62
+ return tstlClassName ~= nil
103
63
  end
104
64
  --- Initializes a new TypeScriptToLua class in the situation where you do not know what kind of class
105
65
  -- it is. This function requires that you provide an instantiated class of the same type, as it will
@@ -23,8 +23,8 @@ export declare function deserializeVector(vector: SerializedVector): Vector;
23
23
  */
24
24
  export declare function getRandomVector(seedOrRNG?: Seed | RNG): Vector;
25
25
  /**
26
- * Used to determine is the given table is a serialized `Vector` object created by the save data
27
- * manager and/or the `deepCopy` function.
26
+ * Used to determine is the given table is a serialized `Vector` object created by the `deepCopy`
27
+ * function.
28
28
  */
29
29
  export declare function isSerializedVector(object: unknown): object is SerializedVector;
30
30
  /** Helper function to check if something is an instantiated `Vector` object. */
@@ -1,6 +1,6 @@
1
1
  local ____exports = {}
2
2
  local OBJECT_NAME
3
- local ____SerializationBrand = require("src.enums.private.SerializationBrand")
3
+ local ____SerializationBrand = require("src.enums.SerializationBrand")
4
4
  local SerializationBrand = ____SerializationBrand.SerializationBrand
5
5
  local ____direction = require("src.functions.direction")
6
6
  local angleToDirection = ____direction.angleToDirection
@@ -69,8 +69,8 @@ function ____exports.getRandomVector(self, seedOrRNG)
69
69
  local y = getRandomFloat(nil, -1, 1, rng)
70
70
  return Vector(x, y)
71
71
  end
72
- --- Used to determine is the given table is a serialized `Vector` object created by the save data
73
- -- manager and/or the `deepCopy` function.
72
+ --- Used to determine is the given table is a serialized `Vector` object created by the `deepCopy`
73
+ -- function.
74
74
  function ____exports.isSerializedVector(self, object)
75
75
  if not isTable(nil, object) then
76
76
  return false
@@ -1,6 +1,17 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  /// <reference types="isaac-typescript-definitions" />
3
+ /// <reference types="isaac-typescript-definitions" />
3
4
  import { WeightedArray } from "../types/WeightedArray";
4
- /** Get a random value from a `WeightedArray`. (The second element in the array is the weight.) */
5
+ /**
6
+ * Get a random value from a `WeightedArray`. (A `WeightedArray` is an array of tuples, where the
7
+ * first element in the tuple is a value, and the second element in the tuple is a float
8
+ * corresponding to the value's weight.)
9
+ */
5
10
  export declare function getRandomFromWeightedArray<T>(weightedArray: WeightedArray<T>, seedOrRNG?: Seed | RNG): T;
11
+ /**
12
+ * Get a random index from a `WeightedArray`. (A `WeightedArray` is an array of tuples, where the
13
+ * first element in the tuple is a value, and the second element in the tuple is a float
14
+ * corresponding to the value's weight.)
15
+ */
16
+ export declare function getRandomIndexFromWeightedArray<T>(weightedArray: WeightedArray<T>, seedOrRNG?: Seed | RNG): int;
6
17
  //# sourceMappingURL=weighted.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"weighted.d.ts","sourceRoot":"","sources":["../../../src/functions/weighted.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAKvD,kGAAkG;AAClG,wBAAgB,0BAA0B,CAAC,CAAC,EAC1C,aAAa,EAAE,aAAa,CAAC,CAAC,CAAC,EAC/B,SAAS,GAAE,IAAI,GAAG,GAAqB,GACtC,CAAC,CA0BH"}
1
+ {"version":3,"file":"weighted.d.ts","sourceRoot":"","sources":["../../../src/functions/weighted.ts"],"names":[],"mappings":";;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAKvD;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,EAC1C,aAAa,EAAE,aAAa,CAAC,CAAC,CAAC,EAC/B,SAAS,GAAE,IAAI,GAAG,GAAqB,GACtC,CAAC,CAKH;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,CAAC,CAAC,EAC/C,aAAa,EAAE,aAAa,CAAC,CAAC,CAAC,EAC/B,SAAS,GAAE,IAAI,GAAG,GAAqB,GACtC,GAAG,CAwBL"}
@@ -2,19 +2,20 @@ local ____lualib = require("lualib_bundle")
2
2
  local __TS__ArrayMap = ____lualib.__TS__ArrayMap
3
3
  local ____exports = {}
4
4
  local ____array = require("src.functions.array")
5
- local arrayToString = ____array.arrayToString
6
5
  local sumArray = ____array.sumArray
7
6
  local ____random = require("src.functions.random")
8
7
  local getRandomFloat = ____random.getRandomFloat
9
8
  local ____rng = require("src.functions.rng")
10
9
  local getRandomSeed = ____rng.getRandomSeed
11
- --- Get a random value from a `WeightedArray`. (The second element in the array is the weight.)
12
- function ____exports.getRandomFromWeightedArray(self, weightedArray, seedOrRNG)
10
+ --- Get a random index from a `WeightedArray`. (A `WeightedArray` is an array of tuples, where the
11
+ -- first element in the tuple is a value, and the second element in the tuple is a float
12
+ -- corresponding to the value's weight.)
13
+ function ____exports.getRandomIndexFromWeightedArray(self, weightedArray, seedOrRNG)
13
14
  if seedOrRNG == nil then
14
15
  seedOrRNG = getRandomSeed(nil)
15
16
  end
16
17
  if #weightedArray == 0 then
17
- error("Failed to get a random element from a weighted array since the provided array was empty.")
18
+ error("Failed to get a random index from a weighted array since the provided array was empty.")
18
19
  end
19
20
  local weights = __TS__ArrayMap(
20
21
  weightedArray,
@@ -23,13 +24,29 @@ function ____exports.getRandomFromWeightedArray(self, weightedArray, seedOrRNG)
23
24
  local totalWeight = sumArray(nil, weights)
24
25
  local randomWeight = getRandomFloat(nil, 0, totalWeight, seedOrRNG)
25
26
  local weightAccumulator = 0
26
- for ____, tuple in ipairs(weightedArray) do
27
- local element, weight = table.unpack(tuple)
28
- weightAccumulator = weightAccumulator + weight
29
- if weightAccumulator >= randomWeight then
30
- return element
27
+ do
28
+ local i = 0
29
+ while i < #weightedArray do
30
+ local tuple = weightedArray[i + 1]
31
+ local _element, weight = table.unpack(tuple)
32
+ weightAccumulator = weightAccumulator + weight
33
+ if weightAccumulator >= randomWeight then
34
+ return i
35
+ end
36
+ i = i + 1
31
37
  end
32
38
  end
33
- error("Failed to get a random element from a weighted array: " .. arrayToString(nil, weightedArray))
39
+ error("Failed to get a random index from a weighted array.")
40
+ end
41
+ --- Get a random value from a `WeightedArray`. (A `WeightedArray` is an array of tuples, where the
42
+ -- first element in the tuple is a value, and the second element in the tuple is a float
43
+ -- corresponding to the value's weight.)
44
+ function ____exports.getRandomFromWeightedArray(self, weightedArray, seedOrRNG)
45
+ if seedOrRNG == nil then
46
+ seedOrRNG = getRandomSeed(nil)
47
+ end
48
+ local randomIndex = ____exports.getRandomIndexFromWeightedArray(nil, weightedArray, seedOrRNG)
49
+ local randomElement = weightedArray[randomIndex + 1]
50
+ return randomElement[1]
34
51
  end
35
52
  return ____exports
@@ -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";