isaacscript-common 6.13.0 → 6.16.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 (144) hide show
  1. package/dist/callbacks/postGridEntityCustomCollision.d.ts +2 -0
  2. package/dist/callbacks/postGridEntityCustomCollision.d.ts.map +1 -0
  3. package/dist/callbacks/postGridEntityCustomCollision.lua +71 -0
  4. package/dist/callbacks/postGridEntityCustomRender.lua +0 -7
  5. package/dist/callbacks/postGridEntityCustomUpdate.lua +0 -7
  6. package/dist/callbacks/subscriptions/postGridEntityCustomBroken.d.ts +6 -0
  7. package/dist/callbacks/subscriptions/postGridEntityCustomBroken.d.ts.map +1 -0
  8. package/dist/callbacks/subscriptions/postGridEntityCustomBroken.lua +29 -0
  9. package/dist/callbacks/subscriptions/postGridEntityCustomCollision.d.ts +6 -0
  10. package/dist/callbacks/subscriptions/postGridEntityCustomCollision.d.ts.map +1 -0
  11. package/dist/callbacks/subscriptions/postGridEntityCustomCollision.lua +29 -0
  12. package/dist/enums/ModCallbackCustom.d.ts +96 -62
  13. package/dist/enums/ModCallbackCustom.d.ts.map +1 -1
  14. package/dist/enums/ModCallbackCustom.lua +64 -60
  15. package/dist/enums/private/SerializationBrand.d.ts +1 -1
  16. package/dist/enums/private/SerializationBrand.lua +1 -1
  17. package/dist/features/customGridEntity.d.ts +7 -3
  18. package/dist/features/customGridEntity.d.ts.map +1 -1
  19. package/dist/features/customGridEntity.lua +67 -7
  20. package/dist/features/extraConsoleCommands/exports.d.ts +4 -3
  21. package/dist/features/extraConsoleCommands/exports.d.ts.map +1 -1
  22. package/dist/features/extraConsoleCommands/exports.lua +4 -3
  23. package/dist/features/extraConsoleCommands/init.lua +1 -0
  24. package/dist/functions/collectibles.d.ts +6 -2
  25. package/dist/functions/collectibles.d.ts.map +1 -1
  26. package/dist/functions/collectibles.lua +4 -2
  27. package/dist/functions/color.d.ts +20 -14
  28. package/dist/functions/color.d.ts.map +1 -1
  29. package/dist/functions/color.lua +78 -73
  30. package/dist/functions/deepCopy.d.ts.map +1 -1
  31. package/dist/functions/deepCopy.lua +22 -1
  32. package/dist/functions/gridEntities.d.ts +2 -36
  33. package/dist/functions/gridEntities.d.ts.map +1 -1
  34. package/dist/functions/gridEntities.lua +2 -78
  35. package/dist/functions/isaacAPIClass.d.ts +1 -1
  36. package/dist/functions/isaacAPIClass.d.ts.map +1 -1
  37. package/dist/functions/itemPool.d.ts +10 -0
  38. package/dist/functions/itemPool.d.ts.map +1 -0
  39. package/dist/functions/itemPool.lua +116 -0
  40. package/dist/functions/kColor.d.ts +20 -14
  41. package/dist/functions/kColor.d.ts.map +1 -1
  42. package/dist/functions/kColor.lua +65 -60
  43. package/dist/functions/mergeTests.lua +2 -2
  44. package/dist/functions/npcs.d.ts +1 -29
  45. package/dist/functions/npcs.d.ts.map +1 -1
  46. package/dist/functions/npcs.lua +0 -45
  47. package/dist/functions/projectiles.d.ts +32 -0
  48. package/dist/functions/projectiles.d.ts.map +1 -0
  49. package/dist/functions/projectiles.lua +73 -0
  50. package/dist/functions/random.d.ts +1 -1
  51. package/dist/functions/random.lua +1 -1
  52. package/dist/functions/rng.d.ts +11 -15
  53. package/dist/functions/rng.d.ts.map +1 -1
  54. package/dist/functions/rng.lua +32 -52
  55. package/dist/functions/rockAlt.d.ts +48 -0
  56. package/dist/functions/rockAlt.d.ts.map +1 -0
  57. package/dist/functions/rockAlt.lua +365 -0
  58. package/dist/functions/saveFile.d.ts +8 -7
  59. package/dist/functions/saveFile.d.ts.map +1 -1
  60. package/dist/functions/saveFile.lua +10 -96
  61. package/dist/functions/serialization.d.ts +26 -7
  62. package/dist/functions/serialization.d.ts.map +1 -1
  63. package/dist/functions/serialization.lua +51 -19
  64. package/dist/functions/table.d.ts +2 -2
  65. package/dist/functions/table.lua +2 -2
  66. package/dist/functions/trinketGive.d.ts +13 -0
  67. package/dist/functions/trinketGive.d.ts.map +1 -1
  68. package/dist/functions/trinketGive.lua +16 -0
  69. package/dist/functions/tstlClass.d.ts +1 -1
  70. package/dist/functions/tstlClass.d.ts.map +1 -1
  71. package/dist/functions/vector.d.ts +21 -14
  72. package/dist/functions/vector.d.ts.map +1 -1
  73. package/dist/functions/vector.lua +58 -54
  74. package/dist/index.d.ts +2 -0
  75. package/dist/index.d.ts.map +1 -1
  76. package/dist/index.lua +16 -0
  77. package/dist/initCustomCallbacks.d.ts.map +1 -1
  78. package/dist/initCustomCallbacks.lua +3 -0
  79. package/dist/interfaces/AddCallbackParameterCustom.d.ts +4 -0
  80. package/dist/interfaces/AddCallbackParameterCustom.d.ts.map +1 -1
  81. package/dist/objects/callbackRegisterFunctions.d.ts.map +1 -1
  82. package/dist/objects/callbackRegisterFunctions.lua +6 -0
  83. package/dist/objects/isaacAPIClassTypeToFunctions.d.ts +12 -0
  84. package/dist/objects/isaacAPIClassTypeToFunctions.d.ts.map +1 -0
  85. package/dist/objects/isaacAPIClassTypeToFunctions.lua +25 -0
  86. package/dist/types/{private/IsaacAPIClass.d.ts → IsaacAPIClass.d.ts} +0 -0
  87. package/dist/types/IsaacAPIClass.d.ts.map +1 -0
  88. package/dist/types/{private/IsaacAPIClass.lua → IsaacAPIClass.lua} +0 -0
  89. package/dist/types/{private/SerializedIsaacAPIClass.d.ts → SerializedIsaacAPIClass.d.ts} +0 -0
  90. package/dist/types/SerializedIsaacAPIClass.d.ts.map +1 -0
  91. package/dist/types/{private/SerializedIsaacAPIClass.lua → SerializedIsaacAPIClass.lua} +0 -0
  92. package/dist/types/{private/TSTLClass.d.ts → TSTLClass.d.ts} +0 -0
  93. package/dist/types/TSTLClass.d.ts.map +1 -0
  94. package/dist/types/{private/TSTLClass.lua → TSTLClass.lua} +0 -0
  95. package/package.json +2 -2
  96. package/src/callbacks/postGridEntityCustomCollision.ts +74 -0
  97. package/src/callbacks/postGridEntityCustomRender.ts +1 -17
  98. package/src/callbacks/postGridEntityCustomUpdate.ts +1 -17
  99. package/src/callbacks/subscriptions/postGridEntityCustomBroken.ts +41 -0
  100. package/src/callbacks/subscriptions/postGridEntityCustomCollision.ts +43 -0
  101. package/src/enums/ModCallbackCustom.ts +38 -2
  102. package/src/enums/private/SerializationBrand.ts +1 -1
  103. package/src/features/customGridEntity.ts +78 -2
  104. package/src/features/extraConsoleCommands/exports.ts +4 -3
  105. package/src/features/extraConsoleCommands/init.ts +1 -0
  106. package/src/features/extraConsoleCommands/listCommands.ts +2 -2
  107. package/src/functions/collectibles.ts +6 -2
  108. package/src/functions/color.ts +89 -87
  109. package/src/functions/deepCopy.ts +15 -2
  110. package/src/functions/gridEntities.ts +2 -77
  111. package/src/functions/isaacAPIClass.ts +1 -1
  112. package/src/functions/itemPool.ts +153 -0
  113. package/src/functions/kColor.ts +87 -84
  114. package/src/functions/mergeTests.ts +2 -2
  115. package/src/functions/npcs.ts +1 -58
  116. package/src/functions/projectiles.ts +78 -0
  117. package/src/functions/random.ts +1 -1
  118. package/src/functions/rng.ts +45 -65
  119. package/src/functions/rockAlt.ts +396 -0
  120. package/src/functions/saveFile.ts +13 -119
  121. package/src/functions/serialization.ts +81 -25
  122. package/src/functions/table.ts +2 -2
  123. package/src/functions/trinketGive.ts +21 -0
  124. package/src/functions/tstlClass.ts +1 -1
  125. package/src/functions/vector.ts +78 -74
  126. package/src/index.ts +2 -0
  127. package/src/initCustomCallbacks.ts +2 -0
  128. package/src/interfaces/AddCallbackParameterCustom.ts +4 -0
  129. package/src/objects/callbackRegisterFunctions.ts +6 -0
  130. package/src/objects/isaacAPIClassTypeToFunctions.ts +63 -0
  131. package/src/types/{private/IsaacAPIClass.ts → IsaacAPIClass.ts} +0 -0
  132. package/src/types/{private/SerializedIsaacAPIClass.ts → SerializedIsaacAPIClass.ts} +0 -0
  133. package/src/types/{private/TSTLClass.ts → TSTLClass.ts} +0 -0
  134. package/dist/objects/isaacAPIClassTypeToCopyFunction.d.ts +0 -6
  135. package/dist/objects/isaacAPIClassTypeToCopyFunction.d.ts.map +0 -1
  136. package/dist/objects/isaacAPIClassTypeToCopyFunction.lua +0 -13
  137. package/dist/objects/serializedIsaacAPIClassTypeToIdentityFunction.d.ts +0 -5
  138. package/dist/objects/serializedIsaacAPIClassTypeToIdentityFunction.d.ts.map +0 -1
  139. package/dist/objects/serializedIsaacAPIClassTypeToIdentityFunction.lua +0 -13
  140. package/dist/types/private/IsaacAPIClass.d.ts.map +0 -1
  141. package/dist/types/private/SerializedIsaacAPIClass.d.ts.map +0 -1
  142. package/dist/types/private/TSTLClass.d.ts.map +0 -1
  143. package/src/objects/isaacAPIClassTypeToCopyFunction.ts +0 -18
  144. package/src/objects/serializedIsaacAPIClassTypeToIdentityFunction.ts +0 -14
@@ -0,0 +1,365 @@
1
+ local ____exports = {}
2
+ local spawnRockAltRewardUrn, spawnRockAltRewardMushroom, spawnRockAltRewardSkull, spawnRockAltRewardPolyp, spawnRockAltRewardBucket, ROCK_ALT_CHANCES, POLYP_PROJECTILE_SPEED, POLYP_NUM_PROJECTILES
3
+ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
4
+ local Card = ____isaac_2Dtypescript_2Ddefinitions.Card
5
+ local CoinSubType = ____isaac_2Dtypescript_2Ddefinitions.CoinSubType
6
+ local CollectibleType = ____isaac_2Dtypescript_2Ddefinitions.CollectibleType
7
+ local EffectVariant = ____isaac_2Dtypescript_2Ddefinitions.EffectVariant
8
+ local EntityType = ____isaac_2Dtypescript_2Ddefinitions.EntityType
9
+ local HeartSubType = ____isaac_2Dtypescript_2Ddefinitions.HeartSubType
10
+ local ItemPoolType = ____isaac_2Dtypescript_2Ddefinitions.ItemPoolType
11
+ local PillColor = ____isaac_2Dtypescript_2Ddefinitions.PillColor
12
+ local RoomType = ____isaac_2Dtypescript_2Ddefinitions.RoomType
13
+ local TrinketType = ____isaac_2Dtypescript_2Ddefinitions.TrinketType
14
+ local ____cachedClasses = require("cachedClasses")
15
+ local game = ____cachedClasses.game
16
+ local ____constants = require("constants")
17
+ local DISTANCE_OF_GRID_TILE = ____constants.DISTANCE_OF_GRID_TILE
18
+ local ____RockAltType = require("enums.RockAltType")
19
+ local RockAltType = ____RockAltType.RockAltType
20
+ local ____backdropTypeToRockAltType = require("objects.backdropTypeToRockAltType")
21
+ local BACKDROP_TYPE_TO_ROCK_ALT_TYPE = ____backdropTypeToRockAltType.BACKDROP_TYPE_TO_ROCK_ALT_TYPE
22
+ local ____entitiesSpecific = require("functions.entitiesSpecific")
23
+ local spawnEffectWithSeed = ____entitiesSpecific.spawnEffectWithSeed
24
+ local spawnNPCWithSeed = ____entitiesSpecific.spawnNPCWithSeed
25
+ local ____itemPool = require("functions.itemPool")
26
+ local isCollectibleInItemPool = ____itemPool.isCollectibleInItemPool
27
+ local ____pickupsSpecific = require("functions.pickupsSpecific")
28
+ local spawnCardWithSeed = ____pickupsSpecific.spawnCardWithSeed
29
+ local spawnCoinWithSeed = ____pickupsSpecific.spawnCoinWithSeed
30
+ local spawnHeartWithSeed = ____pickupsSpecific.spawnHeartWithSeed
31
+ local spawnPillWithSeed = ____pickupsSpecific.spawnPillWithSeed
32
+ local spawnTrinketWithSeed = ____pickupsSpecific.spawnTrinketWithSeed
33
+ local ____projectiles = require("functions.projectiles")
34
+ local fireProjectilesInCircle = ____projectiles.fireProjectilesInCircle
35
+ local ____random = require("functions.random")
36
+ local getRandom = ____random.getRandom
37
+ local ____rng = require("functions.rng")
38
+ local getRandomSeed = ____rng.getRandomSeed
39
+ local isRNG = ____rng.isRNG
40
+ local newRNG = ____rng.newRNG
41
+ local ____spawnCollectible = require("functions.spawnCollectible")
42
+ local spawnCollectible = ____spawnCollectible.spawnCollectible
43
+ local ____utils = require("functions.utils")
44
+ local ____repeat = ____utils["repeat"]
45
+ local ____vector = require("functions.vector")
46
+ local getRandomVector = ____vector.getRandomVector
47
+ function spawnRockAltRewardUrn(self, position, rng)
48
+ local chance = getRandom(nil, rng)
49
+ local totalChance = 0
50
+ totalChance = totalChance + ROCK_ALT_CHANCES.Nothing
51
+ if chance < totalChance then
52
+ return false
53
+ end
54
+ totalChance = totalChance + ROCK_ALT_CHANCES.BasicDrop
55
+ if chance < totalChance then
56
+ local numCoinsChance = getRandom(nil, rng)
57
+ local numCoins = numCoinsChance < 0.5 and 1 or 2
58
+ local length = DISTANCE_OF_GRID_TILE
59
+ ____repeat(
60
+ nil,
61
+ numCoins,
62
+ function()
63
+ local randomVector = getRandomVector(nil, rng)
64
+ local velocity = randomVector * length
65
+ spawnCoinWithSeed(
66
+ nil,
67
+ CoinSubType.NULL,
68
+ position,
69
+ rng,
70
+ velocity
71
+ )
72
+ end
73
+ )
74
+ return true
75
+ end
76
+ totalChance = totalChance + ROCK_ALT_CHANCES.Trinket
77
+ if chance < totalChance then
78
+ spawnTrinketWithSeed(nil, TrinketType.SWALLOWED_PENNY, position, rng)
79
+ return true
80
+ end
81
+ totalChance = totalChance + ROCK_ALT_CHANCES.Collectible
82
+ if chance < totalChance then
83
+ local stillInPools = isCollectibleInItemPool(nil, CollectibleType.QUARTER, ItemPoolType.DEVIL)
84
+ if stillInPools then
85
+ spawnCollectible(nil, CollectibleType.QUARTER, position, rng)
86
+ return true
87
+ end
88
+ return false
89
+ end
90
+ local numSpidersChance = getRandom(nil, rng)
91
+ local numSpiders = numSpidersChance < 0.5 and 1 or 2
92
+ local length = DISTANCE_OF_GRID_TILE * 3
93
+ ____repeat(
94
+ nil,
95
+ numSpiders,
96
+ function()
97
+ local randomVector = getRandomVector(nil, rng)
98
+ local offset = randomVector * length
99
+ local targetPos = position + offset
100
+ EntityNPC.ThrowSpider(
101
+ position,
102
+ nil,
103
+ targetPos,
104
+ false,
105
+ 0
106
+ )
107
+ end
108
+ )
109
+ return true
110
+ end
111
+ function spawnRockAltRewardMushroom(self, position, rng)
112
+ local room = game:GetRoom()
113
+ local roomType = room:GetType()
114
+ local chance = getRandom(nil, rng)
115
+ local totalChance = 0
116
+ totalChance = totalChance + ROCK_ALT_CHANCES.Nothing
117
+ if chance < totalChance then
118
+ return false
119
+ end
120
+ totalChance = totalChance + ROCK_ALT_CHANCES.BasicDrop
121
+ if chance < totalChance then
122
+ spawnPillWithSeed(nil, PillColor.NULL, position, rng)
123
+ return true
124
+ end
125
+ totalChance = totalChance + ROCK_ALT_CHANCES.Trinket
126
+ if chance < totalChance then
127
+ spawnTrinketWithSeed(nil, TrinketType.LIBERTY_CAP, position, rng)
128
+ return true
129
+ end
130
+ totalChance = totalChance + ROCK_ALT_CHANCES.Collectible
131
+ if chance < totalChance then
132
+ if roomType == RoomType.SECRET then
133
+ local wavyCapChance = getRandom(nil, rng)
134
+ if wavyCapChance < 0.0272 then
135
+ local stillInPools = isCollectibleInItemPool(nil, CollectibleType.WAVY_CAP, ItemPoolType.SECRET)
136
+ if stillInPools then
137
+ spawnCollectible(nil, CollectibleType.WAVY_CAP, position, rng)
138
+ return true
139
+ end
140
+ end
141
+ end
142
+ local magicMushroomStillInPools = isCollectibleInItemPool(nil, CollectibleType.MAGIC_MUSHROOM, ItemPoolType.TREASURE)
143
+ local miniMushStillInPools = isCollectibleInItemPool(nil, CollectibleType.MINI_MUSH, ItemPoolType.TREASURE)
144
+ if magicMushroomStillInPools and miniMushStillInPools then
145
+ local collectibleChance = getRandom(nil, rng)
146
+ local collectibleType = collectibleChance < 0.5 and CollectibleType.MAGIC_MUSHROOM or CollectibleType.MINI_MUSH
147
+ spawnCollectible(nil, collectibleType, position, rng)
148
+ return true
149
+ end
150
+ if magicMushroomStillInPools then
151
+ spawnCollectible(nil, CollectibleType.MINI_MUSH, position, rng)
152
+ return true
153
+ end
154
+ if miniMushStillInPools then
155
+ spawnCollectible(nil, CollectibleType.MAGIC_MUSHROOM, position, rng)
156
+ return true
157
+ end
158
+ return false
159
+ end
160
+ spawnEffectWithSeed(
161
+ nil,
162
+ EffectVariant.FART,
163
+ 0,
164
+ position,
165
+ rng
166
+ )
167
+ return true
168
+ end
169
+ function spawnRockAltRewardSkull(self, position, rng)
170
+ local chance = getRandom(nil, rng)
171
+ local totalChance = 0
172
+ totalChance = totalChance + ROCK_ALT_CHANCES.Nothing
173
+ if chance < totalChance then
174
+ return false
175
+ end
176
+ totalChance = totalChance + ROCK_ALT_CHANCES.BasicDrop
177
+ if chance < totalChance then
178
+ spawnCardWithSeed(nil, Card.NULL, position, rng)
179
+ return true
180
+ end
181
+ totalChance = totalChance + ROCK_ALT_CHANCES.Trinket
182
+ if chance < totalChance then
183
+ spawnHeartWithSeed(nil, HeartSubType.BLACK, position, rng)
184
+ return true
185
+ end
186
+ totalChance = totalChance + ROCK_ALT_CHANCES.Collectible
187
+ if chance < totalChance then
188
+ local ghostBabyStillInPools = isCollectibleInItemPool(nil, CollectibleType.GHOST_BABY, ItemPoolType.TREASURE)
189
+ local dryBabyStillInPools = isCollectibleInItemPool(nil, CollectibleType.DRY_BABY, ItemPoolType.TREASURE)
190
+ if ghostBabyStillInPools and dryBabyStillInPools then
191
+ local collectibleChance = getRandom(nil, rng)
192
+ local collectibleType = collectibleChance < 0.5 and CollectibleType.GHOST_BABY or CollectibleType.DRY_BABY
193
+ spawnCollectible(nil, collectibleType, position, rng)
194
+ return true
195
+ end
196
+ if ghostBabyStillInPools then
197
+ spawnCollectible(nil, CollectibleType.DRY_BABY, position, rng)
198
+ return true
199
+ end
200
+ if dryBabyStillInPools then
201
+ spawnCollectible(nil, CollectibleType.GHOST_BABY, position, rng)
202
+ return true
203
+ end
204
+ return false
205
+ end
206
+ spawnNPCWithSeed(
207
+ nil,
208
+ EntityType.HOST,
209
+ 0,
210
+ 0,
211
+ position,
212
+ rng
213
+ )
214
+ return true
215
+ end
216
+ function spawnRockAltRewardPolyp(self, position, rng)
217
+ local chance = getRandom(nil, rng)
218
+ local totalChance = 0
219
+ totalChance = totalChance + ROCK_ALT_CHANCES.Nothing
220
+ if chance < totalChance then
221
+ return false
222
+ end
223
+ totalChance = totalChance + ROCK_ALT_CHANCES.BasicDrop
224
+ if chance < totalChance then
225
+ spawnHeartWithSeed(nil, HeartSubType.NULL, position, rng)
226
+ return true
227
+ end
228
+ totalChance = totalChance + ROCK_ALT_CHANCES.Trinket
229
+ if chance < totalChance then
230
+ spawnTrinketWithSeed(nil, TrinketType.UMBILICAL_CORD, position, rng)
231
+ return true
232
+ end
233
+ totalChance = totalChance + ROCK_ALT_CHANCES.Collectible
234
+ if chance < totalChance then
235
+ local placentaStillInPools = isCollectibleInItemPool(nil, CollectibleType.PLACENTA, ItemPoolType.BOSS)
236
+ local bloodClotStillInPools = isCollectibleInItemPool(nil, CollectibleType.BLOOD_CLOT, ItemPoolType.BOSS)
237
+ if bloodClotStillInPools and placentaStillInPools then
238
+ local collectibleChance = getRandom(nil, rng)
239
+ local collectibleType = collectibleChance < 0.5 and CollectibleType.PLACENTA or CollectibleType.BLOOD_CLOT
240
+ spawnCollectible(nil, collectibleType, position, rng)
241
+ return true
242
+ end
243
+ if bloodClotStillInPools then
244
+ spawnCollectible(nil, CollectibleType.MINI_MUSH, position, rng)
245
+ return true
246
+ end
247
+ if placentaStillInPools then
248
+ spawnCollectible(nil, CollectibleType.MAGIC_MUSHROOM, position, rng)
249
+ return true
250
+ end
251
+ return false
252
+ end
253
+ spawnEffectWithSeed(
254
+ nil,
255
+ EffectVariant.CREEP_RED,
256
+ 0,
257
+ position,
258
+ rng
259
+ )
260
+ fireProjectilesInCircle(
261
+ nil,
262
+ nil,
263
+ position,
264
+ POLYP_PROJECTILE_SPEED,
265
+ POLYP_NUM_PROJECTILES
266
+ )
267
+ return true
268
+ end
269
+ function spawnRockAltRewardBucket(self, _position, rng, _variant)
270
+ local chance = getRandom(nil, rng)
271
+ local totalChance = 0
272
+ totalChance = totalChance + ROCK_ALT_CHANCES.Nothing
273
+ if chance < totalChance then
274
+ return false
275
+ end
276
+ return false
277
+ end
278
+ ROCK_ALT_CHANCES = {Nothing = 0.68, BasicDrop = 0.0967, Trinket = 0.025, Collectible = 0.005}
279
+ POLYP_PROJECTILE_SPEED = 10
280
+ POLYP_NUM_PROJECTILES = 6
281
+ --- Helper function to get the alternate rock type (i.e. urn, mushroom, etc.) that the current room
282
+ -- will have.
283
+ --
284
+ -- The rock type is based on the backdrop of the room.
285
+ --
286
+ -- For example, if you change the backdrop of the starting room of the run to `BackdropType.CAVES`,
287
+ -- and then spawn `GridEntityType.ROCK_ALT`, it will be a mushroom instead of an urn. Additionally,
288
+ -- if it is destroyed, it will generate mushroom-appropriate rewards.
289
+ --
290
+ -- On the other hand, if an urn is spawned first before the backdrop is changed to
291
+ -- `BackdropType.CAVES`, the graphic of the urn will not switch to a mushroom. However, when
292
+ -- destroyed, the urn will still generate mushroom-appropriate rewards.
293
+ function ____exports.getRockAltType(self)
294
+ local room = game:GetRoom()
295
+ local backdropType = room:GetBackdropType()
296
+ return BACKDROP_TYPE_TO_ROCK_ALT_TYPE[backdropType]
297
+ end
298
+ --- Helper function for emulating what happens when a vanilla `GridEntityType.ROCK_ALT` grid entity
299
+ -- breaks.
300
+ --
301
+ -- Most of the time, this function will do nothing, similar to how most of the time, when an
302
+ -- individual urn is destroyed, nothing will spawn.
303
+ --
304
+ -- Note that in vanilla, trinkets will not spawn if they have already been removed from the trinket
305
+ -- pool. This function cannot replicate that behavior because there is no way to check to see if a
306
+ -- trinket is still in the pool. Thus, it will always have a chance to spawn the respective trinket
307
+ -- (e.g. Swallowed Penny from urns).
308
+ --
309
+ -- The logic in this function is based on the rewards listed on the wiki:
310
+ -- https://bindingofisaacrebirth.fandom.com/wiki/Rocks
311
+ --
312
+ -- @param position The place to spawn the reward.
313
+ -- @param rockAltType The type of reward to spawn. For example, `RockAltType.URN` will have a chance
314
+ -- at spawning coins and spiders.
315
+ -- @param variant Optional. The variant of the grid entity to emulate. Default is 0, which
316
+ -- corresponds to a "normal" grid entity or an empty bucket. This only matters when
317
+ -- spawning the reward for buckets. (Empty buckets have different rewards than full
318
+ -- buckets.)
319
+ -- @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
320
+ -- `RNG.Next` method will be called. Default is `getRandomSeed()`. Normally, you
321
+ -- should pass the `InitSeed` of the grid entity that was broken.
322
+ -- @returns Whether or not this function spawned something.
323
+ function ____exports.spawnRockAltReward(self, position, rockAltType, variant, seedOrRNG)
324
+ if variant == nil then
325
+ variant = 0
326
+ end
327
+ if seedOrRNG == nil then
328
+ seedOrRNG = getRandomSeed(nil)
329
+ end
330
+ local rng = isRNG(nil, seedOrRNG) and seedOrRNG or newRNG(nil, seedOrRNG)
331
+ repeat
332
+ local ____switch4 = rockAltType
333
+ local ____cond4 = ____switch4 == RockAltType.URN
334
+ if ____cond4 then
335
+ do
336
+ return spawnRockAltRewardUrn(nil, position, rng)
337
+ end
338
+ end
339
+ ____cond4 = ____cond4 or ____switch4 == RockAltType.MUSHROOM
340
+ if ____cond4 then
341
+ do
342
+ return spawnRockAltRewardMushroom(nil, position, rng)
343
+ end
344
+ end
345
+ ____cond4 = ____cond4 or ____switch4 == RockAltType.SKULL
346
+ if ____cond4 then
347
+ do
348
+ return spawnRockAltRewardSkull(nil, position, rng)
349
+ end
350
+ end
351
+ ____cond4 = ____cond4 or ____switch4 == RockAltType.POLYP
352
+ if ____cond4 then
353
+ do
354
+ return spawnRockAltRewardPolyp(nil, position, rng)
355
+ end
356
+ end
357
+ ____cond4 = ____cond4 or ____switch4 == RockAltType.BUCKET
358
+ if ____cond4 then
359
+ do
360
+ return spawnRockAltRewardBucket(nil, position, rng, variant)
361
+ end
362
+ end
363
+ until true
364
+ end
365
+ return ____exports
@@ -1,16 +1,17 @@
1
1
  import { CollectibleType, ItemPoolType } from "isaac-typescript-definitions";
2
2
  /**
3
- * Helper function to see if the given collectible is unlocked on the player's save file. This
3
+ * Helper function to see if the given collectible is unlocked on the current save file. This
4
4
  * requires providing the corresponding item pool that the collectible is located in.
5
5
  *
6
- * - If any player currently has the item, then it is assumed to be unlocked. (This is because Eden
7
- * may have randomly started with the provided collectible, and it will be subsequently removed
8
- * from all pools.)
6
+ * - If any player currently has the collectible, then it is assumed to be unlocked. (This is
7
+ * because in almost all cases, when a collectible is added to a player's inventory, it is
8
+ * subsequently removed from all pools.)
9
9
  * - If the collectible is located in more than one item pool, then any item pool can be provided.
10
10
  * - If the collectible is not located in any item pools, then this function will always return
11
11
  * false.
12
- * - If any player is Tainted Lost, they will be temporarily changed to Isaac and then temporarily
13
- * changed back (because Tainted Lost is not able to retrieve some collectibles from item pools).
12
+ * - If the collectible is non-offensive, any Tainted Losts will be temporarily changed to Isaac and
13
+ * then changed back. (This is because Tainted Lost is not able to retrieve non-offensive
14
+ * collectibles from item pools).
14
15
  */
15
- export declare function isCollectibleUnlocked(collectibleTypeToCheckFor: CollectibleType, itemPoolToCheckFor: ItemPoolType): boolean;
16
+ export declare function isCollectibleUnlocked(collectibleType: CollectibleType, itemPoolType: ItemPoolType): boolean;
16
17
  //# sourceMappingURL=saveFile.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"saveFile.d.ts","sourceRoot":"","sources":["../../src/functions/saveFile.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,YAAY,EAGb,MAAM,8BAA8B,CAAC;AAmBtC;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CACnC,yBAAyB,EAAE,eAAe,EAC1C,kBAAkB,EAAE,YAAY,GAC/B,OAAO,CA4FT"}
1
+ {"version":3,"file":"saveFile.d.ts","sourceRoot":"","sources":["../../src/functions/saveFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAG7E;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CACnC,eAAe,EAAE,eAAe,EAChC,YAAY,EAAE,YAAY,GACzB,OAAO,CAMT"}
@@ -1,108 +1,22 @@
1
- local ____lualib = require("lualib_bundle")
2
- local Map = ____lualib.Map
3
- local __TS__New = ____lualib.__TS__New
4
- local __TS__Iterator = ____lualib.__TS__Iterator
5
1
  local ____exports = {}
6
- local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
7
- local CollectibleType = ____isaac_2Dtypescript_2Ddefinitions.CollectibleType
8
- local PlayerType = ____isaac_2Dtypescript_2Ddefinitions.PlayerType
9
- local TrinketType = ____isaac_2Dtypescript_2Ddefinitions.TrinketType
10
- local ____cachedClasses = require("cachedClasses")
11
- local game = ____cachedClasses.game
12
- local ____collectibleSet = require("functions.collectibleSet")
13
- local getCollectibleSet = ____collectibleSet.getCollectibleSet
14
- local ____playerDataStructures = require("functions.playerDataStructures")
15
- local mapGetPlayer = ____playerDataStructures.mapGetPlayer
16
- local mapSetPlayer = ____playerDataStructures.mapSetPlayer
17
- local ____playerIndex = require("functions.playerIndex")
18
- local getPlayers = ____playerIndex.getPlayers
19
2
  local ____players = require("functions.players")
20
3
  local anyPlayerHasCollectible = ____players.anyPlayerHasCollectible
21
- local getPlayersOfType = ____players.getPlayersOfType
22
- local ____utils = require("functions.utils")
23
- local ____repeat = ____utils["repeat"]
24
- local COLLECTIBLES_THAT_AFFECT_ITEM_POOLS = {CollectibleType.CHAOS, CollectibleType.SACRED_ORB, CollectibleType.TMTRAINER}
25
- local TRINKETS_THAT_AFFECT_ITEM_POOLS = {TrinketType.NO}
26
- --- Helper function to see if the given collectible is unlocked on the player's save file. This
4
+ --- Helper function to see if the given collectible is unlocked on the current save file. This
27
5
  -- requires providing the corresponding item pool that the collectible is located in.
28
6
  --
29
- -- - If any player currently has the item, then it is assumed to be unlocked. (This is because Eden
30
- -- may have randomly started with the provided collectible, and it will be subsequently removed
31
- -- from all pools.)
7
+ -- - If any player currently has the collectible, then it is assumed to be unlocked. (This is
8
+ -- because in almost all cases, when a collectible is added to a player's inventory, it is
9
+ -- subsequently removed from all pools.)
32
10
  -- - If the collectible is located in more than one item pool, then any item pool can be provided.
33
11
  -- - If the collectible is not located in any item pools, then this function will always return
34
12
  -- false.
35
- -- - If any player is Tainted Lost, they will be temporarily changed to Isaac and then temporarily
36
- -- changed back (because Tainted Lost is not able to retrieve some collectibles from item pools).
37
- function ____exports.isCollectibleUnlocked(self, collectibleTypeToCheckFor, itemPoolToCheckFor)
38
- if anyPlayerHasCollectible(nil, collectibleTypeToCheckFor) then
13
+ -- - If the collectible is non-offensive, any Tainted Losts will be temporarily changed to Isaac and
14
+ -- then changed back. (This is because Tainted Lost is not able to retrieve non-offensive
15
+ -- collectibles from item pools).
16
+ function ____exports.isCollectibleUnlocked(self, collectibleType, itemPoolType)
17
+ if anyPlayerHasCollectible(nil, collectibleType) then
39
18
  return true
40
19
  end
41
- local taintedLosts = getPlayersOfType(nil, PlayerType.THE_LOST_B)
42
- for ____, player in ipairs(taintedLosts) do
43
- player:ChangePlayerType(PlayerType.ISAAC)
44
- end
45
- local removedItemsMap = __TS__New(Map)
46
- local removedTrinketsMap = __TS__New(Map)
47
- for ____, player in ipairs(getPlayers(nil)) do
48
- local removedItems = {}
49
- for ____, itemToRemove in ipairs(COLLECTIBLES_THAT_AFFECT_ITEM_POOLS) do
50
- if player:HasCollectible(itemToRemove) then
51
- local numCollectibles = player:GetCollectibleNum(itemToRemove)
52
- ____repeat(
53
- nil,
54
- numCollectibles,
55
- function()
56
- player:RemoveCollectible(itemToRemove)
57
- removedItems[#removedItems + 1] = itemToRemove
58
- end
59
- )
60
- end
61
- end
62
- mapSetPlayer(nil, removedItemsMap, player, removedItems)
63
- local removedTrinkets = {}
64
- for ____, trinketToRemove in ipairs(TRINKETS_THAT_AFFECT_ITEM_POOLS) do
65
- if player:HasTrinket(trinketToRemove) then
66
- local numTrinkets = player:GetTrinketMultiplier(trinketToRemove)
67
- ____repeat(
68
- nil,
69
- numTrinkets,
70
- function()
71
- player:TryRemoveTrinket(trinketToRemove)
72
- removedTrinkets[#removedTrinkets + 1] = trinketToRemove
73
- end
74
- )
75
- end
76
- end
77
- mapSetPlayer(nil, removedTrinketsMap, player, removedTrinkets)
78
- end
79
- local itemPool = game:GetItemPool()
80
- local collectibleSet = getCollectibleSet(nil)
81
- for ____, collectibleType in __TS__Iterator(collectibleSet:values()) do
82
- if collectibleType ~= collectibleTypeToCheckFor then
83
- itemPool:AddRoomBlacklist(collectibleType)
84
- end
85
- end
86
- local retrievedCollectibleType = itemPool:GetCollectible(itemPoolToCheckFor, false, 1)
87
- local collectibleUnlocked = retrievedCollectibleType == collectibleTypeToCheckFor
88
- itemPool:ResetRoomBlacklist()
89
- for ____, player in ipairs(getPlayers(nil)) do
90
- local removedItems = mapGetPlayer(nil, removedItemsMap, player)
91
- if removedItems ~= nil then
92
- for ____, collectibleType in ipairs(removedItems) do
93
- player:AddCollectible(collectibleType, 0, false)
94
- end
95
- end
96
- local removedTrinkets = mapGetPlayer(nil, removedTrinketsMap, player)
97
- if removedTrinkets ~= nil then
98
- for ____, trinketType in ipairs(removedTrinkets) do
99
- player:AddTrinket(trinketType, false)
100
- end
101
- end
102
- end
103
- for ____, player in ipairs(taintedLosts) do
104
- player:ChangePlayerType(PlayerType.THE_LOST_B)
105
- end
106
- return collectibleUnlocked
20
+ return ____exports.isCollectibleUnlocked(nil, collectibleType, itemPoolType)
107
21
  end
108
22
  return ____exports
@@ -1,12 +1,31 @@
1
- import { SerializationType } from "../enums/SerializationType";
2
- import { SerializedIsaacAPIClass } from "../types/private/SerializedIsaacAPIClass";
3
- export declare function copyIsaacAPIClass(isaacAPIClass: unknown, serializationType: SerializationType): unknown;
1
+ import { SerializedIsaacAPIClass } from "../types/SerializedIsaacAPIClass";
4
2
  /**
5
- * Deserialization is a special case, so we make a dedicated function for this.
3
+ * Helper function to generically copy an Isaac API class without knowing what specific type of
4
+ * class it is. (This is used by the save data manager.)
6
5
  *
7
- * There is no need for a corresponding "serializeIsaacAPIClass" function because the
8
- * "copyIsaacAPIClass" function can handle all serialization types.
6
+ * For the list of supported classes, see the `CopyableIsaacAPIClassType` enum.
7
+ */
8
+ export declare function copyIsaacAPIClass(isaacAPIClass: unknown): unknown;
9
+ /**
10
+ * Helper function to generically deserialize an Isaac API class without knowing what specific type
11
+ * of class it is. (This is used by the save data manager when reading data from the "save#.dat"
12
+ * file.)
13
+ *
14
+ * For the list of supported classes, see the `CopyableIsaacAPIClassType` enum.
15
+ */
16
+ export declare function deserializeIsaacAPIClass(serializedIsaacAPIClass: unknown): unknown;
17
+ /**
18
+ * Helper function to generically check if a given Lua table is a serialized Isaac API class. (This
19
+ * is used by the save data manager when reading data from the "save#.dat" file.)
20
+ *
21
+ * For the list of supported classes, see the `CopyableIsaacAPIClassType` enum.
9
22
  */
10
- export declare function deserializeIsaacAPIClass(serializedIsaacAPIClass: SerializedIsaacAPIClass): unknown;
11
23
  export declare function isSerializedIsaacAPIClass(object: unknown): object is SerializedIsaacAPIClass;
24
+ /**
25
+ * Helper function to generically serialize an Isaac API class without knowing what specific type of
26
+ * class it is. (This is used by the save data manager when writing data to the "save#.dat" file.)
27
+ *
28
+ * For the list of supported classes, see the `CopyableIsaacAPIClassType` enum.
29
+ */
30
+ export declare function serializeIsaacAPIClass(isaacAPIClass: unknown): unknown;
12
31
  //# sourceMappingURL=serialization.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../../src/functions/serialization.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAI/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AAInF,wBAAgB,iBAAiB,CAC/B,aAAa,EAAE,OAAO,EACtB,iBAAiB,EAAE,iBAAiB,GACnC,OAAO,CA0BT;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,uBAAuB,EAAE,uBAAuB,GAC/C,OAAO,CAmBT;AAgBD,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,OAAO,GACd,MAAM,IAAI,uBAAuB,CAKnC"}
1
+ {"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../../src/functions/serialization.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAI3E;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,OAAO,GAAG,OAAO,CA0BjE;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,uBAAuB,EAAE,OAAO,GAC/B,OAAO,CA0BT;AAoBD;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,OAAO,GACd,MAAM,IAAI,uBAAuB,CAQnC;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,aAAa,EAAE,OAAO,GAAG,OAAO,CA0BtE"}