isaacscript-common 3.15.2 → 3.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 (47) hide show
  1. package/callbacks/postPlayerFatalDamage.lua +3 -3
  2. package/callbacks/postSlotDestroyed.lua +9 -7
  3. package/callbacks/subscriptions/postSlotDestroyed.d.ts +4 -2
  4. package/callbacks/subscriptions/postSlotDestroyed.lua +8 -4
  5. package/classes/DefaultMap.lua +6 -4
  6. package/constants.d.ts +2 -0
  7. package/constants.lua +2 -0
  8. package/enums/ModCallbackCustom.d.ts +10 -8
  9. package/enums/SlotDestructionType.d.ts +4 -0
  10. package/enums/SlotDestructionType.lua +7 -0
  11. package/features/deployJSONRoom.lua +62 -17
  12. package/features/saveDataManager/exports.lua +7 -6
  13. package/features/saveDataManager/load.lua +7 -5
  14. package/features/saveDataManager/main.lua +2 -2
  15. package/features/saveDataManager/merge.lua +12 -16
  16. package/features/saveDataManager/save.lua +2 -2
  17. package/features/saveDataManager/serializationBrand.lua +3 -1
  18. package/functions/array.d.ts +1 -0
  19. package/functions/array.lua +18 -12
  20. package/functions/color.lua +6 -7
  21. package/functions/deepCopy.lua +27 -24
  22. package/functions/deepCopyTests.lua +23 -27
  23. package/functions/entity.d.ts +4 -1
  24. package/functions/entity.lua +22 -25
  25. package/functions/enums.lua +3 -1
  26. package/functions/gridEntity.d.ts +3 -3
  27. package/functions/gridEntity.lua +7 -7
  28. package/functions/isaacAPIClass.lua +5 -3
  29. package/functions/jsonHelpers.d.ts +1 -1
  30. package/functions/jsonHelpers.lua +4 -4
  31. package/functions/kColor.lua +6 -7
  32. package/functions/log.d.ts +9 -2
  33. package/functions/log.lua +30 -21
  34. package/functions/rng.lua +10 -12
  35. package/functions/serialization.d.ts +1 -1
  36. package/functions/serialization.lua +9 -7
  37. package/functions/table.d.ts +14 -10
  38. package/functions/table.lua +54 -37
  39. package/functions/tstlClass.lua +6 -4
  40. package/functions/types.d.ts +10 -0
  41. package/functions/types.lua +25 -0
  42. package/functions/utils.d.ts +0 -2
  43. package/functions/utils.lua +0 -6
  44. package/functions/vector.lua +6 -7
  45. package/index.d.ts +1 -0
  46. package/index.lua +8 -0
  47. package/package.json +2 -2
@@ -70,10 +70,10 @@ function entityTakeDmgPlayer(self, tookDamage, damageAmount, damageFlags, damage
70
70
  end
71
71
  function preUseItemBible(self, _collectibleType, _rng, player)
72
72
  if not hasSubscriptions(nil) then
73
- return false
73
+ return nil
74
74
  end
75
75
  if not inBossRoomOf(nil, BossID.SATAN) then
76
- return false
76
+ return nil
77
77
  end
78
78
  local shouldSustainDeath = postPlayerFatalDamageFire(
79
79
  nil,
@@ -86,7 +86,7 @@ function preUseItemBible(self, _collectibleType, _rng, player)
86
86
  if shouldSustainDeath ~= nil then
87
87
  return not shouldSustainDeath
88
88
  end
89
- return false
89
+ return nil
90
90
  end
91
91
  v = {run = {playersLastDamageGameFrame = __TS__New(Map)}}
92
92
  ---
@@ -3,14 +3,17 @@ local Set = ____lualib.Set
3
3
  local __TS__New = ____lualib.__TS__New
4
4
  local Map = ____lualib.Map
5
5
  local ____exports = {}
6
- local hasSubscriptions, postEntityRemove, postSlotAnimationChanged, BROKEN_ANIMATIONS, PRIZE_GAME_FRAME_DELAY_UNTIL_REMOVAL, v
6
+ local hasSubscriptions, postEntityRemove, postSlotAnimationChanged, PRIZE_GAME_FRAME_DELAY_UNTIL_REMOVAL, v
7
7
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
8
+ local EntityGridCollisionClass = ____isaac_2Dtypescript_2Ddefinitions.EntityGridCollisionClass
8
9
  local EntityType = ____isaac_2Dtypescript_2Ddefinitions.EntityType
9
10
  local ModCallback = ____isaac_2Dtypescript_2Ddefinitions.ModCallback
10
11
  local ____cachedClasses = require("cachedClasses")
11
12
  local game = ____cachedClasses.game
12
13
  local ____ModCallbackCustom = require("enums.ModCallbackCustom")
13
14
  local ModCallbackCustom = ____ModCallbackCustom.ModCallbackCustom
15
+ local ____SlotDestructionType = require("enums.SlotDestructionType")
16
+ local SlotDestructionType = ____SlotDestructionType.SlotDestructionType
14
17
  local ____exports = require("features.saveDataManager.exports")
15
18
  local saveDataManager = ____exports.saveDataManager
16
19
  local ____postSlotDestroyed = require("callbacks.subscriptions.postSlotDestroyed")
@@ -28,7 +31,7 @@ function postEntityRemove(self, entity)
28
31
  return
29
32
  end
30
33
  if prizeFrame + PRIZE_GAME_FRAME_DELAY_UNTIL_REMOVAL == gameFrameCount then
31
- postSlotDestroyedFire(nil, slot)
34
+ postSlotDestroyedFire(nil, slot, SlotDestructionType.COLLECTIBLE_PAYOUT)
32
35
  end
33
36
  end
34
37
  function postSlotAnimationChanged(self, slot)
@@ -38,19 +41,18 @@ function postSlotAnimationChanged(self, slot)
38
41
  if alreadyBroken then
39
42
  return
40
43
  end
41
- local sprite = slot:GetSprite()
42
- local animation = sprite:GetAnimation()
43
- if BROKEN_ANIMATIONS:has(animation) then
44
+ if slot.GridCollisionClass == EntityGridCollisionClass.GROUND then
44
45
  v.room.brokenSlots:add(ptrHash)
45
- postSlotDestroyedFire(nil, slot)
46
+ postSlotDestroyedFire(nil, slot, SlotDestructionType.NORMAL)
46
47
  end
48
+ local sprite = slot:GetSprite()
49
+ local animation = sprite:GetAnimation()
47
50
  if animation == "Prize" then
48
51
  v.room.slotPrizeAnimationGameFrame:set(ptrHash, gameFrameCount)
49
52
  else
50
53
  v.room.slotPrizeAnimationGameFrame:delete(ptrHash)
51
54
  end
52
55
  end
53
- BROKEN_ANIMATIONS = __TS__New(Set, {"Broken", "Death"})
54
56
  PRIZE_GAME_FRAME_DELAY_UNTIL_REMOVAL = 3
55
57
  v = {room = {
56
58
  brokenSlots = __TS__New(Set),
@@ -1,5 +1,7 @@
1
1
  import { SlotVariant } from "isaac-typescript-definitions";
2
+ import { SlotDestructionType } from "../../enums/SlotDestructionType";
2
3
  export declare type PostSlotDestroyedRegisterParameters = [
3
- callback: (slot: EntitySlot) => void,
4
- slotVariant?: SlotVariant
4
+ callback: (slot: EntitySlot, slotDestructionType: SlotDestructionType) => void,
5
+ slotVariant?: SlotVariant,
6
+ slotDestructionType?: SlotDestructionType
5
7
  ];
@@ -13,15 +13,19 @@ function ____exports.postSlotDestroyedRegister(self, ...)
13
13
  end
14
14
  ---
15
15
  -- @internal
16
- function ____exports.postSlotDestroyedFire(self, slot)
16
+ function ____exports.postSlotDestroyedFire(self, slot, slotDestructionType)
17
17
  for ____, ____value in ipairs(subscriptions) do
18
18
  local callback = ____value[1]
19
- local slotVariant = ____value[2]
19
+ local callbackSlotVariant = ____value[2]
20
+ local callbackSlotDestructionType = ____value[3]
20
21
  do
21
- if slotVariant ~= nil and slotVariant ~= slot.Variant then
22
+ if callbackSlotVariant ~= nil and callbackSlotVariant ~= slot.Variant then
22
23
  goto __continue5
23
24
  end
24
- callback(nil, slot)
25
+ if callbackSlotDestructionType ~= nil and callbackSlotDestructionType ~= slotDestructionType then
26
+ goto __continue5
27
+ end
28
+ callback(nil, slot, slotDestructionType)
25
29
  end
26
30
  ::__continue5::
27
31
  end
@@ -4,6 +4,9 @@ local Map = ____lualib.Map
4
4
  local __TS__ClassExtends = ____lualib.__TS__ClassExtends
5
5
  local __TS__TypeOf = ____lualib.__TS__TypeOf
6
6
  local ____exports = {}
7
+ local ____types = require("functions.types")
8
+ local isFunction = ____types.isFunction
9
+ local isPrimitive = ____types.isPrimitive
7
10
  --- `DefaultMap` is a data structure that makes working with default values easier.
8
11
  --
9
12
  -- It is a common pattern to look up a value in a `Map`, and then, if the value does not exist, set
@@ -87,11 +90,10 @@ local DefaultMap = ____exports.DefaultMap
87
90
  DefaultMap.name = "DefaultMap"
88
91
  __TS__ClassExtends(DefaultMap, Map)
89
92
  function DefaultMap.prototype.____constructor(self, defaultValueOrFactoryFunction, initializerArray)
90
- local argType = __TS__TypeOf(defaultValueOrFactoryFunction)
91
- local argIsPrimitive = argType == "boolean" or argType == "number" or argType == "string"
92
- local argIsFunction = argType == "function"
93
+ local argIsPrimitive = isPrimitive(nil, defaultValueOrFactoryFunction)
94
+ local argIsFunction = isFunction(nil, defaultValueOrFactoryFunction)
93
95
  if not argIsPrimitive and not argIsFunction then
94
- error(("Failed to instantiate a DefaultMap since the provided default value was of type \"" .. argType) .. "\". This error usually means that you are trying to use an array (or some other non-primitive data structure that is passed by reference) as the default value. Instead, return the data structure in a factory function, like \"() => []\". See the DefaultMap documentation for more details.")
96
+ error(("Failed to instantiate a DefaultMap since the provided default value was of type \"" .. __TS__TypeOf(defaultValueOrFactoryFunction)) .. "\". This error usually means that you are trying to use an array (or some other non-primitive data structure that is passed by reference) as the default value. Instead, return the data structure in a factory function, like \"() => []\". See the DefaultMap documentation for more details.")
95
97
  end
96
98
  Map.prototype.____constructor(self, initializerArray)
97
99
  if argIsFunction then
package/constants.d.ts CHANGED
@@ -14,6 +14,8 @@ export declare const AZAZEL_DEFAULT_BRIMSTONE_DISTANCE = 75.125;
14
14
  export declare const BLIND_ITEM_PNG_PATH = "gfx/items/collectibles/questionmark.png";
15
15
  /** Bombs explode when their frame count is equal to this value. */
16
16
  export declare const BOMB_EXPLODE_FRAME = 45;
17
+ /** This is the initial value of the `EntityPickup.Wait` property after a collectible is spawned. */
18
+ export declare const COLLECTIBLE_STARTING_WAIT = 20;
17
19
  export declare const DEFAULT_ITEM_POOL_TYPE = ItemPoolType.TREASURE;
18
20
  /** This is also the distance that a player spawns from the door that they enter a room from. */
19
21
  export declare const DISTANCE_OF_GRID_TILE = 40;
package/constants.lua CHANGED
@@ -18,6 +18,8 @@ ____exports.AZAZEL_DEFAULT_BRIMSTONE_DISTANCE = 75.125
18
18
  ____exports.BLIND_ITEM_PNG_PATH = "gfx/items/collectibles/questionmark.png"
19
19
  --- Bombs explode when their frame count is equal to this value.
20
20
  ____exports.BOMB_EXPLODE_FRAME = 45
21
+ --- This is the initial value of the `EntityPickup.Wait` property after a collectible is spawned.
22
+ ____exports.COLLECTIBLE_STARTING_WAIT = 20
21
23
  ____exports.DEFAULT_ITEM_POOL_TYPE = ItemPoolType.TREASURE
22
24
  --- This is also the distance that a player spawns from the door that they enter a room from.
23
25
  ____exports.DISTANCE_OF_GRID_TILE = 40
@@ -421,7 +421,7 @@ export declare enum ModCallbackCustom {
421
421
  * ```ts
422
422
  * function postItemDischarge(
423
423
  * player: EntityPlayer,
424
- * collectibleType: CollectibleType | int,
424
+ * collectibleType: CollectibleType,
425
425
  * activeSlot: ActiveSlot,
426
426
  * ): void {}
427
427
  * ```
@@ -692,8 +692,8 @@ export declare enum ModCallbackCustom {
692
692
  * ```ts
693
693
  * function postPlayerChangeType(
694
694
  * player: EntityPlayer,
695
- * oldCharacter: PlayerType | int,
696
- * newCharacter: PlayerType | int,
695
+ * oldCharacter: PlayerType,
696
+ * newCharacter: PlayerType,
697
697
  * ) {}
698
698
  * ```
699
699
  */
@@ -734,7 +734,7 @@ export declare enum ModCallbackCustom {
734
734
  * prevent the fatal damage.
735
735
  *
736
736
  * Note that this function does properly take into account Guppy's Collar, Broken Ankh, Spirit
737
- * Shackles, and Mysterious Paper.
737
+ * Shackles, and Mysterious Paper. It also takes into account using The Bible on Satan.
738
738
  *
739
739
  * - When registering the callback, takes an optional second argument that will make the callback
740
740
  * only fire if the player matches the `PlayerVariant` provided.
@@ -964,11 +964,13 @@ export declare enum ModCallbackCustom {
964
964
  * Fires from the `POST_RENDER` callback when a slot plays the animation that indicates that it
965
965
  * has broken.
966
966
  *
967
- * When registering the callback, takes an optional second argument that will make the callback
968
- * only fire if it matches the `SlotVariant` provided.
967
+ * - When registering the callback, takes an optional second argument that will make the callback
968
+ * only fire if it matches the `SlotVariant` provided.
969
+ * - When registering the callback, takes an optional third argument that will make the callback
970
+ * only fire if the destruction type matches the `SlotDestructionType` provided.
969
971
  *
970
972
  * ```ts
971
- * function postSlotDestroyed(slot: Entity): void {}
973
+ * function postSlotDestroyed(slot: Entity, slotDestructionType: SlotDestructionType): void {}
972
974
  * ```
973
975
  */
974
976
  POST_SLOT_DESTROYED = 66,
@@ -1110,7 +1112,7 @@ export declare enum ModCallbackCustom {
1110
1112
  * ```ts
1111
1113
  * function postTrinketBreak(
1112
1114
  * player: EntityPlayer,
1113
- * trinketType: TrinketType | int,
1115
+ * trinketType: TrinketType,
1114
1116
  * ): void {}
1115
1117
  * ```
1116
1118
  */
@@ -0,0 +1,4 @@
1
+ export declare enum SlotDestructionType {
2
+ NORMAL = 0,
3
+ COLLECTIBLE_PAYOUT = 1
4
+ }
@@ -0,0 +1,7 @@
1
+ local ____exports = {}
2
+ ____exports.SlotDestructionType = {}
3
+ ____exports.SlotDestructionType.NORMAL = 0
4
+ ____exports.SlotDestructionType[____exports.SlotDestructionType.NORMAL] = "NORMAL"
5
+ ____exports.SlotDestructionType.COLLECTIBLE_PAYOUT = 1
6
+ ____exports.SlotDestructionType[____exports.SlotDestructionType.COLLECTIBLE_PAYOUT] = "COLLECTIBLE_PAYOUT"
7
+ return ____exports
@@ -4,14 +4,16 @@ local __TS__New = ____lualib.__TS__New
4
4
  local Map = ____lualib.Map
5
5
  local __TS__Iterator = ____lualib.__TS__Iterator
6
6
  local ____exports = {}
7
- local postNewRoomReordered, setDecorationsInvisible, respawnPersistentEntities, removeSpecificNPCs, fillRoomWithDecorations, spawnAllEntities, spawnGridEntityForJSONRoom, spawnNormalEntityForJSONRoom, storePersistentEntity, fixPitGraphics, getPitMap, getPitFrame, FEATURE_NAME, NPC_TYPES_TO_NOT_REMOVE, PERSISTENT_ENTITY_TYPES, v
7
+ local preUseItemWeNeedToGoDeeper, postNewRoomReordered, setDecorationsInvisible, respawnPersistentEntities, removeSpecificNPCs, fillRoomWithDecorations, spawnAllEntities, spawnGridEntityForJSONRoom, spawnNormalEntityForJSONRoom, storePersistentEntity, fixPitGraphics, getPitMap, getPitFrame, FEATURE_NAME, NPC_TYPES_TO_NOT_REMOVE, PERSISTENT_ENTITY_TYPES, v
8
8
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
9
+ local CollectibleType = ____isaac_2Dtypescript_2Ddefinitions.CollectibleType
9
10
  local EffectVariant = ____isaac_2Dtypescript_2Ddefinitions.EffectVariant
10
11
  local EntityCollisionClass = ____isaac_2Dtypescript_2Ddefinitions.EntityCollisionClass
11
12
  local EntityFlag = ____isaac_2Dtypescript_2Ddefinitions.EntityFlag
12
13
  local EntityGridCollisionClass = ____isaac_2Dtypescript_2Ddefinitions.EntityGridCollisionClass
13
14
  local EntityType = ____isaac_2Dtypescript_2Ddefinitions.EntityType
14
15
  local GridEntityType = ____isaac_2Dtypescript_2Ddefinitions.GridEntityType
16
+ local ModCallback = ____isaac_2Dtypescript_2Ddefinitions.ModCallback
15
17
  local PickupVariant = ____isaac_2Dtypescript_2Ddefinitions.PickupVariant
16
18
  local PitfallVariant = ____isaac_2Dtypescript_2Ddefinitions.PitfallVariant
17
19
  local RoomType = ____isaac_2Dtypescript_2Ddefinitions.RoomType
@@ -23,6 +25,8 @@ local ____ModCallbackCustom = require("enums.ModCallbackCustom")
23
25
  local ModCallbackCustom = ____ModCallbackCustom.ModCallbackCustom
24
26
  local ____featuresInitialized = require("featuresInitialized")
25
27
  local errorIfFeaturesNotInitialized = ____featuresInitialized.errorIfFeaturesNotInitialized
28
+ local ____array = require("functions.array")
29
+ local emptyArray = ____array.emptyArray
26
30
  local ____entity = require("functions.entity")
27
31
  local removeAllMatchingEntities = ____entity.removeAllMatchingEntities
28
32
  local spawn = ____entity.spawn
@@ -35,6 +39,7 @@ local ____gridEntity = require("functions.gridEntity")
35
39
  local convertXMLGridEntityType = ____gridEntity.convertXMLGridEntityType
36
40
  local getGridEntities = ____gridEntity.getGridEntities
37
41
  local removeAllGridExcept = ____gridEntity.removeAllGridExcept
42
+ local removeGrid = ____gridEntity.removeGrid
38
43
  local setGridEntityInvisible = ____gridEntity.setGridEntityInvisible
39
44
  local spawnGridWithVariant = ____gridEntity.spawnGridWithVariant
40
45
  local ____jsonRoom = require("functions.jsonRoom")
@@ -56,8 +61,44 @@ local ____spawnCollectible = require("functions.spawnCollectible")
56
61
  local spawnCollectible = ____spawnCollectible.spawnCollectible
57
62
  local ____utils = require("functions.utils")
58
63
  local erange = ____utils.erange
64
+ local ____runInNFrames = require("features.runInNFrames")
65
+ local runNextGameFrame = ____runInNFrames.runNextGameFrame
59
66
  local ____exports = require("features.saveDataManager.exports")
60
67
  local saveDataManager = ____exports.saveDataManager
68
+ function preUseItemWeNeedToGoDeeper(self, _collectibleType, _rng, player)
69
+ if v.room.manuallyUsingShovel then
70
+ return nil
71
+ end
72
+ local roomListIndex = getRoomListIndex(nil)
73
+ if not v.level.deployedRoomListIndexes:has(roomListIndex) then
74
+ return nil
75
+ end
76
+ local decorations = getGridEntities(nil, GridEntityType.DECORATION)
77
+ for ____, decoration in ipairs(decorations) do
78
+ removeGrid(nil, decoration, false)
79
+ end
80
+ local playerPtr = EntityPtr(player)
81
+ runNextGameFrame(
82
+ nil,
83
+ function()
84
+ local futureEntity = playerPtr.Ref
85
+ if futureEntity == nil then
86
+ return
87
+ end
88
+ local futurePlayer = futureEntity:ToPlayer()
89
+ if futurePlayer == nil then
90
+ return
91
+ end
92
+ v.room.manuallyUsingShovel = true
93
+ futurePlayer:UseActiveItem(CollectibleType.WE_NEED_TO_GO_DEEPER)
94
+ v.room.manuallyUsingShovel = false
95
+ local decorationGridIndexes = v.level.roomToDecorationGridIndexesMap:getAndSetDefault(roomListIndex)
96
+ emptyArray(nil, decorationGridIndexes)
97
+ fillRoomWithDecorations(nil)
98
+ end
99
+ )
100
+ return true
101
+ end
61
102
  function postNewRoomReordered(self)
62
103
  local roomListIndex = getRoomListIndex(nil)
63
104
  if not v.level.deployedRoomListIndexes:has(roomListIndex) then
@@ -124,10 +165,10 @@ function removeSpecificNPCs(self)
124
165
  for ____, npc in ipairs(getNPCs(nil)) do
125
166
  do
126
167
  if NPC_TYPES_TO_NOT_REMOVE:has(npc.Type) then
127
- goto __continue25
168
+ goto __continue33
128
169
  end
129
170
  if npc:HasEntityFlags(EntityFlag.CHARM) or npc:HasEntityFlags(EntityFlag.FRIENDLY) or npc:HasEntityFlags(EntityFlag.PERSISTENT) then
130
- goto __continue25
171
+ goto __continue33
131
172
  end
132
173
  npc:ClearEntityFlags(EntityFlag.APPEAR)
133
174
  npc:Remove()
@@ -136,7 +177,7 @@ function removeSpecificNPCs(self)
136
177
  room:SetGridPath(gridIndex, 0)
137
178
  end
138
179
  end
139
- ::__continue25::
180
+ ::__continue33::
140
181
  end
141
182
  end
142
183
  function fillRoomWithDecorations(self)
@@ -148,7 +189,7 @@ function fillRoomWithDecorations(self)
148
189
  do
149
190
  local existingGridEntity = room:GetGridEntity(gridIndex)
150
191
  if existingGridEntity ~= nil then
151
- goto __continue31
192
+ goto __continue39
152
193
  end
153
194
  local position = room:GetGridPosition(gridIndex)
154
195
  local decoration = Isaac.GridSpawn(GridEntityType.DECORATION, 0, position)
@@ -157,7 +198,7 @@ function fillRoomWithDecorations(self)
157
198
  end
158
199
  decorationGridIndexes[#decorationGridIndexes + 1] = gridIndex
159
200
  end
160
- ::__continue31::
201
+ ::__continue39::
161
202
  end
162
203
  end
163
204
  function spawnAllEntities(self, jsonRoom, rng, verbose)
@@ -413,21 +454,25 @@ end
413
454
  FEATURE_NAME = "JSON room deployer"
414
455
  NPC_TYPES_TO_NOT_REMOVE = __TS__New(Set, {EntityType.DARK_ESAU})
415
456
  PERSISTENT_ENTITY_TYPES = __TS__New(Set, {EntityType.WALL_HUGGER})
416
- v = {level = {
417
- deployedRoomListIndexes = __TS__New(Set),
418
- roomToPersistentEntitiesMap = __TS__New(
419
- DefaultMap,
420
- function() return {} end
421
- ),
422
- roomToDecorationGridIndexesMap = __TS__New(
423
- DefaultMap,
424
- function() return {} end
425
- )
426
- }}
457
+ v = {
458
+ level = {
459
+ deployedRoomListIndexes = __TS__New(Set),
460
+ roomToPersistentEntitiesMap = __TS__New(
461
+ DefaultMap,
462
+ function() return {} end
463
+ ),
464
+ roomToDecorationGridIndexesMap = __TS__New(
465
+ DefaultMap,
466
+ function() return {} end
467
+ )
468
+ },
469
+ room = {manuallyUsingShovel = false}
470
+ }
427
471
  ---
428
472
  -- @internal
429
473
  function ____exports.deployJSONRoomInit(self, mod)
430
474
  saveDataManager(nil, "deployJSONRoom", v)
475
+ mod:AddCallback(ModCallback.PRE_USE_ITEM, preUseItemWeNeedToGoDeeper, CollectibleType.WE_NEED_TO_GO_DEEPER)
431
476
  mod:AddCallbackCustom(ModCallbackCustom.POST_NEW_ROOM_REORDERED, postNewRoomReordered)
432
477
  end
433
478
  --- Helper function to deconstruct a vanilla room and set up a custom room in its place.
@@ -1,5 +1,6 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local Map = ____lualib.Map
3
+ local __TS__TypeOf = ____lualib.__TS__TypeOf
3
4
  local __TS__ObjectKeys = ____lualib.__TS__ObjectKeys
4
5
  local ____exports = {}
5
6
  local ____SerializationType = require("enums.SerializationType")
@@ -8,6 +9,8 @@ local ____featuresInitialized = require("featuresInitialized")
8
9
  local errorIfFeaturesNotInitialized = ____featuresInitialized.errorIfFeaturesNotInitialized
9
10
  local ____deepCopy = require("functions.deepCopy")
10
11
  local deepCopy = ____deepCopy.deepCopy
12
+ local ____types = require("functions.types")
13
+ local isString = ____types.isString
11
14
  local ____constants = require("features.saveDataManager.constants")
12
15
  local SAVE_DATA_MANAGER_FEATURE_NAME = ____constants.SAVE_DATA_MANAGER_FEATURE_NAME
13
16
  local ____main = require("features.saveDataManager.main")
@@ -103,9 +106,8 @@ local saveDataMap = ____maps.saveDataMap
103
106
  -- not clutter the the "save#.dat" file with unnecessary keys.
104
107
  function ____exports.saveDataManager(self, key, v, conditionalFunc)
105
108
  errorIfFeaturesNotInitialized(nil, SAVE_DATA_MANAGER_FEATURE_NAME)
106
- local keyType = type(key)
107
- if keyType ~= "string" then
108
- error((("The " .. SAVE_DATA_MANAGER_FEATURE_NAME) .. " requires that keys are strings. You tried to use a key of type: ") .. keyType)
109
+ if not isString(nil, key) then
110
+ error((("The " .. SAVE_DATA_MANAGER_FEATURE_NAME) .. " requires that keys are strings. You tried to use a key of type: ") .. __TS__TypeOf(key))
109
111
  end
110
112
  if saveDataMap[key] ~= nil then
111
113
  error((("The " .. SAVE_DATA_MANAGER_FEATURE_NAME) .. " is already managing save data for a key of: ") .. key)
@@ -168,9 +170,8 @@ end
168
170
  -- ```
169
171
  function ____exports.saveDataManagerReset(self, key, childObjectKey)
170
172
  errorIfFeaturesNotInitialized(nil, SAVE_DATA_MANAGER_FEATURE_NAME)
171
- local keyType = type(key)
172
- if keyType ~= "string" then
173
- error((("The " .. SAVE_DATA_MANAGER_FEATURE_NAME) .. " requires that keys are strings. You tried to use a key of type: ") .. keyType)
173
+ if not isString(nil, key) then
174
+ error((("The " .. SAVE_DATA_MANAGER_FEATURE_NAME) .. " requires that keys are strings. You tried to use a key of type: ") .. __TS__TypeOf(key))
174
175
  end
175
176
  local saveData = saveDataMap[key]
176
177
  if saveData == nil then
@@ -8,7 +8,10 @@ local ____log = require("functions.log")
8
8
  local log = ____log.log
9
9
  local logError = ____log.logError
10
10
  local ____table = require("functions.table")
11
- local iterateTableDeterministically = ____table.iterateTableDeterministically
11
+ local iterateTableInOrder = ____table.iterateTableInOrder
12
+ local ____types = require("functions.types")
13
+ local isString = ____types.isString
14
+ local isTable = ____types.isTable
12
15
  local ____constants = require("features.saveDataManager.constants")
13
16
  local SAVE_DATA_MANAGER_DEBUG = ____constants.SAVE_DATA_MANAGER_DEBUG
14
17
  local SAVE_DATA_MANAGER_FEATURE_NAME = ____constants.SAVE_DATA_MANAGER_FEATURE_NAME
@@ -43,15 +46,14 @@ function ____exports.loadFromDisk(self, mod, oldSaveData)
43
46
  if SAVE_DATA_MANAGER_DEBUG then
44
47
  log("Converted data from the \"save#.dat\" to a Lua table.")
45
48
  end
46
- iterateTableDeterministically(
49
+ iterateTableInOrder(
47
50
  nil,
48
51
  newSaveData,
49
52
  function(____, key, value)
50
- if type(key) ~= "string" then
53
+ if not isString(nil, key) then
51
54
  return
52
55
  end
53
- local valueType = type(value)
54
- if valueType ~= "table" then
56
+ if not isTable(nil, value) then
55
57
  return
56
58
  end
57
59
  local oldSaveDataForSubscriber = oldSaveData[key]
@@ -19,7 +19,7 @@ local ____log = require("functions.log")
19
19
  local logError = ____log.logError
20
20
  local ____table = require("functions.table")
21
21
  local clearTable = ____table.clearTable
22
- local iterateTableDeterministically = ____table.iterateTableDeterministically
22
+ local iterateTableInOrder = ____table.iterateTableInOrder
23
23
  local ____constants = require("features.saveDataManager.constants")
24
24
  local SAVE_DATA_MANAGER_DEBUG = ____constants.SAVE_DATA_MANAGER_DEBUG
25
25
  local SAVE_DATA_MANAGER_FEATURE_NAME = ____constants.SAVE_DATA_MANAGER_FEATURE_NAME
@@ -66,7 +66,7 @@ function restoreDefaultsAll(self)
66
66
  restoreDefaults(nil, SaveDataKey.ROOM)
67
67
  end
68
68
  function restoreDefaults(self, saveDataKey)
69
- iterateTableDeterministically(
69
+ iterateTableInOrder(
70
70
  nil,
71
71
  saveDataMap,
72
72
  function(____, subscriberName, saveData)
@@ -18,10 +18,12 @@ local deserializeIsaacAPIClass = ____serialization.deserializeIsaacAPIClass
18
18
  local isSerializedIsaacAPIClass = ____serialization.isSerializedIsaacAPIClass
19
19
  local ____table = require("functions.table")
20
20
  local clearTable = ____table.clearTable
21
- local iterateTableDeterministically = ____table.iterateTableDeterministically
21
+ local iterateTableInOrder = ____table.iterateTableInOrder
22
22
  local ____tstlClass = require("functions.tstlClass")
23
23
  local isTSTLMap = ____tstlClass.isTSTLMap
24
24
  local isTSTLSet = ____tstlClass.isTSTLSet
25
+ local ____types = require("functions.types")
26
+ local isTable = ____types.isTable
25
27
  local ____utils = require("functions.utils")
26
28
  local getTraversalDescription = ____utils.getTraversalDescription
27
29
  local ____constants = require("features.saveDataManager.constants")
@@ -52,17 +54,14 @@ function ____exports.merge(self, oldObject, newTable, traversalDescription)
52
54
  if SAVE_DATA_MANAGER_DEBUG then
53
55
  log("merge is traversing: " .. traversalDescription)
54
56
  end
55
- local oldObjectType = type(oldObject)
56
- if oldObjectType ~= "table" then
57
+ if not isTable(nil, oldObject) then
57
58
  error("The first argument given to the merge function is not a table.")
58
59
  end
59
- local newTableType = type(newTable)
60
- if newTableType ~= "table" then
60
+ if not isTable(nil, newTable) then
61
61
  error("The second argument given to the merge function is not a table.")
62
62
  end
63
63
  if isArray(nil, oldObject) and isArray(nil, newTable) then
64
- local oldTable = oldObject
65
- mergeArray(nil, oldTable, newTable)
64
+ mergeArray(nil, oldObject, newTable)
66
65
  return
67
66
  end
68
67
  if isTSTLMap(nil, oldObject) or isTSTLSet(nil, oldObject) then
@@ -73,7 +72,7 @@ function ____exports.merge(self, oldObject, newTable, traversalDescription)
73
72
  end
74
73
  function mergeArray(self, oldArray, newArray)
75
74
  clearTable(nil, oldArray)
76
- iterateTableDeterministically(
75
+ iterateTableInOrder(
77
76
  nil,
78
77
  newArray,
79
78
  function(____, key, value)
@@ -85,7 +84,7 @@ end
85
84
  function mergeTSTLObject(self, oldObject, newTable, traversalDescription)
86
85
  oldObject:clear()
87
86
  local convertStringKeysToNumbers = newTable[SerializationBrand.OBJECT_WITH_NUMBER_KEYS] ~= nil
88
- iterateTableDeterministically(
87
+ iterateTableInOrder(
89
88
  nil,
90
89
  newTable,
91
90
  function(____, key, value)
@@ -101,9 +100,8 @@ function mergeTSTLObject(self, oldObject, newTable, traversalDescription)
101
100
  keyToUse = numberKey
102
101
  end
103
102
  if isTSTLMap(nil, oldObject) then
104
- local valueType = type(value)
105
103
  local valueCopy
106
- if valueType == "table" then
104
+ if isTable(nil, value) then
107
105
  valueCopy = deepCopy(nil, value, SerializationType.DESERIALIZE, traversalDescription)
108
106
  else
109
107
  valueCopy = value
@@ -117,7 +115,7 @@ function mergeTSTLObject(self, oldObject, newTable, traversalDescription)
117
115
  )
118
116
  end
119
117
  function mergeTable(self, oldTable, newTable, traversalDescription)
120
- iterateTableDeterministically(
118
+ iterateTableInOrder(
121
119
  nil,
122
120
  newTable,
123
121
  function(____, key, value)
@@ -136,11 +134,9 @@ function mergeTable(self, oldTable, newTable, traversalDescription)
136
134
  oldTable[key] = deserializedObject
137
135
  return
138
136
  end
139
- local valueType = type(value)
140
- if valueType == "table" then
137
+ if isTable(nil, value) then
141
138
  local oldValue = oldTable[key]
142
- local oldValueType = type(oldValue)
143
- if oldValueType ~= "table" then
139
+ if not isTable(nil, oldValue) then
144
140
  oldValue = {}
145
141
  oldTable[key] = oldValue
146
142
  end
@@ -12,13 +12,13 @@ local jsonEncode = ____jsonHelpers.jsonEncode
12
12
  local ____log = require("functions.log")
13
13
  local log = ____log.log
14
14
  local ____table = require("functions.table")
15
- local iterateTableDeterministically = ____table.iterateTableDeterministically
15
+ local iterateTableInOrder = ____table.iterateTableInOrder
16
16
  local ____constants = require("features.saveDataManager.constants")
17
17
  local SAVE_DATA_MANAGER_DEBUG = ____constants.SAVE_DATA_MANAGER_DEBUG
18
18
  local SAVE_DATA_MANAGER_FEATURE_NAME = ____constants.SAVE_DATA_MANAGER_FEATURE_NAME
19
19
  function getAllSaveDataToWriteToDisk(self, saveDataMap, saveDataConditionalFuncMap)
20
20
  local allSaveData = {}
21
- iterateTableDeterministically(
21
+ iterateTableInOrder(
22
22
  nil,
23
23
  saveDataMap,
24
24
  function(____, subscriberName, saveData)
@@ -6,10 +6,12 @@ local ____SerializationBrand = require("enums.private.SerializationBrand")
6
6
  local SerializationBrand = ____SerializationBrand.SerializationBrand
7
7
  local ____enums = require("functions.enums")
8
8
  local getEnumValues = ____enums.getEnumValues
9
+ local ____types = require("functions.types")
10
+ local isString = ____types.isString
9
11
  local SERIALIZATION_BRANDS = getEnumValues(nil, SerializationBrand)
10
12
  local SERIALIZATION_BRAND_SET = __TS__New(Set, SERIALIZATION_BRANDS)
11
13
  function ____exports.isSerializationBrand(self, key)
12
- if type(key) ~= "string" then
14
+ if not isString(nil, key) then
13
15
  return false
14
16
  end
15
17
  return SERIALIZATION_BRAND_SET:has(key)
@@ -54,6 +54,7 @@ export declare function combineArrays<T>(...arrays: Array<T[] | readonly T[]>):
54
54
  * entire array will be copied.
55
55
  */
56
56
  export declare function copyArray<T>(oldArray: T[] | readonly T[], numElements?: int): T[];
57
+ /** Helper function to remove all of the elements in an array in-place. */
57
58
  export declare function emptyArray<T>(array: T[]): void;
58
59
  /**
59
60
  * Helper function to get an array containing the indexes of an array.