isaacscript-common 3.0.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cachedClasses.d.ts +6 -4
- package/cachedClasses.lua +4 -4
- package/callbacks/postSlotDestroyed.d.ts +1 -0
- package/callbacks/postSlotDestroyed.lua +66 -0
- package/callbacks/postSlotRender.lua +3 -21
- package/callbacks/subscriptions/postCustomRevive.d.ts +1 -0
- package/callbacks/subscriptions/postDoorRender.d.ts +1 -0
- package/callbacks/subscriptions/postDoorUpdate.d.ts +1 -0
- package/callbacks/subscriptions/postPickupCollect.d.ts +1 -0
- package/callbacks/subscriptions/postPickupStateChanged.d.ts +1 -0
- package/callbacks/subscriptions/postPitRender.d.ts +1 -0
- package/callbacks/subscriptions/postPitUpdate.d.ts +1 -0
- package/callbacks/subscriptions/postPoopRender.d.ts +1 -0
- package/callbacks/subscriptions/postPoopUpdate.d.ts +1 -0
- package/callbacks/subscriptions/postPressurePlateRender.d.ts +1 -0
- package/callbacks/subscriptions/postPressurePlateUpdate.d.ts +1 -0
- package/callbacks/subscriptions/postRockRender.d.ts +1 -0
- package/callbacks/subscriptions/postRockUpdate.d.ts +1 -0
- package/callbacks/subscriptions/postSpikesRender.d.ts +1 -0
- package/callbacks/subscriptions/postSpikesUpdate.d.ts +1 -0
- package/callbacks/subscriptions/postTNTRender.d.ts +1 -0
- package/callbacks/subscriptions/postTNTUpdate.d.ts +1 -0
- package/features/debugDisplay/exports.d.ts +17 -0
- package/features/debugDisplay/v.d.ts +17 -0
- package/features/deployJSONRoom.d.ts +1 -0
- package/features/saveDataManager/load.lua +12 -8
- package/features/saveDataManager/main.lua +10 -3
- package/features/saveDataManager/merge.lua +33 -21
- package/features/saveDataManager/save.lua +12 -7
- package/functions/array.d.ts +2 -0
- package/functions/chargeBar.d.ts +1 -0
- package/functions/collectibles.d.ts +6 -1
- package/functions/collectibles.lua +16 -3
- package/functions/deepCopy.lua +35 -26
- package/functions/deepCopyTests.lua +8 -5
- package/functions/direction.d.ts +1 -0
- package/functions/direction.lua +22 -0
- package/functions/doors.d.ts +1 -0
- package/functions/doors.lua +5 -0
- package/functions/entity.d.ts +4 -4
- package/functions/entity.lua +8 -8
- package/functions/entitySpecific.d.ts +20 -20
- package/functions/entitySpecific.lua +10 -10
- package/functions/enums.d.ts +2 -0
- package/functions/globals.lua +2 -10
- package/functions/gridEntitySpecific.d.ts +5 -0
- package/functions/isaacAPIClass.d.ts +4 -4
- package/functions/isaacAPIClass.lua +6 -6
- package/functions/jsonRoom.d.ts +2 -0
- package/functions/log.lua +3 -3
- package/functions/pickups.d.ts +9 -9
- package/functions/playerHealth.d.ts +1 -0
- package/functions/playerIndex.d.ts +2 -0
- package/functions/positionVelocity.d.ts +3 -0
- package/functions/random.d.ts +2 -0
- package/functions/revive.d.ts +2 -0
- package/functions/rng.d.ts +1 -0
- package/functions/serialization.lua +2 -2
- package/functions/set.d.ts +1 -0
- package/functions/sprite.d.ts +2 -0
- package/functions/table.d.ts +12 -0
- package/functions/table.lua +34 -0
- package/functions/tears.d.ts +1 -0
- package/functions/tstlClass.d.ts +34 -0
- package/functions/tstlClass.lua +54 -9
- package/functions/ui.d.ts +2 -0
- package/functions/utils.d.ts +15 -0
- package/functions/utils.lua +20 -0
- package/functions/vector.lua +4 -16
- package/initCustomCallbacks.lua +3 -0
- package/interfaces/ChargeBarSprites.d.ts +1 -0
- package/interfaces/private/TSTLClassMetatable.d.ts +2 -0
- package/objects/oppositeDoorSlots.d.ts +4 -0
- package/objects/oppositeDoorSlots.lua +15 -0
- package/package.json +1 -1
- package/types/AnyEntity.d.ts +10 -0
package/cachedClasses.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
3
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
2
4
|
/**
|
|
3
5
|
* A cached version of the class returned from the `Game()` constructor.
|
|
4
6
|
*
|
|
5
7
|
* Use this instead of invoking the constructor again for a miniscule performance increase.
|
|
6
8
|
*
|
|
7
|
-
* Caching the results of
|
|
9
|
+
* Caching the results of this constructor is safe, but caching other classes (like `Level` or
|
|
8
10
|
* `Room`) is not safe and can lead to the game crashing in certain situations.
|
|
9
11
|
*/
|
|
10
12
|
export declare const game: Game;
|
|
@@ -13,7 +15,7 @@ export declare const game: Game;
|
|
|
13
15
|
*
|
|
14
16
|
* Use this instead of invoking the constructor again for a miniscule performance increase.
|
|
15
17
|
*
|
|
16
|
-
* Caching the results of
|
|
18
|
+
* Caching the results of this constructor is safe, but caching other classes (like `Level` or
|
|
17
19
|
* `Room`) is not safe and can lead to the game crashing in certain situations.
|
|
18
20
|
*/
|
|
19
21
|
export declare const itemConfig: import("isaac-typescript-definitions/types/ItemConfig").ItemConfig;
|
|
@@ -22,7 +24,7 @@ export declare const itemConfig: import("isaac-typescript-definitions/types/Item
|
|
|
22
24
|
*
|
|
23
25
|
* Use this instead of invoking the constructor again for a miniscule performance increase.
|
|
24
26
|
*
|
|
25
|
-
* Caching the results of
|
|
27
|
+
* Caching the results of this constructor is safe, but caching other classes (like `Level` or
|
|
26
28
|
* `Room`) is not safe and can lead to the game crashing in certain situations.
|
|
27
29
|
*/
|
|
28
30
|
export declare const musicManager: MusicManager;
|
|
@@ -31,7 +33,7 @@ export declare const musicManager: MusicManager;
|
|
|
31
33
|
*
|
|
32
34
|
* Use this instead of invoking the constructor again for a miniscule performance increase.
|
|
33
35
|
*
|
|
34
|
-
* Caching the results of
|
|
36
|
+
* Caching the results of this constructor is safe, but caching other classes (like `Level` or
|
|
35
37
|
* `Room`) is not safe and can lead to the game crashing in certain situations.
|
|
36
38
|
*/
|
|
37
39
|
export declare const sfxManager: SFXManager;
|
package/cachedClasses.lua
CHANGED
|
@@ -3,28 +3,28 @@ local ____exports = {}
|
|
|
3
3
|
--
|
|
4
4
|
-- Use this instead of invoking the constructor again for a miniscule performance increase.
|
|
5
5
|
--
|
|
6
|
-
-- Caching the results of
|
|
6
|
+
-- Caching the results of this constructor is safe, but caching other classes (like `Level` or
|
|
7
7
|
-- `Room`) is not safe and can lead to the game crashing in certain situations.
|
|
8
8
|
____exports.game = Game()
|
|
9
9
|
--- A cached version of the class returned from the `Isaac.GetItemConfig()` constructor.
|
|
10
10
|
--
|
|
11
11
|
-- Use this instead of invoking the constructor again for a miniscule performance increase.
|
|
12
12
|
--
|
|
13
|
-
-- Caching the results of
|
|
13
|
+
-- Caching the results of this constructor is safe, but caching other classes (like `Level` or
|
|
14
14
|
-- `Room`) is not safe and can lead to the game crashing in certain situations.
|
|
15
15
|
____exports.itemConfig = Isaac.GetItemConfig()
|
|
16
16
|
--- A cached version of the class returned from the `MusicManager()` constructor.
|
|
17
17
|
--
|
|
18
18
|
-- Use this instead of invoking the constructor again for a miniscule performance increase.
|
|
19
19
|
--
|
|
20
|
-
-- Caching the results of
|
|
20
|
+
-- Caching the results of this constructor is safe, but caching other classes (like `Level` or
|
|
21
21
|
-- `Room`) is not safe and can lead to the game crashing in certain situations.
|
|
22
22
|
____exports.musicManager = MusicManager()
|
|
23
23
|
--- A cached version of the class returned from the `SFXManager()` constructor.
|
|
24
24
|
--
|
|
25
25
|
-- Use this instead of invoking the constructor again for a miniscule performance increase.
|
|
26
26
|
--
|
|
27
|
-
-- Caching the results of
|
|
27
|
+
-- Caching the results of this constructor is safe, but caching other classes (like `Level` or
|
|
28
28
|
-- `Room`) is not safe and can lead to the game crashing in certain situations.
|
|
29
29
|
____exports.sfxManager = SFXManager()
|
|
30
30
|
return ____exports
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local Set = ____lualib.Set
|
|
3
|
+
local __TS__New = ____lualib.__TS__New
|
|
4
|
+
local Map = ____lualib.Map
|
|
5
|
+
local ____exports = {}
|
|
6
|
+
local hasSubscriptions, postEntityRemove, postSlotAnimationChanged, BROKEN_ANIMATIONS, PRIZE_GAME_FRAME_DELAY_UNTIL_REMOVAL, v
|
|
7
|
+
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
|
|
8
|
+
local EntityType = ____isaac_2Dtypescript_2Ddefinitions.EntityType
|
|
9
|
+
local ModCallback = ____isaac_2Dtypescript_2Ddefinitions.ModCallback
|
|
10
|
+
local ____cachedClasses = require("cachedClasses")
|
|
11
|
+
local game = ____cachedClasses.game
|
|
12
|
+
local ____ModCallbackCustom = require("enums.ModCallbackCustom")
|
|
13
|
+
local ModCallbackCustom = ____ModCallbackCustom.ModCallbackCustom
|
|
14
|
+
local ____exports = require("features.saveDataManager.exports")
|
|
15
|
+
local saveDataManager = ____exports.saveDataManager
|
|
16
|
+
local ____postSlotDestroyed = require("callbacks.subscriptions.postSlotDestroyed")
|
|
17
|
+
local postSlotDestroyedFire = ____postSlotDestroyed.postSlotDestroyedFire
|
|
18
|
+
local postSlotDestroyedHasSubscriptions = ____postSlotDestroyed.postSlotDestroyedHasSubscriptions
|
|
19
|
+
function hasSubscriptions(self)
|
|
20
|
+
return postSlotDestroyedHasSubscriptions(nil)
|
|
21
|
+
end
|
|
22
|
+
function postEntityRemove(self, entity)
|
|
23
|
+
local slot = entity
|
|
24
|
+
local ptrHash = GetPtrHash(slot)
|
|
25
|
+
local gameFrameCount = game:GetFrameCount()
|
|
26
|
+
local prizeFrame = v.room.slotPrizeAnimationGameFrame:get(ptrHash)
|
|
27
|
+
if prizeFrame == nil then
|
|
28
|
+
return
|
|
29
|
+
end
|
|
30
|
+
if prizeFrame + PRIZE_GAME_FRAME_DELAY_UNTIL_REMOVAL == gameFrameCount then
|
|
31
|
+
postSlotDestroyedFire(nil, slot)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
function postSlotAnimationChanged(self, slot)
|
|
35
|
+
local ptrHash = GetPtrHash(slot)
|
|
36
|
+
local gameFrameCount = game:GetFrameCount()
|
|
37
|
+
local alreadyBroken = v.room.brokenSlots:has(ptrHash)
|
|
38
|
+
if alreadyBroken then
|
|
39
|
+
return
|
|
40
|
+
end
|
|
41
|
+
local sprite = slot:GetSprite()
|
|
42
|
+
local animation = sprite:GetAnimation()
|
|
43
|
+
if BROKEN_ANIMATIONS:has(animation) then
|
|
44
|
+
v.room.brokenSlots:add(ptrHash)
|
|
45
|
+
postSlotDestroyedFire(nil, slot)
|
|
46
|
+
end
|
|
47
|
+
if animation == "Prize" then
|
|
48
|
+
v.room.slotPrizeAnimationGameFrame:set(ptrHash, gameFrameCount)
|
|
49
|
+
else
|
|
50
|
+
v.room.slotPrizeAnimationGameFrame:delete(ptrHash)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
BROKEN_ANIMATIONS = __TS__New(Set, {"Broken", "Death"})
|
|
54
|
+
PRIZE_GAME_FRAME_DELAY_UNTIL_REMOVAL = 3
|
|
55
|
+
v = {room = {
|
|
56
|
+
brokenSlots = __TS__New(Set),
|
|
57
|
+
slotPrizeAnimationGameFrame = __TS__New(Map)
|
|
58
|
+
}}
|
|
59
|
+
---
|
|
60
|
+
-- @internal
|
|
61
|
+
function ____exports.postSlotDestroyedCallbacksInit(self, mod)
|
|
62
|
+
saveDataManager(nil, "postSlotDestroyed", v, hasSubscriptions)
|
|
63
|
+
mod:AddCallback(ModCallback.POST_ENTITY_REMOVE, postEntityRemove, EntityType.SLOT)
|
|
64
|
+
mod:AddCallbackCustom(ModCallbackCustom.POST_SLOT_ANIMATION_CHANGED, postSlotAnimationChanged)
|
|
65
|
+
end
|
|
66
|
+
return ____exports
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
|
-
local Set = ____lualib.Set
|
|
3
2
|
local __TS__New = ____lualib.__TS__New
|
|
3
|
+
local Set = ____lualib.Set
|
|
4
4
|
local ____exports = {}
|
|
5
|
-
local hasSubscriptions, postRender, checkSlotAnimationChanged,
|
|
5
|
+
local hasSubscriptions, postRender, checkSlotAnimationChanged, v
|
|
6
6
|
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
|
|
7
7
|
local ModCallback = ____isaac_2Dtypescript_2Ddefinitions.ModCallback
|
|
8
8
|
local ____DefaultMap = require("classes.DefaultMap")
|
|
@@ -14,14 +14,11 @@ local getSlots = ____entitySpecific.getSlots
|
|
|
14
14
|
local ____postSlotAnimationChanged = require("callbacks.subscriptions.postSlotAnimationChanged")
|
|
15
15
|
local postSlotAnimationChangedFire = ____postSlotAnimationChanged.postSlotAnimationChangedFire
|
|
16
16
|
local postSlotAnimationChangedHasSubscriptions = ____postSlotAnimationChanged.postSlotAnimationChangedHasSubscriptions
|
|
17
|
-
local ____postSlotDestroyed = require("callbacks.subscriptions.postSlotDestroyed")
|
|
18
|
-
local postSlotDestroyedFire = ____postSlotDestroyed.postSlotDestroyedFire
|
|
19
|
-
local postSlotDestroyedHasSubscriptions = ____postSlotDestroyed.postSlotDestroyedHasSubscriptions
|
|
20
17
|
local ____postSlotRender = require("callbacks.subscriptions.postSlotRender")
|
|
21
18
|
local postSlotRenderFire = ____postSlotRender.postSlotRenderFire
|
|
22
19
|
local postSlotRenderHasSubscriptions = ____postSlotRender.postSlotRenderHasSubscriptions
|
|
23
20
|
function hasSubscriptions(self)
|
|
24
|
-
return postSlotRenderHasSubscriptions(nil) or
|
|
21
|
+
return postSlotRenderHasSubscriptions(nil) or postSlotAnimationChangedHasSubscriptions(nil)
|
|
25
22
|
end
|
|
26
23
|
function postRender(self)
|
|
27
24
|
if not hasSubscriptions(nil) then
|
|
@@ -30,7 +27,6 @@ function postRender(self)
|
|
|
30
27
|
for ____, slot in ipairs(getSlots(nil)) do
|
|
31
28
|
postSlotRenderFire(nil, slot)
|
|
32
29
|
checkSlotAnimationChanged(nil, slot)
|
|
33
|
-
checkSlotBroken(nil, slot)
|
|
34
30
|
end
|
|
35
31
|
end
|
|
36
32
|
function checkSlotAnimationChanged(self, slot)
|
|
@@ -43,20 +39,6 @@ function checkSlotAnimationChanged(self, slot)
|
|
|
43
39
|
postSlotAnimationChangedFire(nil, slot, previousAnimation, currentAnimation)
|
|
44
40
|
end
|
|
45
41
|
end
|
|
46
|
-
function checkSlotBroken(self, slot)
|
|
47
|
-
local ptrHash = GetPtrHash(slot)
|
|
48
|
-
local alreadyBroken = v.room.brokenSlots:has(ptrHash)
|
|
49
|
-
if alreadyBroken then
|
|
50
|
-
return
|
|
51
|
-
end
|
|
52
|
-
local sprite = slot:GetSprite()
|
|
53
|
-
local animation = sprite:GetAnimation()
|
|
54
|
-
if BROKEN_ANIMATIONS:has(animation) then
|
|
55
|
-
v.room.brokenSlots:add(ptrHash)
|
|
56
|
-
postSlotDestroyedFire(nil, slot)
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
BROKEN_ANIMATIONS = __TS__New(Set, {"Broken", "Death"})
|
|
60
42
|
v = {room = {
|
|
61
43
|
slotAnimations = __TS__New(
|
|
62
44
|
DefaultMap,
|
|
@@ -1,4 +1,21 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
3
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
4
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
5
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
6
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
7
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
8
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
9
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
10
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
11
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
12
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
13
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
14
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
15
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
16
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
17
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
18
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
2
19
|
/**
|
|
3
20
|
* After using the "playerDisplay" console command, text will be drawn on each player for debugging
|
|
4
21
|
* purposes. Use this function to specify a callback function that will returns the string that
|
|
@@ -1,4 +1,21 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
3
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
4
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
5
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
6
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
7
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
8
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
9
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
10
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
11
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
12
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
13
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
14
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
15
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
16
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
17
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
18
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
2
19
|
declare const v: {
|
|
3
20
|
run: {
|
|
4
21
|
player: boolean;
|
|
@@ -7,6 +7,8 @@ local jsonDecode = ____jsonHelpers.jsonDecode
|
|
|
7
7
|
local ____log = require("functions.log")
|
|
8
8
|
local log = ____log.log
|
|
9
9
|
local logError = ____log.logError
|
|
10
|
+
local ____table = require("functions.table")
|
|
11
|
+
local iterateTableDeterministically = ____table.iterateTableDeterministically
|
|
10
12
|
local ____constants = require("features.saveDataManager.constants")
|
|
11
13
|
local SAVE_DATA_MANAGER_DEBUG = ____constants.SAVE_DATA_MANAGER_DEBUG
|
|
12
14
|
local SAVE_DATA_MANAGER_FEATURE_NAME = ____constants.SAVE_DATA_MANAGER_FEATURE_NAME
|
|
@@ -41,26 +43,28 @@ function ____exports.loadFromDisk(self, mod, oldSaveData)
|
|
|
41
43
|
if SAVE_DATA_MANAGER_DEBUG then
|
|
42
44
|
log("Converted data from the \"save#.dat\" to a Lua table.")
|
|
43
45
|
end
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
iterateTableDeterministically(
|
|
47
|
+
nil,
|
|
48
|
+
newSaveData,
|
|
49
|
+
function(____, key, value)
|
|
46
50
|
if type(key) ~= "string" then
|
|
47
|
-
|
|
51
|
+
return
|
|
48
52
|
end
|
|
49
53
|
local valueType = type(value)
|
|
50
54
|
if valueType ~= "table" then
|
|
51
|
-
|
|
55
|
+
return
|
|
52
56
|
end
|
|
53
57
|
local oldSaveDataForSubscriber = oldSaveData[key]
|
|
54
58
|
if oldSaveDataForSubscriber == nil then
|
|
55
|
-
|
|
59
|
+
return
|
|
56
60
|
end
|
|
57
61
|
if SAVE_DATA_MANAGER_DEBUG then
|
|
58
62
|
log("Merging in stored data for feature: " .. key)
|
|
59
63
|
end
|
|
60
64
|
merge(nil, oldSaveDataForSubscriber, value, key)
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
|
|
65
|
+
end,
|
|
66
|
+
SAVE_DATA_MANAGER_DEBUG
|
|
67
|
+
)
|
|
64
68
|
log(("The " .. SAVE_DATA_MANAGER_FEATURE_NAME) .. " loaded data from the \"save#.dat\" file.")
|
|
65
69
|
end
|
|
66
70
|
return ____exports
|
|
@@ -19,7 +19,9 @@ 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
23
|
local ____constants = require("features.saveDataManager.constants")
|
|
24
|
+
local SAVE_DATA_MANAGER_DEBUG = ____constants.SAVE_DATA_MANAGER_DEBUG
|
|
23
25
|
local SAVE_DATA_MANAGER_FEATURE_NAME = ____constants.SAVE_DATA_MANAGER_FEATURE_NAME
|
|
24
26
|
local ____load = require("features.saveDataManager.load")
|
|
25
27
|
local loadFromDisk = ____load.loadFromDisk
|
|
@@ -64,9 +66,14 @@ function restoreDefaultsAll(self)
|
|
|
64
66
|
restoreDefaults(nil, SaveDataKey.ROOM)
|
|
65
67
|
end
|
|
66
68
|
function restoreDefaults(self, saveDataKey)
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
iterateTableDeterministically(
|
|
70
|
+
nil,
|
|
71
|
+
saveDataMap,
|
|
72
|
+
function(____, subscriberName, saveData)
|
|
73
|
+
____exports.restoreDefaultSaveData(nil, subscriberName, saveData, saveDataKey)
|
|
74
|
+
end,
|
|
75
|
+
SAVE_DATA_MANAGER_DEBUG
|
|
76
|
+
)
|
|
70
77
|
end
|
|
71
78
|
function ____exports.restoreDefaultSaveData(self, subscriberName, saveData, saveDataKey)
|
|
72
79
|
if not RESETTABLE_SAVE_DATA_KEYS:has(saveDataKey) then
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
2
|
local Map = ____lualib.Map
|
|
3
|
-
local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
4
3
|
local Set = ____lualib.Set
|
|
5
4
|
local ____exports = {}
|
|
6
5
|
local mergeArray, mergeTSTLObject, mergeTable
|
|
@@ -19,6 +18,10 @@ local deserializeIsaacAPIClass = ____serialization.deserializeIsaacAPIClass
|
|
|
19
18
|
local isSerializedIsaacAPIClass = ____serialization.isSerializedIsaacAPIClass
|
|
20
19
|
local ____table = require("functions.table")
|
|
21
20
|
local clearTable = ____table.clearTable
|
|
21
|
+
local iterateTableDeterministically = ____table.iterateTableDeterministically
|
|
22
|
+
local ____tstlClass = require("functions.tstlClass")
|
|
23
|
+
local isTSTLMap = ____tstlClass.isTSTLMap
|
|
24
|
+
local isTSTLSet = ____tstlClass.isTSTLSet
|
|
22
25
|
local ____utils = require("functions.utils")
|
|
23
26
|
local getTraversalDescription = ____utils.getTraversalDescription
|
|
24
27
|
local ____constants = require("features.saveDataManager.constants")
|
|
@@ -62,7 +65,7 @@ function ____exports.merge(self, oldObject, newTable, traversalDescription)
|
|
|
62
65
|
mergeArray(nil, oldTable, newTable)
|
|
63
66
|
return
|
|
64
67
|
end
|
|
65
|
-
if
|
|
68
|
+
if isTSTLMap(nil, oldObject) or isTSTLSet(nil, oldObject) then
|
|
66
69
|
mergeTSTLObject(nil, oldObject, newTable, traversalDescription)
|
|
67
70
|
else
|
|
68
71
|
mergeTable(nil, oldObject, newTable, traversalDescription)
|
|
@@ -70,27 +73,34 @@ function ____exports.merge(self, oldObject, newTable, traversalDescription)
|
|
|
70
73
|
end
|
|
71
74
|
function mergeArray(self, oldArray, newArray)
|
|
72
75
|
clearTable(nil, oldArray)
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
+
iterateTableDeterministically(
|
|
77
|
+
nil,
|
|
78
|
+
newArray,
|
|
79
|
+
function(____, key, value)
|
|
80
|
+
oldArray[key] = value
|
|
81
|
+
end,
|
|
82
|
+
SAVE_DATA_MANAGER_DEBUG
|
|
83
|
+
)
|
|
76
84
|
end
|
|
77
85
|
function mergeTSTLObject(self, oldObject, newTable, traversalDescription)
|
|
78
86
|
oldObject:clear()
|
|
79
87
|
local convertStringKeysToNumbers = newTable[SerializationBrand.OBJECT_WITH_NUMBER_KEYS] ~= nil
|
|
80
|
-
|
|
81
|
-
|
|
88
|
+
iterateTableDeterministically(
|
|
89
|
+
nil,
|
|
90
|
+
newTable,
|
|
91
|
+
function(____, key, value)
|
|
82
92
|
if isSerializationBrand(nil, key) then
|
|
83
|
-
|
|
93
|
+
return
|
|
84
94
|
end
|
|
85
95
|
local keyToUse = key
|
|
86
96
|
if convertStringKeysToNumbers then
|
|
87
97
|
local numberKey = tonumber(key)
|
|
88
98
|
if numberKey == nil then
|
|
89
|
-
|
|
99
|
+
return
|
|
90
100
|
end
|
|
91
101
|
keyToUse = numberKey
|
|
92
102
|
end
|
|
93
|
-
if
|
|
103
|
+
if isTSTLMap(nil, oldObject) then
|
|
94
104
|
local valueType = type(value)
|
|
95
105
|
local valueCopy
|
|
96
106
|
if valueType == "table" then
|
|
@@ -99,22 +109,24 @@ function mergeTSTLObject(self, oldObject, newTable, traversalDescription)
|
|
|
99
109
|
valueCopy = value
|
|
100
110
|
end
|
|
101
111
|
oldObject:set(keyToUse, valueCopy)
|
|
102
|
-
elseif
|
|
112
|
+
elseif isTSTLSet(nil, oldObject) then
|
|
103
113
|
oldObject:add(keyToUse)
|
|
104
114
|
end
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
|
|
115
|
+
end,
|
|
116
|
+
SAVE_DATA_MANAGER_DEBUG
|
|
117
|
+
)
|
|
108
118
|
end
|
|
109
119
|
function mergeTable(self, oldTable, newTable, traversalDescription)
|
|
110
|
-
|
|
111
|
-
|
|
120
|
+
iterateTableDeterministically(
|
|
121
|
+
nil,
|
|
122
|
+
newTable,
|
|
123
|
+
function(____, key, value)
|
|
112
124
|
if SAVE_DATA_MANAGER_DEBUG then
|
|
113
125
|
local valueToPrint = value == "" and "(empty string)" or tostring(value)
|
|
114
126
|
log((("merge is merging: " .. traversalDescription) .. " --> ") .. valueToPrint)
|
|
115
127
|
end
|
|
116
128
|
if isSerializationBrand(nil, key) then
|
|
117
|
-
|
|
129
|
+
return
|
|
118
130
|
end
|
|
119
131
|
if isSerializedIsaacAPIClass(nil, value) then
|
|
120
132
|
if SAVE_DATA_MANAGER_DEBUG then
|
|
@@ -122,7 +134,7 @@ function mergeTable(self, oldTable, newTable, traversalDescription)
|
|
|
122
134
|
end
|
|
123
135
|
local deserializedObject = deserializeIsaacAPIClass(nil, value)
|
|
124
136
|
oldTable[key] = deserializedObject
|
|
125
|
-
|
|
137
|
+
return
|
|
126
138
|
end
|
|
127
139
|
local valueType = type(value)
|
|
128
140
|
if valueType == "table" then
|
|
@@ -137,8 +149,8 @@ function mergeTable(self, oldTable, newTable, traversalDescription)
|
|
|
137
149
|
else
|
|
138
150
|
oldTable[key] = value
|
|
139
151
|
end
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
|
|
152
|
+
end,
|
|
153
|
+
SAVE_DATA_MANAGER_DEBUG
|
|
154
|
+
)
|
|
143
155
|
end
|
|
144
156
|
return ____exports
|
|
@@ -11,28 +11,33 @@ local ____jsonHelpers = require("functions.jsonHelpers")
|
|
|
11
11
|
local jsonEncode = ____jsonHelpers.jsonEncode
|
|
12
12
|
local ____log = require("functions.log")
|
|
13
13
|
local log = ____log.log
|
|
14
|
+
local ____table = require("functions.table")
|
|
15
|
+
local iterateTableDeterministically = ____table.iterateTableDeterministically
|
|
14
16
|
local ____constants = require("features.saveDataManager.constants")
|
|
17
|
+
local SAVE_DATA_MANAGER_DEBUG = ____constants.SAVE_DATA_MANAGER_DEBUG
|
|
15
18
|
local SAVE_DATA_MANAGER_FEATURE_NAME = ____constants.SAVE_DATA_MANAGER_FEATURE_NAME
|
|
16
19
|
function getAllSaveDataToWriteToDisk(self, saveDataMap, saveDataConditionalFuncMap)
|
|
17
20
|
local allSaveData = {}
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
iterateTableDeterministically(
|
|
22
|
+
nil,
|
|
23
|
+
saveDataMap,
|
|
24
|
+
function(____, subscriberName, saveData)
|
|
20
25
|
local conditionalFunc = saveDataConditionalFuncMap:get(subscriberName)
|
|
21
26
|
if conditionalFunc ~= nil then
|
|
22
27
|
local shouldSave = conditionalFunc(nil)
|
|
23
28
|
if not shouldSave then
|
|
24
|
-
|
|
29
|
+
return
|
|
25
30
|
end
|
|
26
31
|
end
|
|
27
32
|
local saveDataWithoutRoom = {persistent = saveData.persistent, run = saveData.run, level = saveData.level}
|
|
28
33
|
if #__TS__ObjectKeys(saveDataWithoutRoom) == 0 then
|
|
29
|
-
|
|
34
|
+
return
|
|
30
35
|
end
|
|
31
36
|
local saveDataCopy = deepCopy(nil, saveDataWithoutRoom, SerializationType.SERIALIZE, subscriberName)
|
|
32
37
|
allSaveData[subscriberName] = saveDataCopy
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
|
|
38
|
+
end,
|
|
39
|
+
SAVE_DATA_MANAGER_DEBUG
|
|
40
|
+
)
|
|
36
41
|
return allSaveData
|
|
37
42
|
end
|
|
38
43
|
function ____exports.saveToDisk(self, mod, saveDataMap, saveDataConditionalFuncMap)
|
package/functions/array.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
3
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
2
4
|
/**
|
|
3
5
|
* Helper function for determining if two arrays contain the exact same elements. Note that this
|
|
4
6
|
* only performs a shallow comparison.
|
package/functions/chargeBar.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
2
3
|
import { ChargeBarSprites } from "../interfaces/ChargeBarSprites";
|
|
3
4
|
/**
|
|
4
5
|
* Constructor for a `ChargeBarSprites` object. For more information, see the `renderChargeBar`
|