isaacscript-common 1.2.59 → 1.2.62
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/dist/callbacks/itemPickup.lua +9 -13
- package/dist/callbacks/postGridEntityCollision.lua +10 -10
- package/dist/callbacks/postPlayerChangeHealth.lua +8 -8
- package/dist/callbacks/postPurchase.lua +36 -37
- package/dist/callbacks/postTransformation.lua +19 -34
- package/dist/callbacks/postTrinketBreak.lua +16 -19
- package/dist/features/deployJSONRoom.lua +17 -23
- package/dist/features/saveDataManager/debug.d.ts +1 -0
- package/dist/features/saveDataManager/debug.lua +4 -0
- package/dist/features/saveDataManager/load.lua +6 -7
- package/dist/features/saveDataManager/merge.lua +10 -10
- package/dist/features/saveDataManager/save.lua +4 -0
- package/dist/featuresInitialized.d.ts +1 -0
- package/dist/featuresInitialized.lua +10 -0
- package/dist/functions/array.lua +1 -2
- package/dist/functions/deepCopy.d.ts +3 -3
- package/dist/functions/deepCopy.lua +52 -33
- package/dist/functions/deepCopyTests.lua +61 -1
- package/dist/functions/log.d.ts +1 -1
- package/dist/functions/log.lua +19 -5
- package/dist/functions/spawnCollectible.lua +2 -2
- package/dist/functions/utils.d.ts +7 -1
- package/dist/types/DefaultMap.d.ts +46 -10
- package/dist/types/DefaultMap.lua +19 -8
- package/dist/types/SerializationBrand.d.ts +15 -0
- package/dist/types/SerializationBrand.lua +24 -0
- package/dist/upgradeMod.lua +3 -3
- package/package.json +1 -1
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
2
|
local ____lualib = require("lualib_bundle")
|
|
3
|
-
local Map = ____lualib.Map
|
|
4
3
|
local __TS__New = ____lualib.__TS__New
|
|
5
4
|
local ____exports = {}
|
|
6
|
-
local hasSubscriptions, postPEffectUpdateReordered, queueEmpty, queueNotEmpty,
|
|
5
|
+
local hasSubscriptions, postPEffectUpdateReordered, queueEmpty, queueNotEmpty, v
|
|
7
6
|
local ____exports = require("features.saveDataManager.exports")
|
|
8
7
|
local saveDataManager = ____exports.saveDataManager
|
|
9
8
|
local ____player = require("functions.player")
|
|
10
9
|
local getPlayerIndex = ____player.getPlayerIndex
|
|
10
|
+
local ____DefaultMap = require("types.DefaultMap")
|
|
11
|
+
local DefaultMap = ____DefaultMap.DefaultMap
|
|
11
12
|
local ____ModCallbacksCustom = require("types.ModCallbacksCustom")
|
|
12
13
|
local ModCallbacksCustom = ____ModCallbacksCustom.ModCallbacksCustom
|
|
13
14
|
local ____PickingUpItem = require("types.PickingUpItem")
|
|
@@ -26,7 +27,8 @@ function postPEffectUpdateReordered(self, player)
|
|
|
26
27
|
if not hasSubscriptions(nil) then
|
|
27
28
|
return
|
|
28
29
|
end
|
|
29
|
-
local
|
|
30
|
+
local playerIndex = getPlayerIndex(nil, player)
|
|
31
|
+
local pickingUpItem = v.run.playerPickingUpItemMap:getAndSetDefault(playerIndex)
|
|
30
32
|
if player:IsItemQueueEmpty() then
|
|
31
33
|
queueEmpty(nil, player, pickingUpItem)
|
|
32
34
|
else
|
|
@@ -51,16 +53,10 @@ function queueNotEmpty(self, player, pickingUpItem)
|
|
|
51
53
|
preItemPickupFire(nil, player, pickingUpItem)
|
|
52
54
|
end
|
|
53
55
|
end
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
pickingUpItem = newPickingUpItem(nil)
|
|
59
|
-
v.run.pickingUpItem:set(playerIndex, pickingUpItem)
|
|
60
|
-
end
|
|
61
|
-
return pickingUpItem
|
|
62
|
-
end
|
|
63
|
-
v = {run = {pickingUpItem = __TS__New(Map)}}
|
|
56
|
+
v = {run = {playerPickingUpItemMap = __TS__New(
|
|
57
|
+
DefaultMap,
|
|
58
|
+
function() return newPickingUpItem(nil) end
|
|
59
|
+
)}}
|
|
64
60
|
function ____exports.itemPickupCallbacksInit(self, mod)
|
|
65
61
|
saveDataManager(nil, "itemPickup", v, hasSubscriptions)
|
|
66
62
|
mod:AddCallbackCustom(ModCallbacksCustom.MC_POST_PEFFECT_UPDATE_REORDERED, postPEffectUpdateReordered)
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
2
|
local ____lualib = require("lualib_bundle")
|
|
3
|
-
local Map = ____lualib.Map
|
|
4
|
-
local __TS__New = ____lualib.__TS__New
|
|
5
3
|
local Set = ____lualib.Set
|
|
4
|
+
local __TS__New = ____lualib.__TS__New
|
|
6
5
|
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
|
|
7
6
|
local __TS__Iterator = ____lualib.__TS__Iterator
|
|
8
7
|
local ____exports = {}
|
|
@@ -12,6 +11,8 @@ local saveDataManager = ____exports.saveDataManager
|
|
|
12
11
|
local ____gridEntity = require("functions.gridEntity")
|
|
13
12
|
local getCollidingEntitiesWithGridEntity = ____gridEntity.getCollidingEntitiesWithGridEntity
|
|
14
13
|
local getGridEntities = ____gridEntity.getGridEntities
|
|
14
|
+
local ____DefaultMap = require("types.DefaultMap")
|
|
15
|
+
local DefaultMap = ____DefaultMap.DefaultMap
|
|
15
16
|
local ____postGridEntityCollision = require("callbacks.subscriptions.postGridEntityCollision")
|
|
16
17
|
local postGridEntityCollisionFire = ____postGridEntityCollision.postGridEntityCollisionFire
|
|
17
18
|
local postGridEntityCollisionHasSubscriptions = ____postGridEntityCollision.postGridEntityCollisionHasSubscriptions
|
|
@@ -25,14 +26,10 @@ function postUpdate(self)
|
|
|
25
26
|
for ____, gridEntity in ipairs(getGridEntities(nil)) do
|
|
26
27
|
do
|
|
27
28
|
if gridEntity.CollisionClass == GridCollisionClass.COLLISION_NONE then
|
|
28
|
-
goto
|
|
29
|
+
goto __continue7
|
|
29
30
|
end
|
|
30
31
|
local gridEntityPtrHash = GetPtrHash(gridEntity)
|
|
31
|
-
local oldCollidingEntities = v.room.collidingEntitiesMap:
|
|
32
|
-
if oldCollidingEntities == nil then
|
|
33
|
-
oldCollidingEntities = __TS__New(Set)
|
|
34
|
-
v.room.collidingEntitiesMap:set(gridEntityPtrHash, oldCollidingEntities)
|
|
35
|
-
end
|
|
32
|
+
local oldCollidingEntities = v.room.collidingEntitiesMap:getAndSetDefault(gridEntityPtrHash)
|
|
36
33
|
local collidingEntities = getCollidingEntitiesWithGridEntity(nil, gridEntity)
|
|
37
34
|
for ____, entity in ipairs(collidingEntities) do
|
|
38
35
|
local entityPtrHash = GetPtrHash(entity)
|
|
@@ -52,10 +49,13 @@ function postUpdate(self)
|
|
|
52
49
|
end
|
|
53
50
|
end
|
|
54
51
|
end
|
|
55
|
-
::
|
|
52
|
+
::__continue7::
|
|
56
53
|
end
|
|
57
54
|
end
|
|
58
|
-
v = {room = {collidingEntitiesMap = __TS__New(
|
|
55
|
+
v = {room = {collidingEntitiesMap = __TS__New(
|
|
56
|
+
DefaultMap,
|
|
57
|
+
function() return __TS__New(Set) end
|
|
58
|
+
)}}
|
|
59
59
|
function ____exports.postGridEntityCollisionInit(self, mod)
|
|
60
60
|
saveDataManager(nil, "postGridEntityCollision", v, hasSubscriptions)
|
|
61
61
|
mod:AddCallback(ModCallbacks.MC_POST_UPDATE, postUpdate)
|
|
@@ -11,6 +11,8 @@ local getPlayerIndex = ____player.getPlayerIndex
|
|
|
11
11
|
local ____utils = require("functions.utils")
|
|
12
12
|
local ensureAllCases = ____utils.ensureAllCases
|
|
13
13
|
local getEnumValues = ____utils.getEnumValues
|
|
14
|
+
local ____DefaultMap = require("types.DefaultMap")
|
|
15
|
+
local DefaultMap = ____DefaultMap.DefaultMap
|
|
14
16
|
local ____HealthType = require("types.HealthType")
|
|
15
17
|
local HealthType = ____HealthType.HealthType
|
|
16
18
|
local ____ModCallbacksCustom = require("types.ModCallbacksCustom")
|
|
@@ -26,13 +28,8 @@ function postPEffectUpdateReordered(self, player)
|
|
|
26
28
|
return
|
|
27
29
|
end
|
|
28
30
|
local playerIndex = getPlayerIndex(nil, player, true)
|
|
29
|
-
local playerHealthMap = v.run.playersHealthMap:
|
|
30
|
-
|
|
31
|
-
playerHealthMap = __TS__New(Map)
|
|
32
|
-
v.run.playersHealthMap:set(playerIndex, playerHealthMap)
|
|
33
|
-
end
|
|
34
|
-
local healthTypes = getEnumValues(nil, HealthType)
|
|
35
|
-
for ____, healthType in ipairs(healthTypes) do
|
|
31
|
+
local playerHealthMap = v.run.playersHealthMap:getAndSetDefault(playerIndex)
|
|
32
|
+
for ____, healthType in ipairs(getEnumValues(nil, HealthType)) do
|
|
36
33
|
local storedHealthValue = playerHealthMap:get(healthType)
|
|
37
34
|
local currentHealthValue = getCurrentHealthValue(nil, player, healthType)
|
|
38
35
|
playerHealthMap:set(healthType, currentHealthValue)
|
|
@@ -100,7 +97,10 @@ function getCurrentHealthValue(self, player, healthType)
|
|
|
100
97
|
end
|
|
101
98
|
until true
|
|
102
99
|
end
|
|
103
|
-
v = {run = {playersHealthMap = __TS__New(
|
|
100
|
+
v = {run = {playersHealthMap = __TS__New(
|
|
101
|
+
DefaultMap,
|
|
102
|
+
function() return __TS__New(Map) end
|
|
103
|
+
)}}
|
|
104
104
|
function ____exports.postPlayerChangeHealthCallbackInit(self, mod)
|
|
105
105
|
saveDataManager(nil, "postPlayerChangeHealth", v, hasSubscriptions)
|
|
106
106
|
mod:AddCallbackCustom(ModCallbacksCustom.MC_POST_PEFFECT_UPDATE_REORDERED, postPEffectUpdateReordered)
|
|
@@ -3,8 +3,10 @@ local ____lualib = require("lualib_bundle")
|
|
|
3
3
|
local Map = ____lualib.Map
|
|
4
4
|
local __TS__New = ____lualib.__TS__New
|
|
5
5
|
local __TS__Iterator = ____lualib.__TS__Iterator
|
|
6
|
+
local __TS__ArrayFind = ____lualib.__TS__ArrayFind
|
|
7
|
+
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
|
|
6
8
|
local ____exports = {}
|
|
7
|
-
local hasSubscriptions, postUpdate, checkPickupsPurchased, storePickupsInMap, storePlayersInMap,
|
|
9
|
+
local hasSubscriptions, postUpdate, checkPickupsPurchased, getPlayerThatIsNoLongerHoldingAnItem, storePickupsInMap, storePlayersInMap, pickupAtIndexStillExists, v
|
|
8
10
|
local ____exports = require("features.saveDataManager.exports")
|
|
9
11
|
local saveDataManager = ____exports.saveDataManager
|
|
10
12
|
local ____entity = require("functions.entity")
|
|
@@ -33,44 +35,42 @@ function checkPickupsPurchased(self, pickups, players)
|
|
|
33
35
|
local index = ____value[1]
|
|
34
36
|
local pickupDescription = ____value[2]
|
|
35
37
|
do
|
|
36
|
-
if
|
|
38
|
+
if pickupAtIndexStillExists(nil, index, pickups) then
|
|
37
39
|
goto __continue7
|
|
38
40
|
end
|
|
39
41
|
v.room.pickupMap:delete(index)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
postPurchaseFire(
|
|
50
|
-
nil,
|
|
51
|
-
player,
|
|
52
|
-
pickupDescription.variant,
|
|
53
|
-
pickupDescription.subtype,
|
|
54
|
-
pickupDescription.price
|
|
55
|
-
)
|
|
56
|
-
break
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
::__continue9::
|
|
42
|
+
local player = getPlayerThatIsNoLongerHoldingAnItem(nil, players)
|
|
43
|
+
if player ~= nil then
|
|
44
|
+
postPurchaseFire(
|
|
45
|
+
nil,
|
|
46
|
+
player,
|
|
47
|
+
pickupDescription.variant,
|
|
48
|
+
pickupDescription.subtype,
|
|
49
|
+
pickupDescription.price
|
|
50
|
+
)
|
|
60
51
|
end
|
|
61
52
|
end
|
|
62
53
|
::__continue7::
|
|
63
54
|
end
|
|
64
55
|
end
|
|
65
|
-
function
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
v.room.
|
|
56
|
+
function getPlayerThatIsNoLongerHoldingAnItem(self, players)
|
|
57
|
+
return __TS__ArrayFind(
|
|
58
|
+
players,
|
|
59
|
+
function(____, player)
|
|
60
|
+
local playerHoldingItem = player:IsHoldingItem()
|
|
61
|
+
local playerIndex = getPlayerIndex(nil, player)
|
|
62
|
+
local playerHoldingItemLastFrame = v.room.playerHoldingItemLastFrameMap:get(playerIndex)
|
|
63
|
+
return playerHoldingItemLastFrame == false and playerHoldingItem
|
|
72
64
|
end
|
|
73
|
-
|
|
65
|
+
)
|
|
66
|
+
end
|
|
67
|
+
function storePickupsInMap(self, pickups)
|
|
68
|
+
local pickupsWithPrice = __TS__ArrayFilter(
|
|
69
|
+
pickups,
|
|
70
|
+
function(____, pickup) return pickup.Price ~= 0 end
|
|
71
|
+
)
|
|
72
|
+
for ____, pickup in ipairs(pickupsWithPrice) do
|
|
73
|
+
v.room.pickupMap:set(pickup.Index, {variant = pickup.Variant, subtype = pickup.SubType, price = pickup.Price})
|
|
74
74
|
end
|
|
75
75
|
end
|
|
76
76
|
function storePlayersInMap(self, players)
|
|
@@ -80,13 +80,12 @@ function storePlayersInMap(self, players)
|
|
|
80
80
|
v.room.playerHoldingItemLastFrameMap:set(playerIndex, holdingItem)
|
|
81
81
|
end
|
|
82
82
|
end
|
|
83
|
-
function
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
return false
|
|
83
|
+
function pickupAtIndexStillExists(self, index, pickups)
|
|
84
|
+
local pickupAtIndex = __TS__ArrayFind(
|
|
85
|
+
pickups,
|
|
86
|
+
function(____, pickup) return pickup.Index end
|
|
87
|
+
)
|
|
88
|
+
return pickupAtIndex ~= nil and pickupAtIndex:Exists()
|
|
90
89
|
end
|
|
91
90
|
v = {room = {
|
|
92
91
|
pickupMap = __TS__New(Map),
|
|
@@ -2,16 +2,17 @@
|
|
|
2
2
|
local ____lualib = require("lualib_bundle")
|
|
3
3
|
local Set = ____lualib.Set
|
|
4
4
|
local __TS__New = ____lualib.__TS__New
|
|
5
|
-
local
|
|
6
|
-
local Map = ____lualib.Map
|
|
5
|
+
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
|
|
7
6
|
local ____exports = {}
|
|
8
|
-
local hasSubscriptions, postPEffectUpdateReordered,
|
|
7
|
+
local hasSubscriptions, postPEffectUpdateReordered, VALID_TRANSFORMATIONS, v
|
|
9
8
|
local ____exports = require("features.saveDataManager.exports")
|
|
10
9
|
local saveDataManager = ____exports.saveDataManager
|
|
11
|
-
local
|
|
12
|
-
local
|
|
10
|
+
local ____math = require("functions.math")
|
|
11
|
+
local range = ____math.range
|
|
13
12
|
local ____player = require("functions.player")
|
|
14
13
|
local getPlayerIndex = ____player.getPlayerIndex
|
|
14
|
+
local ____DefaultMap = require("types.DefaultMap")
|
|
15
|
+
local DefaultMap = ____DefaultMap.DefaultMap
|
|
15
16
|
local ____ModCallbacksCustom = require("types.ModCallbacksCustom")
|
|
16
17
|
local ModCallbacksCustom = ____ModCallbacksCustom.ModCallbacksCustom
|
|
17
18
|
local ____postTransformation = require("callbacks.subscriptions.postTransformation")
|
|
@@ -25,42 +26,26 @@ function postPEffectUpdateReordered(self, player)
|
|
|
25
26
|
return
|
|
26
27
|
end
|
|
27
28
|
local playerIndex = getPlayerIndex(nil, player)
|
|
28
|
-
local
|
|
29
|
-
|
|
30
|
-
transformations = __TS__New(Map)
|
|
31
|
-
v.run.transformations:set(playerIndex, transformations)
|
|
32
|
-
end
|
|
33
|
-
for ____, playerForm in ipairs(TRANSFORMATIONS) do
|
|
29
|
+
local playerTransformationsMap = v.run.playersTransformationsMap:getAndSetDefault(playerIndex)
|
|
30
|
+
for ____, playerForm in ipairs(VALID_TRANSFORMATIONS) do
|
|
34
31
|
local hasForm = player:HasPlayerForm(playerForm)
|
|
35
|
-
local storedForm =
|
|
36
|
-
if storedForm == nil then
|
|
37
|
-
local defaultValue = false
|
|
38
|
-
storedForm = defaultValue
|
|
39
|
-
transformations:set(playerForm, defaultValue)
|
|
40
|
-
end
|
|
32
|
+
local storedForm = playerTransformationsMap:getAndSetDefault(playerForm)
|
|
41
33
|
if hasForm ~= storedForm then
|
|
42
|
-
|
|
34
|
+
playerTransformationsMap:set(playerForm, hasForm)
|
|
43
35
|
postTransformationFire(nil, player, playerForm, hasForm)
|
|
44
36
|
end
|
|
45
37
|
end
|
|
46
38
|
end
|
|
47
39
|
local UNUSED_TRANSFORMATIONS = __TS__New(Set, {PlayerForm.PLAYERFORM_FLIGHT})
|
|
48
|
-
local
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
end
|
|
58
|
-
::__continue2::
|
|
59
|
-
playerForm = playerForm + 1
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
TRANSFORMATIONS = copyArray(nil, tempTransformations)
|
|
63
|
-
v = {run = {transformations = __TS__New(Map)}}
|
|
40
|
+
local ALL_TRANSFORMATIONS = range(nil, 0, PlayerForm.NUM_PLAYER_FORMS - 1)
|
|
41
|
+
VALID_TRANSFORMATIONS = __TS__ArrayFilter(
|
|
42
|
+
ALL_TRANSFORMATIONS,
|
|
43
|
+
function(____, playerForm) return not UNUSED_TRANSFORMATIONS:has(playerForm) end
|
|
44
|
+
)
|
|
45
|
+
v = {run = {playersTransformationsMap = __TS__New(
|
|
46
|
+
DefaultMap,
|
|
47
|
+
function() return __TS__New(DefaultMap, false) end
|
|
48
|
+
)}}
|
|
64
49
|
function ____exports.postTransformationCallbackInit(self, mod)
|
|
65
50
|
saveDataManager(nil, "postTransformation", v, hasSubscriptions)
|
|
66
51
|
mod:AddCallbackCustom(ModCallbacksCustom.MC_POST_PEFFECT_UPDATE_REORDERED, postPEffectUpdateReordered)
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
2
|
local ____lualib = require("lualib_bundle")
|
|
3
|
-
local Map = ____lualib.Map
|
|
4
3
|
local __TS__New = ____lualib.__TS__New
|
|
5
4
|
local ____exports = {}
|
|
6
|
-
local hasSubscriptions, entityTakeDmgPlayer, postPEffectUpdateReordered,
|
|
5
|
+
local hasSubscriptions, entityTakeDmgPlayer, postPEffectUpdateReordered, TRINKETS_THAT_CAN_BREAK, v
|
|
7
6
|
local ____exports = require("features.saveDataManager.exports")
|
|
8
7
|
local saveDataManager = ____exports.saveDataManager
|
|
9
8
|
local ____player = require("functions.player")
|
|
10
9
|
local getPlayerIndex = ____player.getPlayerIndex
|
|
10
|
+
local ____DefaultMap = require("types.DefaultMap")
|
|
11
|
+
local DefaultMap = ____DefaultMap.DefaultMap
|
|
11
12
|
local ____ModCallbacksCustom = require("types.ModCallbacksCustom")
|
|
12
13
|
local ModCallbacksCustom = ____ModCallbacksCustom.ModCallbacksCustom
|
|
13
14
|
local ____postTrinketBreak = require("callbacks.subscriptions.postTrinketBreak")
|
|
@@ -24,45 +25,41 @@ function entityTakeDmgPlayer(self, tookDamage, _damageAmount, _damageFlags, _dam
|
|
|
24
25
|
if player == nil then
|
|
25
26
|
return
|
|
26
27
|
end
|
|
27
|
-
local
|
|
28
|
+
local playerIndex = getPlayerIndex(nil, player)
|
|
29
|
+
local trinketMap = v.run.playersTrinketMap:getAndSetDefault(playerIndex)
|
|
28
30
|
for ____, trinketType in ipairs(TRINKETS_THAT_CAN_BREAK) do
|
|
29
31
|
do
|
|
30
32
|
local numTrinketsHeld = player:GetTrinketMultiplier(trinketType)
|
|
31
|
-
local oldNumTrinketsHeld = trinketMap:
|
|
32
|
-
if
|
|
33
|
-
goto
|
|
33
|
+
local oldNumTrinketsHeld = trinketMap:getAndSetDefault(trinketType)
|
|
34
|
+
if numTrinketsHeld >= oldNumTrinketsHeld then
|
|
35
|
+
goto __continue8
|
|
34
36
|
end
|
|
35
37
|
trinketMap:set(trinketType, numTrinketsHeld)
|
|
36
38
|
local numTrinketsOnGround = Isaac.CountEntities(nil, EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, trinketType)
|
|
37
39
|
if numTrinketsOnGround > 0 then
|
|
38
|
-
goto
|
|
40
|
+
goto __continue8
|
|
39
41
|
end
|
|
40
42
|
postTrinketBreakFire(nil, player, trinketType)
|
|
41
43
|
end
|
|
42
|
-
::
|
|
44
|
+
::__continue8::
|
|
43
45
|
end
|
|
44
46
|
end
|
|
45
47
|
function postPEffectUpdateReordered(self, player)
|
|
46
48
|
if not hasSubscriptions(nil) then
|
|
47
49
|
return
|
|
48
50
|
end
|
|
49
|
-
local
|
|
51
|
+
local playerIndex = getPlayerIndex(nil, player)
|
|
52
|
+
local trinketMap = v.run.playersTrinketMap:getAndSetDefault(playerIndex)
|
|
50
53
|
for ____, trinketType in ipairs(TRINKETS_THAT_CAN_BREAK) do
|
|
51
54
|
local numTrinkets = player:GetTrinketMultiplier(trinketType)
|
|
52
55
|
trinketMap:set(trinketType, numTrinkets)
|
|
53
56
|
end
|
|
54
57
|
end
|
|
55
|
-
function getTrinketMap(self, player)
|
|
56
|
-
local playerIndex = getPlayerIndex(nil, player)
|
|
57
|
-
local playerTrinketMap = v.run.playerTrinketMap:get(playerIndex)
|
|
58
|
-
if playerTrinketMap == nil then
|
|
59
|
-
playerTrinketMap = __TS__New(Map)
|
|
60
|
-
v.run.playerTrinketMap:set(playerIndex, playerTrinketMap)
|
|
61
|
-
end
|
|
62
|
-
return playerTrinketMap
|
|
63
|
-
end
|
|
64
58
|
TRINKETS_THAT_CAN_BREAK = {TrinketType.TRINKET_WISH_BONE, TrinketType.TRINKET_WALNUT}
|
|
65
|
-
v = {run = {
|
|
59
|
+
v = {run = {playersTrinketMap = __TS__New(
|
|
60
|
+
DefaultMap,
|
|
61
|
+
function() return __TS__New(DefaultMap, 0) end
|
|
62
|
+
)}}
|
|
66
63
|
function ____exports.postTrinketBreakCallbackInit(self, mod)
|
|
67
64
|
saveDataManager(nil, "postTrinketBreak", v, hasSubscriptions)
|
|
68
65
|
mod:AddCallback(ModCallbacks.MC_ENTITY_TAKE_DMG, entityTakeDmgPlayer, EntityType.ENTITY_PLAYER)
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
local ____lualib = require("lualib_bundle")
|
|
3
3
|
local Set = ____lualib.Set
|
|
4
4
|
local __TS__New = ____lualib.__TS__New
|
|
5
|
-
local Map = ____lualib.Map
|
|
6
5
|
local __TS__ArrayPush = ____lualib.__TS__ArrayPush
|
|
6
|
+
local Map = ____lualib.Map
|
|
7
7
|
local __TS__Iterator = ____lualib.__TS__Iterator
|
|
8
8
|
local ____exports = {}
|
|
9
9
|
local postNewRoom, setDecorationsInvisible, respawnPersistentEntities, removeSpecificNPCs, fillRoomWithDecorations, spawnAllEntities, spawnGridEntityForJSONRoom, spawnNormalEntityForJSONRoom, storePersistentEntity, fixPitGraphics, getPitMap, getPitFrame, FEATURE_NAME, NPC_TYPES_TO_NOT_REMOVE, PERSISTENT_ENTITY_TYPES, initialized, v
|
|
@@ -34,6 +34,8 @@ local setRoomCleared = ____rooms.setRoomCleared
|
|
|
34
34
|
local setRoomUncleared = ____rooms.setRoomUncleared
|
|
35
35
|
local ____spawnCollectible = require("functions.spawnCollectible")
|
|
36
36
|
local spawnCollectible = ____spawnCollectible.spawnCollectible
|
|
37
|
+
local ____DefaultMap = require("types.DefaultMap")
|
|
38
|
+
local DefaultMap = ____DefaultMap.DefaultMap
|
|
37
39
|
local ____exports = require("features.saveDataManager.exports")
|
|
38
40
|
local saveDataManager = ____exports.saveDataManager
|
|
39
41
|
function postNewRoom(self)
|
|
@@ -48,10 +50,7 @@ function setDecorationsInvisible(self)
|
|
|
48
50
|
local game = Game()
|
|
49
51
|
local room = game:GetRoom()
|
|
50
52
|
local roomListIndex = getRoomListIndex(nil)
|
|
51
|
-
local decorationGridIndexes = v.level.
|
|
52
|
-
if decorationGridIndexes == nil then
|
|
53
|
-
return
|
|
54
|
-
end
|
|
53
|
+
local decorationGridIndexes = v.level.roomToDecorationGridIndexesMap:getAndSetDefault(roomListIndex)
|
|
55
54
|
for ____, gridIndex in ipairs(decorationGridIndexes) do
|
|
56
55
|
local gridEntity = room:GetGridEntity(gridIndex)
|
|
57
56
|
if gridEntity ~= nil then
|
|
@@ -63,10 +62,7 @@ function respawnPersistentEntities(self)
|
|
|
63
62
|
local game = Game()
|
|
64
63
|
local room = game:GetRoom()
|
|
65
64
|
local roomListIndex = getRoomListIndex(nil)
|
|
66
|
-
local persistentEntities = v.level.
|
|
67
|
-
if persistentEntities == nil then
|
|
68
|
-
return
|
|
69
|
-
end
|
|
65
|
+
local persistentEntities = v.level.roomToPersistentEntitiesMap:getAndSetDefault(roomListIndex)
|
|
70
66
|
for ____, persistentEntity in ipairs(persistentEntities) do
|
|
71
67
|
local position = room:GetGridPosition(persistentEntity.gridIndex)
|
|
72
68
|
Isaac.Spawn(
|
|
@@ -124,18 +120,14 @@ function fillRoomWithDecorations(self)
|
|
|
124
120
|
local room = game:GetRoom()
|
|
125
121
|
local gridSize = room:GetGridSize()
|
|
126
122
|
local roomListIndex = getRoomListIndex(nil)
|
|
127
|
-
local decorationGridIndexes = v.level.
|
|
128
|
-
if decorationGridIndexes == nil then
|
|
129
|
-
decorationGridIndexes = {}
|
|
130
|
-
v.level.decorationGridIndexes:set(roomListIndex, decorationGridIndexes)
|
|
131
|
-
end
|
|
123
|
+
local decorationGridIndexes = v.level.roomToDecorationGridIndexesMap:getAndSetDefault(roomListIndex)
|
|
132
124
|
do
|
|
133
125
|
local gridIndex = 0
|
|
134
126
|
while gridIndex < gridSize do
|
|
135
127
|
do
|
|
136
128
|
local existingGridEntity = room:GetGridEntity(gridIndex)
|
|
137
129
|
if existingGridEntity ~= nil then
|
|
138
|
-
goto
|
|
130
|
+
goto __continue33
|
|
139
131
|
end
|
|
140
132
|
local position = room:GetGridPosition(gridIndex)
|
|
141
133
|
local decoration = Isaac.GridSpawn(GridEntityType.GRID_DECORATION, 0, position, true)
|
|
@@ -144,7 +136,7 @@ function fillRoomWithDecorations(self)
|
|
|
144
136
|
end
|
|
145
137
|
__TS__ArrayPush(decorationGridIndexes, gridIndex)
|
|
146
138
|
end
|
|
147
|
-
::
|
|
139
|
+
::__continue33::
|
|
148
140
|
gridIndex = gridIndex + 1
|
|
149
141
|
end
|
|
150
142
|
end
|
|
@@ -288,11 +280,7 @@ function storePersistentEntity(self, entity)
|
|
|
288
280
|
local gridIndex = room:GetGridIndex(entity.Position)
|
|
289
281
|
local roomListIndex = getRoomListIndex(nil)
|
|
290
282
|
local persistentEntity = {gridIndex = gridIndex, type = entity.Type, variant = entity.Variant, subType = entity.SubType}
|
|
291
|
-
local persistentEntities = v.level.
|
|
292
|
-
if persistentEntities == nil then
|
|
293
|
-
persistentEntities = {}
|
|
294
|
-
v.level.persistentEntities:set(roomListIndex, persistentEntities)
|
|
295
|
-
end
|
|
283
|
+
local persistentEntities = v.level.roomToPersistentEntitiesMap:getAndSetDefault(roomListIndex)
|
|
296
284
|
__TS__ArrayPush(persistentEntities, persistentEntity)
|
|
297
285
|
end
|
|
298
286
|
function fixPitGraphics(self)
|
|
@@ -412,8 +400,14 @@ PERSISTENT_ENTITY_TYPES = __TS__New(Set, {EntityType.ENTITY_WALL_HUGGER})
|
|
|
412
400
|
initialized = false
|
|
413
401
|
v = {level = {
|
|
414
402
|
deployedRoomListIndexes = __TS__New(Set),
|
|
415
|
-
|
|
416
|
-
|
|
403
|
+
roomToPersistentEntitiesMap = __TS__New(
|
|
404
|
+
DefaultMap,
|
|
405
|
+
function() return {} end
|
|
406
|
+
),
|
|
407
|
+
roomToDecorationGridIndexesMap = __TS__New(
|
|
408
|
+
DefaultMap,
|
|
409
|
+
function() return {} end
|
|
410
|
+
)
|
|
417
411
|
}}
|
|
418
412
|
function ____exports.deployJSONRoomInit(self, mod)
|
|
419
413
|
initialized = true
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -3,12 +3,12 @@ local ____lualib = require("lualib_bundle")
|
|
|
3
3
|
local __TS__StringTrim = ____lualib.__TS__StringTrim
|
|
4
4
|
local ____exports = {}
|
|
5
5
|
local readSaveDatFile, tryLoadModData, DEFAULT_MOD_DATA
|
|
6
|
-
local ____debug = require("debug")
|
|
7
|
-
local DEBUG = ____debug.DEBUG
|
|
8
6
|
local ____json = require("functions.json")
|
|
9
7
|
local jsonDecode = ____json.jsonDecode
|
|
10
8
|
local ____log = require("functions.log")
|
|
11
9
|
local log = ____log.log
|
|
10
|
+
local ____debug = require("features.saveDataManager.debug")
|
|
11
|
+
local SAVE_DATA_MANAGER_DEBUG = ____debug.SAVE_DATA_MANAGER_DEBUG
|
|
12
12
|
local ____merge = require("features.saveDataManager.merge")
|
|
13
13
|
local merge = ____merge.merge
|
|
14
14
|
function readSaveDatFile(self, mod)
|
|
@@ -37,13 +37,12 @@ function ____exports.loadFromDisk(self, mod, oldSaveData)
|
|
|
37
37
|
end
|
|
38
38
|
local jsonString = readSaveDatFile(nil, mod)
|
|
39
39
|
local newSaveData = jsonDecode(nil, jsonString)
|
|
40
|
-
if
|
|
40
|
+
if SAVE_DATA_MANAGER_DEBUG then
|
|
41
41
|
log("Converted data from the \"save#.dat\" to a Lua table.")
|
|
42
42
|
end
|
|
43
43
|
for key, value in pairs(newSaveData) do
|
|
44
44
|
do
|
|
45
|
-
|
|
46
|
-
if keyType ~= "string" then
|
|
45
|
+
if type(key) ~= "string" then
|
|
47
46
|
goto __continue5
|
|
48
47
|
end
|
|
49
48
|
local valueType = type(value)
|
|
@@ -54,8 +53,8 @@ function ____exports.loadFromDisk(self, mod, oldSaveData)
|
|
|
54
53
|
if oldSaveDataForSubscriber == nil then
|
|
55
54
|
goto __continue5
|
|
56
55
|
end
|
|
57
|
-
if
|
|
58
|
-
log("Merging in stored data for feature: " ..
|
|
56
|
+
if SAVE_DATA_MANAGER_DEBUG then
|
|
57
|
+
log("Merging in stored data for feature: " .. key)
|
|
59
58
|
end
|
|
60
59
|
merge(nil, oldSaveDataForSubscriber, value, key)
|
|
61
60
|
end
|
|
@@ -5,23 +5,23 @@ local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
|
5
5
|
local Set = ____lualib.Set
|
|
6
6
|
local ____exports = {}
|
|
7
7
|
local mergeArray, mergeTSTLObject, mergeTable, mergeVector
|
|
8
|
-
local ____constantsInternal = require("constantsInternal")
|
|
9
|
-
local TSTL_OBJECT_WITH_NUMBER_KEYS_BRAND = ____constantsInternal.TSTL_OBJECT_WITH_NUMBER_KEYS_BRAND
|
|
10
|
-
local ____debug = require("debug")
|
|
11
|
-
local DEBUG = ____debug.DEBUG
|
|
12
8
|
local ____array = require("functions.array")
|
|
13
9
|
local isArray = ____array.isArray
|
|
14
10
|
local ____deepCopy = require("functions.deepCopy")
|
|
15
11
|
local addTraversalDescription = ____deepCopy.addTraversalDescription
|
|
16
12
|
local deepCopy = ____deepCopy.deepCopy
|
|
17
13
|
local deserializeVector = ____deepCopy.deserializeVector
|
|
18
|
-
local isBrand = ____deepCopy.isBrand
|
|
19
14
|
local isSerializedVector = ____deepCopy.isSerializedVector
|
|
20
15
|
local SerializationType = ____deepCopy.SerializationType
|
|
21
16
|
local ____log = require("functions.log")
|
|
22
17
|
local log = ____log.log
|
|
23
18
|
local ____table = require("functions.table")
|
|
24
19
|
local clearTable = ____table.clearTable
|
|
20
|
+
local ____SerializationBrand = require("types.SerializationBrand")
|
|
21
|
+
local isSerializationBrand = ____SerializationBrand.isSerializationBrand
|
|
22
|
+
local SerializationBrand = ____SerializationBrand.SerializationBrand
|
|
23
|
+
local ____debug = require("features.saveDataManager.debug")
|
|
24
|
+
local SAVE_DATA_MANAGER_DEBUG = ____debug.SAVE_DATA_MANAGER_DEBUG
|
|
25
25
|
function ____exports.merge(self, oldObject, newTable, traversalDescription)
|
|
26
26
|
local oldObjectType = type(oldObject)
|
|
27
27
|
if oldObjectType ~= "table" then
|
|
@@ -31,7 +31,7 @@ function ____exports.merge(self, oldObject, newTable, traversalDescription)
|
|
|
31
31
|
if newTableType ~= "table" then
|
|
32
32
|
error("The second argument given to the merge function is not a table.")
|
|
33
33
|
end
|
|
34
|
-
if
|
|
34
|
+
if SAVE_DATA_MANAGER_DEBUG then
|
|
35
35
|
log("merge is operating on: " .. traversalDescription)
|
|
36
36
|
end
|
|
37
37
|
if mergeArray(nil, oldObject, newTable) then
|
|
@@ -56,10 +56,10 @@ function mergeArray(self, oldObject, newTable)
|
|
|
56
56
|
end
|
|
57
57
|
function mergeTSTLObject(self, oldObject, newTable, traversalDescription)
|
|
58
58
|
oldObject:clear()
|
|
59
|
-
local convertStringKeysToNumbers = newTable[
|
|
59
|
+
local convertStringKeysToNumbers = newTable[SerializationBrand.OBJECT_WITH_NUMBER_KEYS] ~= nil
|
|
60
60
|
for key, value in pairs(newTable) do
|
|
61
61
|
do
|
|
62
|
-
if
|
|
62
|
+
if isSerializationBrand(nil, key) then
|
|
63
63
|
goto __continue13
|
|
64
64
|
end
|
|
65
65
|
local keyToUse = key
|
|
@@ -89,7 +89,7 @@ end
|
|
|
89
89
|
function mergeTable(self, oldTable, newTable, traversalDescription)
|
|
90
90
|
for key, value in pairs(newTable) do
|
|
91
91
|
do
|
|
92
|
-
if
|
|
92
|
+
if isSerializationBrand(nil, key) then
|
|
93
93
|
goto __continue22
|
|
94
94
|
end
|
|
95
95
|
if mergeVector(nil, oldTable, key, value) then
|
|
@@ -104,7 +104,7 @@ function mergeTable(self, oldTable, newTable, traversalDescription)
|
|
|
104
104
|
____exports.merge(nil, oldValue, value, traversalDescription)
|
|
105
105
|
end
|
|
106
106
|
else
|
|
107
|
-
if
|
|
107
|
+
if SAVE_DATA_MANAGER_DEBUG then
|
|
108
108
|
log((("Merging key \"" .. tostring(key)) .. "\" with value: ") .. tostring(value))
|
|
109
109
|
end
|
|
110
110
|
oldTable[key] = value
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
2
|
local ____lualib = require("lualib_bundle")
|
|
3
3
|
local Map = ____lualib.Map
|
|
4
|
+
local __TS__ObjectKeys = ____lualib.__TS__ObjectKeys
|
|
4
5
|
local ____exports = {}
|
|
5
6
|
local getAllSaveDataToWriteToDisk
|
|
6
7
|
local ____deepCopy = require("functions.deepCopy")
|
|
@@ -25,6 +26,9 @@ function getAllSaveDataToWriteToDisk(self, saveDataMap, saveDataConditionalFuncM
|
|
|
25
26
|
end
|
|
26
27
|
end
|
|
27
28
|
local saveDataWithoutRoom = {persistent = saveData.persistent, run = saveData.run, level = saveData.level}
|
|
29
|
+
if #__TS__ObjectKeys(saveDataWithoutRoom) == 0 then
|
|
30
|
+
goto __continue4
|
|
31
|
+
end
|
|
28
32
|
local saveDataCopy = deepCopy(nil, saveDataWithoutRoom, SerializationType.SERIALIZE, subscriberName)
|
|
29
33
|
allSaveData[subscriberName] = saveDataCopy
|
|
30
34
|
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
|
+
local ____exports = {}
|
|
3
|
+
local featuresInitialized = false
|
|
4
|
+
function ____exports.areFeaturesInitialized(self)
|
|
5
|
+
return featuresInitialized
|
|
6
|
+
end
|
|
7
|
+
function ____exports.setFeaturesInitialized(self)
|
|
8
|
+
featuresInitialized = true
|
|
9
|
+
end
|
|
10
|
+
return ____exports
|
package/dist/functions/array.lua
CHANGED
|
@@ -164,8 +164,7 @@ function ____exports.isArray(self, ____table)
|
|
|
164
164
|
local numEntries = 0
|
|
165
165
|
for key in pairs(____table) do
|
|
166
166
|
numEntries = numEntries + 1
|
|
167
|
-
|
|
168
|
-
if keyType ~= "number" then
|
|
167
|
+
if type(key) ~= "number" then
|
|
169
168
|
return false
|
|
170
169
|
end
|
|
171
170
|
end
|
|
@@ -15,16 +15,16 @@ export declare enum SerializationType {
|
|
|
15
15
|
* - TSTL Maps
|
|
16
16
|
* - TSTL Sets
|
|
17
17
|
* - TSTL Classes
|
|
18
|
+
* - DefaultMaps
|
|
18
19
|
* - Isaac Vectors
|
|
19
20
|
*
|
|
20
21
|
* @param oldObject The object to copy.
|
|
21
22
|
* @param serializationType Has 3 possible values. Can leave TypeScriptToLua objects as-is, or can
|
|
22
|
-
* serialize objects to Lua tables, or can deserialize Lua tables to objects.
|
|
23
|
-
* default.
|
|
23
|
+
* serialize objects to Lua tables, or can deserialize Lua tables to objects. Will perform no
|
|
24
|
+
* serialization by default.
|
|
24
25
|
* @param traversalDescription Used to track the current key that we are operating on.
|
|
25
26
|
*/
|
|
26
27
|
export declare function deepCopy(oldObject: LuaTable | Map<AnyNotNil, unknown> | Set<AnyNotNil>, serializationType?: SerializationType, traversalDescription?: string): LuaTable | Map<AnyNotNil, unknown> | Set<AnyNotNil>;
|
|
27
|
-
export declare function isBrand(key: AnyNotNil): boolean;
|
|
28
28
|
export declare function deserializeVector(vectorTable: LuaTable): Vector;
|
|
29
29
|
export declare function addTraversalDescription(key: AnyNotNil, traversalDescription: string): string;
|
|
30
30
|
/**
|
|
@@ -7,14 +7,13 @@ local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
|
7
7
|
local __TS__Iterator = ____lualib.__TS__Iterator
|
|
8
8
|
local ____exports = {}
|
|
9
9
|
local isTSTLClass, copyClass, getNewClassFromMetatable, deepCopyValue, copyVector, checkMetatable, validateValue, TSTL_CLASS_KEYS
|
|
10
|
-
local
|
|
11
|
-
local
|
|
12
|
-
local
|
|
13
|
-
local
|
|
14
|
-
local
|
|
15
|
-
local
|
|
16
|
-
local
|
|
17
|
-
local DEBUG = ____debug.DEBUG
|
|
10
|
+
local ____debug = require("features.saveDataManager.debug")
|
|
11
|
+
local SAVE_DATA_MANAGER_DEBUG = ____debug.SAVE_DATA_MANAGER_DEBUG
|
|
12
|
+
local ____DefaultMap = require("types.DefaultMap")
|
|
13
|
+
local DefaultMap = ____DefaultMap.DefaultMap
|
|
14
|
+
local ____SerializationBrand = require("types.SerializationBrand")
|
|
15
|
+
local isSerializationBrand = ____SerializationBrand.isSerializationBrand
|
|
16
|
+
local SerializationBrand = ____SerializationBrand.SerializationBrand
|
|
18
17
|
local ____log = require("functions.log")
|
|
19
18
|
local log = ____log.log
|
|
20
19
|
local ____vector = require("functions.vector")
|
|
@@ -30,7 +29,7 @@ function ____exports.deepCopy(self, oldObject, serializationType, traversalDescr
|
|
|
30
29
|
if oldObjectType ~= "table" then
|
|
31
30
|
error(("The deepCopy function was given a " .. oldObjectType) .. " instead of a table.")
|
|
32
31
|
end
|
|
33
|
-
if
|
|
32
|
+
if SAVE_DATA_MANAGER_DEBUG then
|
|
34
33
|
local logString = "deepCopy is operating on: " .. traversalDescription
|
|
35
34
|
if serializationType == ____exports.SerializationType.SERIALIZE then
|
|
36
35
|
logString = logString .. " (serializing)"
|
|
@@ -41,17 +40,30 @@ function ____exports.deepCopy(self, oldObject, serializationType, traversalDescr
|
|
|
41
40
|
end
|
|
42
41
|
local oldTable = oldObject
|
|
43
42
|
local isClass = isTSTLClass(nil, oldTable)
|
|
43
|
+
local hasTSTLDefaultMapBrand = false
|
|
44
44
|
local hasTSTLMapBrand = false
|
|
45
45
|
local hasTSTLSetBrand = false
|
|
46
46
|
local hasTSTLClassBrand = false
|
|
47
47
|
if not __TS__InstanceOf(oldObject, Map) and not __TS__InstanceOf(oldObject, Set) and not isClass then
|
|
48
48
|
checkMetatable(nil, oldTable, traversalDescription)
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
hasTSTLDefaultMapBrand = oldTable[SerializationBrand.DEFAULT_MAP] ~= nil
|
|
50
|
+
hasTSTLMapBrand = oldTable[SerializationBrand.MAP] ~= nil
|
|
51
|
+
hasTSTLSetBrand = oldTable[SerializationBrand.SET] ~= nil
|
|
52
|
+
hasTSTLClassBrand = oldTable[SerializationBrand.CLASS] ~= nil
|
|
52
53
|
end
|
|
53
54
|
local newObject
|
|
54
|
-
if serializationType == ____exports.SerializationType.NONE and __TS__InstanceOf(oldObject,
|
|
55
|
+
if serializationType == ____exports.SerializationType.NONE and __TS__InstanceOf(oldObject, DefaultMap) then
|
|
56
|
+
local oldDefaultMap = oldObject
|
|
57
|
+
local constructorArg = oldDefaultMap:getConstructorArg()
|
|
58
|
+
newObject = __TS__New(DefaultMap, constructorArg)
|
|
59
|
+
elseif serializationType == ____exports.SerializationType.DESERIALIZE and hasTSTLDefaultMapBrand then
|
|
60
|
+
local defaultValue = oldTable[SerializationBrand.DEFAULT_MAP_VALUE]
|
|
61
|
+
if type(defaultValue) ~= "boolean" and type(defaultValue) ~= "number" and type(defaultValue) ~= "string" then
|
|
62
|
+
error("The deepCopy function failed to get a valid default value for a DefaultMap object when deserializing.")
|
|
63
|
+
else
|
|
64
|
+
newObject = __TS__New(DefaultMap, defaultValue)
|
|
65
|
+
end
|
|
66
|
+
elseif serializationType == ____exports.SerializationType.NONE and __TS__InstanceOf(oldObject, Map) or serializationType == ____exports.SerializationType.DESERIALIZE and hasTSTLMapBrand then
|
|
55
67
|
newObject = __TS__New(Map)
|
|
56
68
|
elseif serializationType == ____exports.SerializationType.NONE and __TS__InstanceOf(oldObject, Set) or serializationType == ____exports.SerializationType.DESERIALIZE and hasTSTLSetBrand then
|
|
57
69
|
newObject = __TS__New(Set)
|
|
@@ -62,12 +74,19 @@ function ____exports.deepCopy(self, oldObject, serializationType, traversalDescr
|
|
|
62
74
|
end
|
|
63
75
|
if serializationType == ____exports.SerializationType.SERIALIZE then
|
|
64
76
|
local newTable = newObject
|
|
65
|
-
if __TS__InstanceOf(oldObject,
|
|
66
|
-
newTable[
|
|
77
|
+
if __TS__InstanceOf(oldObject, DefaultMap) then
|
|
78
|
+
newTable[SerializationBrand.DEFAULT_MAP] = ""
|
|
79
|
+
local oldDefaultMap = oldObject
|
|
80
|
+
local defaultValue = oldDefaultMap:getConstructorArg()
|
|
81
|
+
if type(defaultValue) == "boolean" or type(defaultValue) == "number" or type(defaultValue) == "string" then
|
|
82
|
+
newTable[SerializationBrand.DEFAULT_MAP_VALUE] = defaultValue
|
|
83
|
+
end
|
|
84
|
+
elseif __TS__InstanceOf(oldObject, Map) then
|
|
85
|
+
newTable[SerializationBrand.MAP] = ""
|
|
67
86
|
elseif __TS__InstanceOf(oldObject, Set) then
|
|
68
|
-
newTable[
|
|
87
|
+
newTable[SerializationBrand.SET] = ""
|
|
69
88
|
elseif isClass then
|
|
70
|
-
newTable[
|
|
89
|
+
newTable[SerializationBrand.CLASS] = ""
|
|
71
90
|
end
|
|
72
91
|
end
|
|
73
92
|
if __TS__InstanceOf(oldObject, Map) then
|
|
@@ -75,8 +94,8 @@ function ____exports.deepCopy(self, oldObject, serializationType, traversalDescr
|
|
|
75
94
|
local key = ____value[1]
|
|
76
95
|
local value = ____value[2]
|
|
77
96
|
do
|
|
78
|
-
if
|
|
79
|
-
goto
|
|
97
|
+
if isSerializationBrand(nil, key) then
|
|
98
|
+
goto __continue23
|
|
80
99
|
end
|
|
81
100
|
deepCopyValue(
|
|
82
101
|
nil,
|
|
@@ -88,13 +107,13 @@ function ____exports.deepCopy(self, oldObject, serializationType, traversalDescr
|
|
|
88
107
|
serializationType
|
|
89
108
|
)
|
|
90
109
|
end
|
|
91
|
-
::
|
|
110
|
+
::__continue23::
|
|
92
111
|
end
|
|
93
112
|
elseif __TS__InstanceOf(oldObject, Set) then
|
|
94
113
|
for ____, key in __TS__Iterator(oldObject:values()) do
|
|
95
114
|
do
|
|
96
|
-
if
|
|
97
|
-
goto
|
|
115
|
+
if isSerializationBrand(nil, key) then
|
|
116
|
+
goto __continue27
|
|
98
117
|
end
|
|
99
118
|
local value = ""
|
|
100
119
|
deepCopyValue(
|
|
@@ -107,13 +126,13 @@ function ____exports.deepCopy(self, oldObject, serializationType, traversalDescr
|
|
|
107
126
|
serializationType
|
|
108
127
|
)
|
|
109
128
|
end
|
|
110
|
-
::
|
|
129
|
+
::__continue27::
|
|
111
130
|
end
|
|
112
131
|
else
|
|
113
132
|
for key, value in pairs(oldObject) do
|
|
114
133
|
do
|
|
115
|
-
if
|
|
116
|
-
goto
|
|
134
|
+
if isSerializationBrand(nil, key) then
|
|
135
|
+
goto __continue31
|
|
117
136
|
end
|
|
118
137
|
deepCopyValue(
|
|
119
138
|
nil,
|
|
@@ -125,7 +144,7 @@ function ____exports.deepCopy(self, oldObject, serializationType, traversalDescr
|
|
|
125
144
|
serializationType
|
|
126
145
|
)
|
|
127
146
|
end
|
|
128
|
-
::
|
|
147
|
+
::__continue31::
|
|
129
148
|
end
|
|
130
149
|
end
|
|
131
150
|
return newObject
|
|
@@ -141,6 +160,9 @@ function isTSTLClass(self, object)
|
|
|
141
160
|
local numKeys = 0
|
|
142
161
|
for key in pairs(metatable) do
|
|
143
162
|
numKeys = numKeys + 1
|
|
163
|
+
if type(key) ~= "string" then
|
|
164
|
+
return false
|
|
165
|
+
end
|
|
144
166
|
if not TSTL_CLASS_KEYS:has(key) then
|
|
145
167
|
return false
|
|
146
168
|
end
|
|
@@ -161,9 +183,6 @@ function getNewClassFromMetatable(self, metatable)
|
|
|
161
183
|
newClass:____constructor()
|
|
162
184
|
return newClass
|
|
163
185
|
end
|
|
164
|
-
function ____exports.isBrand(self, key)
|
|
165
|
-
return key == TSTL_MAP_BRAND or key == TSTL_SET_BRAND or key == TSTL_CLASS_BRAND or key == TSTL_OBJECT_WITH_NUMBER_KEYS_BRAND or key == VECTOR_BRAND
|
|
166
|
-
end
|
|
167
186
|
function deepCopyValue(self, oldObject, newObject, key, value, traversalDescription, serializationType)
|
|
168
187
|
local valueType = type(value)
|
|
169
188
|
validateValue(nil, value, valueType, traversalDescription)
|
|
@@ -173,8 +192,8 @@ function deepCopyValue(self, oldObject, newObject, key, value, traversalDescript
|
|
|
173
192
|
if serializationType == ____exports.SerializationType.SERIALIZE and isTSTLObject and keyType == "number" then
|
|
174
193
|
convertNumberKeysToString = true
|
|
175
194
|
local newTable = newObject
|
|
176
|
-
newTable[
|
|
177
|
-
if
|
|
195
|
+
newTable[SerializationBrand.OBJECT_WITH_NUMBER_KEYS] = ""
|
|
196
|
+
if SAVE_DATA_MANAGER_DEBUG then
|
|
178
197
|
log("deepCopy is converting a TSTL map with number keys to strings.")
|
|
179
198
|
end
|
|
180
199
|
end
|
|
@@ -206,7 +225,7 @@ function copyVector(self, vector, serializationType)
|
|
|
206
225
|
local vectorTable = {}
|
|
207
226
|
vectorTable.X = vector.X
|
|
208
227
|
vectorTable.Y = vector.Y
|
|
209
|
-
vectorTable[
|
|
228
|
+
vectorTable[SerializationBrand.VECTOR] = ""
|
|
210
229
|
return vectorTable
|
|
211
230
|
end
|
|
212
231
|
local newVector = Vector(vector.X, vector.Y)
|
|
@@ -254,7 +273,7 @@ function ____exports.isSerializedVector(self, object)
|
|
|
254
273
|
return false
|
|
255
274
|
end
|
|
256
275
|
local ____table = object
|
|
257
|
-
return ____table[
|
|
276
|
+
return ____table[SerializationBrand.VECTOR] ~= nil and ____table.X ~= nil and ____table.Y ~= nil
|
|
258
277
|
end
|
|
259
278
|
____exports.SerializationType = SerializationType or ({})
|
|
260
279
|
____exports.SerializationType.NONE = 0
|
|
@@ -5,11 +5,16 @@ local __TS__New = ____lualib.__TS__New
|
|
|
5
5
|
local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
6
6
|
local Set = ____lualib.Set
|
|
7
7
|
local ____exports = {}
|
|
8
|
-
local copiedObjectIsTable, copiedObjectHasKeyAndValueString, copiedTableHasKeyAndValueNumber, copiedTableDoesNotCoerceTypes, copiedObjectHasNoReferencesForPrimitivesForward, copiedObjectHasNoReferencesForPrimitivesBackward, copiedObjectHasNoReferencesForArray, copiedObjectHasChildObject, copiedMapIsMap, copiedMapHasValue, copiedSetIsSet, copiedSetHasValue, copiedMapHasChildMap
|
|
8
|
+
local copiedObjectIsTable, copiedObjectHasKeyAndValueString, copiedTableHasKeyAndValueNumber, copiedTableDoesNotCoerceTypes, copiedObjectHasNoReferencesForPrimitivesForward, copiedObjectHasNoReferencesForPrimitivesBackward, copiedObjectHasNoReferencesForArray, copiedObjectHasChildObject, copiedMapIsMap, copiedMapHasValue, copiedSetIsSet, copiedSetHasValue, copiedMapHasChildMap, copiedDefaultMapHasChildDefaultMap, copiedDefaultMapHasBrand
|
|
9
|
+
local ____DefaultMap = require("types.DefaultMap")
|
|
10
|
+
local DefaultMap = ____DefaultMap.DefaultMap
|
|
11
|
+
local ____SerializationBrand = require("types.SerializationBrand")
|
|
12
|
+
local SerializationBrand = ____SerializationBrand.SerializationBrand
|
|
9
13
|
local ____array = require("functions.array")
|
|
10
14
|
local arrayEquals = ____array.arrayEquals
|
|
11
15
|
local ____deepCopy = require("functions.deepCopy")
|
|
12
16
|
local deepCopy = ____deepCopy.deepCopy
|
|
17
|
+
local SerializationType = ____deepCopy.SerializationType
|
|
13
18
|
local ____log = require("functions.log")
|
|
14
19
|
local log = ____log.log
|
|
15
20
|
function copiedObjectIsTable(self)
|
|
@@ -241,6 +246,59 @@ function copiedMapHasChildMap(self)
|
|
|
241
246
|
error("The copied child Map did not have a value of: " .. tostring(childMapValue))
|
|
242
247
|
end
|
|
243
248
|
end
|
|
249
|
+
function copiedDefaultMapHasChildDefaultMap(self)
|
|
250
|
+
local parentMapKey = "abc"
|
|
251
|
+
local childMapKey1 = 123
|
|
252
|
+
local childMapKey2 = 456
|
|
253
|
+
local childMapDefaultValue = 1
|
|
254
|
+
local childMapCustomValue = 2
|
|
255
|
+
local oldParentMap = __TS__New(
|
|
256
|
+
DefaultMap,
|
|
257
|
+
function() return __TS__New(DefaultMap, childMapDefaultValue) end
|
|
258
|
+
)
|
|
259
|
+
local oldChildMap = oldParentMap:getAndSetDefault(parentMapKey)
|
|
260
|
+
oldChildMap:getAndSetDefault(childMapKey1)
|
|
261
|
+
oldChildMap:set(childMapKey2, childMapCustomValue)
|
|
262
|
+
local newTable = deepCopy(nil, oldParentMap)
|
|
263
|
+
local newParentMap = newTable
|
|
264
|
+
local newChildMap = newParentMap:get(parentMapKey)
|
|
265
|
+
if newChildMap == nil then
|
|
266
|
+
error("The copied DefaultMap did not have a child map at key: " .. parentMapKey)
|
|
267
|
+
end
|
|
268
|
+
local newChildMapType = type(newChildMap)
|
|
269
|
+
if newChildMapType ~= "table" then
|
|
270
|
+
error("The copied child DefaultMap had a type of: " .. newChildMapType)
|
|
271
|
+
end
|
|
272
|
+
if not __TS__InstanceOf(newChildMap, DefaultMap) then
|
|
273
|
+
error("The copied child DefaultMap was not a DefaultMap.")
|
|
274
|
+
end
|
|
275
|
+
local newChildMapValue1 = newChildMap:get(childMapKey1)
|
|
276
|
+
if newChildMapValue1 == nil then
|
|
277
|
+
error("The copied child DefaultMap did not have a key of: " .. tostring(childMapKey1))
|
|
278
|
+
end
|
|
279
|
+
if newChildMapValue1 ~= childMapDefaultValue then
|
|
280
|
+
error("The copied child Map did not have a default value of: " .. tostring(childMapDefaultValue))
|
|
281
|
+
end
|
|
282
|
+
local newChildMapValue2 = newChildMap:get(childMapKey2)
|
|
283
|
+
if newChildMapValue2 == nil then
|
|
284
|
+
error("The copied child DefaultMap did not have a key of: " .. tostring(childMapKey2))
|
|
285
|
+
end
|
|
286
|
+
if newChildMapValue2 ~= childMapCustomValue then
|
|
287
|
+
error("The copied child Map did not have a custom value of: " .. tostring(childMapCustomValue))
|
|
288
|
+
end
|
|
289
|
+
end
|
|
290
|
+
function copiedDefaultMapHasBrand(self)
|
|
291
|
+
local oldDefaultValue = "foo"
|
|
292
|
+
local oldDefaultMap = __TS__New(DefaultMap, oldDefaultValue)
|
|
293
|
+
local newTable = deepCopy(nil, oldDefaultMap, SerializationType.SERIALIZE)
|
|
294
|
+
if not (newTable[SerializationBrand.DEFAULT_MAP] ~= nil) then
|
|
295
|
+
error("The copied DefaultMap does not have the brand: " .. SerializationBrand.DEFAULT_MAP)
|
|
296
|
+
end
|
|
297
|
+
local serializedDefaultValue = newTable[SerializationBrand.DEFAULT_MAP]
|
|
298
|
+
if serializedDefaultValue ~= oldDefaultValue then
|
|
299
|
+
error("The copied DefaultMap does not have a serialized default value of: " .. oldDefaultValue)
|
|
300
|
+
end
|
|
301
|
+
end
|
|
244
302
|
function ____exports.deepCopyTests(self)
|
|
245
303
|
copiedObjectIsTable(nil)
|
|
246
304
|
copiedObjectHasKeyAndValueString(nil)
|
|
@@ -255,6 +313,8 @@ function ____exports.deepCopyTests(self)
|
|
|
255
313
|
copiedSetIsSet(nil)
|
|
256
314
|
copiedSetHasValue(nil)
|
|
257
315
|
copiedMapHasChildMap(nil)
|
|
316
|
+
copiedDefaultMapHasChildDefaultMap(nil)
|
|
317
|
+
copiedDefaultMapHasBrand(nil)
|
|
258
318
|
log("All tests passed!")
|
|
259
319
|
end
|
|
260
320
|
return ____exports
|
package/dist/functions/log.d.ts
CHANGED
|
@@ -38,7 +38,7 @@ export declare function logColor(this: void, color: Color): void;
|
|
|
38
38
|
export declare function logEntity(this: void, entity: Entity): void;
|
|
39
39
|
export declare function logKColor(this: void, kColor: KColor): void;
|
|
40
40
|
export declare function logMap(this: void, map: Map<AnyNotNil, unknown>): void;
|
|
41
|
-
export declare function logTable(this: void, table: unknown): void;
|
|
41
|
+
export declare function logTable(this: void, table: unknown, parentTables?: number): void;
|
|
42
42
|
export declare function logTemporaryEffects(this: void, player: EntityPlayer): void;
|
|
43
43
|
export declare function logSet(this: void, set: Set<AnyNotNil>): void;
|
|
44
44
|
export declare function logVector(this: void, vector: Vector): void;
|
package/dist/functions/log.lua
CHANGED
|
@@ -125,10 +125,24 @@ function ____exports.logMap(map)
|
|
|
125
125
|
end
|
|
126
126
|
____exports.log("The size of the map was: " .. tostring(map.size))
|
|
127
127
|
end
|
|
128
|
-
function ____exports.logTable(____table)
|
|
129
|
-
|
|
128
|
+
function ____exports.logTable(____table, parentTables)
|
|
129
|
+
if parentTables == nil then
|
|
130
|
+
parentTables = 0
|
|
131
|
+
end
|
|
132
|
+
local numSpaces = (parentTables + 1) * 2
|
|
133
|
+
if parentTables == 0 then
|
|
134
|
+
____exports.log("Printing out a Lua table:")
|
|
135
|
+
end
|
|
136
|
+
local indentation = string.rep(
|
|
137
|
+
" ",
|
|
138
|
+
math.floor(numSpaces)
|
|
139
|
+
)
|
|
130
140
|
for key, value in pairs(____table) do
|
|
131
|
-
____exports.log((("
|
|
141
|
+
____exports.log((((indentation .. "Key: ") .. tostring(key)) .. ", Value: ") .. tostring(value))
|
|
142
|
+
local valueType = type(value)
|
|
143
|
+
if valueType == "table" then
|
|
144
|
+
____exports.logTable(value, parentTables + 1)
|
|
145
|
+
end
|
|
132
146
|
end
|
|
133
147
|
end
|
|
134
148
|
function ____exports.logTemporaryEffects(player)
|
|
@@ -145,7 +159,7 @@ function ____exports.logTemporaryEffects(player)
|
|
|
145
159
|
do
|
|
146
160
|
local effect = effectsList:Get(i)
|
|
147
161
|
if effect == nil then
|
|
148
|
-
goto
|
|
162
|
+
goto __continue38
|
|
149
163
|
end
|
|
150
164
|
if effect.Item:IsCollectible() then
|
|
151
165
|
local collectibleName = getCollectibleName(nil, effect.Item.ID)
|
|
@@ -159,7 +173,7 @@ function ____exports.logTemporaryEffects(player)
|
|
|
159
173
|
____exports.log(((" " .. tostring(i + 1)) .. ") Unknown type of temporary effect: ") .. tostring(effect.Item.ID))
|
|
160
174
|
end
|
|
161
175
|
end
|
|
162
|
-
::
|
|
176
|
+
::__continue38::
|
|
163
177
|
i = i + 1
|
|
164
178
|
end
|
|
165
179
|
end
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
local ____exports = {}
|
|
3
3
|
local ____preventCollectibleRotate = require("features.preventCollectibleRotate")
|
|
4
4
|
local preventCollectibleRotate = ____preventCollectibleRotate.preventCollectibleRotate
|
|
5
|
-
local
|
|
6
|
-
local areFeaturesInitialized =
|
|
5
|
+
local ____featuresInitialized = require("featuresInitialized")
|
|
6
|
+
local areFeaturesInitialized = ____featuresInitialized.areFeaturesInitialized
|
|
7
7
|
local ____collectibles = require("functions.collectibles")
|
|
8
8
|
local isQuestCollectible = ____collectibles.isQuestCollectible
|
|
9
9
|
local ____player = require("functions.player")
|
|
@@ -40,10 +40,16 @@ export declare const ensureAllCases: (obj: never) => never;
|
|
|
40
40
|
* when you iterate over them, you will get both the names of the enums and the values of the enums,
|
|
41
41
|
* in a random order. If all you need are the values of an enum, use this helper function.
|
|
42
42
|
*
|
|
43
|
+
* This function will return the enum values in a sorted order, which may not necessarily be the
|
|
44
|
+
* same order as which they were declared in.
|
|
45
|
+
*
|
|
46
|
+
* This function will work properly for both number enums and string enums. (Reverse mappings are
|
|
47
|
+
* not created for string enums.)
|
|
48
|
+
*
|
|
43
49
|
* For a more in depth explanation, see:
|
|
44
50
|
* https://isaacscript.github.io/docs/gotchas#iterating-over-enums
|
|
45
51
|
*/
|
|
46
|
-
export declare function getEnumValues(transpiledEnum:
|
|
52
|
+
export declare function getEnumValues<T>(transpiledEnum: T): Array<T[keyof T]>;
|
|
47
53
|
/**
|
|
48
54
|
* Converts a hex string like "#33aa33" to a KColor object.
|
|
49
55
|
*
|
|
@@ -1,15 +1,42 @@
|
|
|
1
|
-
declare type
|
|
2
|
-
declare type
|
|
1
|
+
declare type FactoryFunction<K, V> = (k: K) => V;
|
|
2
|
+
declare type FirstArg<K, V> = Iterable<[K, V]> | V | FactoryFunction<K, V>;
|
|
3
|
+
declare type SecondArg<K, V> = V | FactoryFunction<K, V>;
|
|
3
4
|
/**
|
|
4
|
-
* An extended Map with
|
|
5
|
+
* An extended Map with some new methods:
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
* a default value.
|
|
7
|
+
* - `getAndSetDefault` - If the key exists, this will return the same thing as the `get` method.
|
|
8
|
+
* Otherwise, it will set a default value to the key, and then return the default value.
|
|
9
|
+
* - `getDefaultValue` - Returns the default value to be used for a new key. (If a factory function
|
|
10
|
+
* was provided during instantiation, this will execute the factory function.)
|
|
11
|
+
* - `getConstructorArg` - Helper method for cloning the map. Returns either the default value or
|
|
12
|
+
* the reference to the factory function.
|
|
13
|
+
*
|
|
14
|
+
* When instantiating a new DefaultMap, you must specify either a default value or a function that
|
|
15
|
+
* returns a default value.
|
|
8
16
|
*
|
|
9
17
|
* Example:
|
|
10
18
|
* ```ts
|
|
11
|
-
*
|
|
12
|
-
* const
|
|
19
|
+
* // Initializes a new empty DefaultMap with a default value of "foo"
|
|
20
|
+
* const defaultMapWithPrimitive = new DefaultMap<string, string>("foo");
|
|
21
|
+
*
|
|
22
|
+
* // Initializes a new empty DefaultMap with a default value of a new Map
|
|
23
|
+
* const defaultMapWithFactory = new DefaultMap<string, Map<string, string>>(() => {
|
|
24
|
+
* return new Map();
|
|
25
|
+
* })
|
|
26
|
+
*
|
|
27
|
+
* // Initializes a DefaultMap with some initial values and a default value of "bar"
|
|
28
|
+
* const defaultMapWithInitialValues = new DefaultMap<string, string>([
|
|
29
|
+
* ["a1", "a2"],
|
|
30
|
+
* ["b1", "b2"],
|
|
31
|
+
* ], "bar");
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* If specified, the first argument of a factory function must be equal to the key:
|
|
35
|
+
*
|
|
36
|
+
* ```ts
|
|
37
|
+
* const defaultMapWithConditionalDefaultValue = new DefaultMap<number, number>((key: number) => {
|
|
38
|
+
* return isOdd(key) ? 0 : 1;
|
|
39
|
+
* });
|
|
13
40
|
* ```
|
|
14
41
|
*/
|
|
15
42
|
export declare class DefaultMap<K, V> extends Map<K, V> {
|
|
@@ -21,10 +48,19 @@ export declare class DefaultMap<K, V> extends Map<K, V> {
|
|
|
21
48
|
*/
|
|
22
49
|
constructor(iterableOrDefaultValueOrDefaultValueFactory: FirstArg<K, V>, defaultValueOrDefaultValueFactory?: SecondArg<K, V>);
|
|
23
50
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
51
|
+
* If the key exists, this will return the same thing as the `get` method. Otherwise, it will set
|
|
52
|
+
* a default value to the key, and then return the default value.
|
|
53
|
+
*/
|
|
54
|
+
getAndSetDefault(key: K): V;
|
|
55
|
+
/**
|
|
56
|
+
* Returns the default value to be used for a new key. (If a factory function was provided during
|
|
57
|
+
* instantiation, this will execute the factory function.)
|
|
26
58
|
*/
|
|
27
|
-
getAndSetDefault(key: K): V | undefined;
|
|
28
59
|
getDefaultValue(key: K): V;
|
|
60
|
+
/**
|
|
61
|
+
* Helper method for cloning the map. Returns either the default value or a reference to the
|
|
62
|
+
* factory function.
|
|
63
|
+
*/
|
|
64
|
+
getConstructorArg(): V | FactoryFunction<K, V>;
|
|
29
65
|
}
|
|
30
66
|
export {};
|
|
@@ -3,13 +3,15 @@ local ____lualib = require("lualib_bundle")
|
|
|
3
3
|
local __TS__Class = ____lualib.__TS__Class
|
|
4
4
|
local Map = ____lualib.Map
|
|
5
5
|
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
6
|
+
local __TS__TypeOf = ____lualib.__TS__TypeOf
|
|
6
7
|
local ____exports = {}
|
|
7
8
|
local parseArguments, parseArgumentsOne, parseArgumentsTwo, parseDefaultValueOrDefaultValueFactory
|
|
8
9
|
function parseArguments(self, firstArg, secondArg)
|
|
9
10
|
return secondArg == nil and parseArgumentsOne(nil, firstArg) or parseArgumentsTwo(nil, firstArg, secondArg)
|
|
10
11
|
end
|
|
11
12
|
function parseArgumentsOne(self, firstArg)
|
|
12
|
-
local
|
|
13
|
+
local arg = firstArg
|
|
14
|
+
local ____parseDefaultValueOrDefaultValueFactory_result_1 = parseDefaultValueOrDefaultValueFactory(nil, arg)
|
|
13
15
|
local defaultValue = ____parseDefaultValueOrDefaultValueFactory_result_1.defaultValue
|
|
14
16
|
local defaultValueFactory = ____parseDefaultValueOrDefaultValueFactory_result_1.defaultValueFactory
|
|
15
17
|
return {iterable = nil, defaultValue = defaultValue, defaultValueFactory = defaultValueFactory}
|
|
@@ -17,7 +19,7 @@ end
|
|
|
17
19
|
function parseArgumentsTwo(self, firstArg, secondArg)
|
|
18
20
|
local firstArgType = type(firstArg)
|
|
19
21
|
if firstArgType ~= "table" then
|
|
20
|
-
error("A DefaultMap constructor with two arguments must have the first argument be
|
|
22
|
+
error("A DefaultMap constructor with two arguments must have the first argument be the initializer list.")
|
|
21
23
|
end
|
|
22
24
|
local ____parseDefaultValueOrDefaultValueFactory_result_2 = parseDefaultValueOrDefaultValueFactory(nil, secondArg)
|
|
23
25
|
local defaultValue = ____parseDefaultValueOrDefaultValueFactory_result_2.defaultValue
|
|
@@ -25,14 +27,13 @@ function parseArgumentsTwo(self, firstArg, secondArg)
|
|
|
25
27
|
return {iterable = firstArg, defaultValue = defaultValue, defaultValueFactory = defaultValueFactory}
|
|
26
28
|
end
|
|
27
29
|
function parseDefaultValueOrDefaultValueFactory(self, arg)
|
|
28
|
-
|
|
29
|
-
if argType == "function" then
|
|
30
|
+
if type(arg) == "function" then
|
|
30
31
|
return {defaultValue = nil, defaultValueFactory = arg}
|
|
31
32
|
end
|
|
32
|
-
if
|
|
33
|
+
if type(arg) == "boolean" or type(arg) == "number" or type(arg) == "string" then
|
|
33
34
|
return {defaultValue = arg, defaultValueFactory = nil}
|
|
34
35
|
end
|
|
35
|
-
return error("A DefaultMap was instantiated with an unknown type of: " ..
|
|
36
|
+
return error("A DefaultMap was instantiated with an unknown type of: " .. __TS__TypeOf(arg))
|
|
36
37
|
end
|
|
37
38
|
____exports.DefaultMap = __TS__Class()
|
|
38
39
|
local DefaultMap = ____exports.DefaultMap
|
|
@@ -55,8 +56,9 @@ function DefaultMap.prototype.____constructor(self, iterableOrDefaultValueOrDefa
|
|
|
55
56
|
self.defaultValueFactory = defaultValueFactory
|
|
56
57
|
end
|
|
57
58
|
function DefaultMap.prototype.getAndSetDefault(self, key)
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
local value = self:get(key)
|
|
60
|
+
if value ~= nil then
|
|
61
|
+
return value
|
|
60
62
|
end
|
|
61
63
|
local defaultValue = self:getDefaultValue(key)
|
|
62
64
|
self:set(key, defaultValue)
|
|
@@ -71,4 +73,13 @@ function DefaultMap.prototype.getDefaultValue(self, key)
|
|
|
71
73
|
end
|
|
72
74
|
return error("A DefaultMap was incorrectly instantiated.")
|
|
73
75
|
end
|
|
76
|
+
function DefaultMap.prototype.getConstructorArg(self)
|
|
77
|
+
if self.defaultValue ~= nil then
|
|
78
|
+
return self.defaultValue
|
|
79
|
+
end
|
|
80
|
+
if self.defaultValueFactory ~= nil then
|
|
81
|
+
return self.defaultValueFactory
|
|
82
|
+
end
|
|
83
|
+
return error("A DefaultMap was incorrectly instantiated.")
|
|
84
|
+
end
|
|
74
85
|
return ____exports
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="typescript-to-lua/language-extensions" />
|
|
2
|
+
export declare enum SerializationBrand {
|
|
3
|
+
DEFAULT_MAP = "__TSTL_DEFAULT_MAP",
|
|
4
|
+
/**
|
|
5
|
+
* This is set to the value that represents the default value (instead of an empty string like the
|
|
6
|
+
* other brands are).
|
|
7
|
+
*/
|
|
8
|
+
DEFAULT_MAP_VALUE = "__TSTL_DEFAULT_MAP_VALUE",
|
|
9
|
+
MAP = "__TSTL_MAP",
|
|
10
|
+
SET = "__TSTL_SET",
|
|
11
|
+
CLASS = "__TSTL_CLASS",
|
|
12
|
+
OBJECT_WITH_NUMBER_KEYS = "__TSTL_OBJECT_WITH_NUMBER_KEYS",
|
|
13
|
+
VECTOR = "__VECTOR"
|
|
14
|
+
}
|
|
15
|
+
export declare function isSerializationBrand(key: AnyNotNil): boolean;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
|
+
local ____lualib = require("lualib_bundle")
|
|
3
|
+
local Set = ____lualib.Set
|
|
4
|
+
local __TS__New = ____lualib.__TS__New
|
|
5
|
+
local ____exports = {}
|
|
6
|
+
local ____utils = require("functions.utils")
|
|
7
|
+
local getEnumValues = ____utils.getEnumValues
|
|
8
|
+
____exports.SerializationBrand = SerializationBrand or ({})
|
|
9
|
+
____exports.SerializationBrand.DEFAULT_MAP = "__TSTL_DEFAULT_MAP"
|
|
10
|
+
____exports.SerializationBrand.DEFAULT_MAP_VALUE = "__TSTL_DEFAULT_MAP_VALUE"
|
|
11
|
+
____exports.SerializationBrand.MAP = "__TSTL_MAP"
|
|
12
|
+
____exports.SerializationBrand.SET = "__TSTL_SET"
|
|
13
|
+
____exports.SerializationBrand.CLASS = "__TSTL_CLASS"
|
|
14
|
+
____exports.SerializationBrand.OBJECT_WITH_NUMBER_KEYS = "__TSTL_OBJECT_WITH_NUMBER_KEYS"
|
|
15
|
+
____exports.SerializationBrand.VECTOR = "__VECTOR"
|
|
16
|
+
local serializationBrands = getEnumValues(nil, ____exports.SerializationBrand)
|
|
17
|
+
local SERIALIZATION_BRAND_SET = __TS__New(Set, serializationBrands)
|
|
18
|
+
function ____exports.isSerializationBrand(self, key)
|
|
19
|
+
if type(key) ~= "string" then
|
|
20
|
+
return false
|
|
21
|
+
end
|
|
22
|
+
return SERIALIZATION_BRAND_SET:has(key)
|
|
23
|
+
end
|
|
24
|
+
return ____exports
|
package/dist/upgradeMod.lua
CHANGED
|
@@ -87,9 +87,9 @@ local ____main = require("features.saveDataManager.main")
|
|
|
87
87
|
local saveDataManagerInit = ____main.saveDataManagerInit
|
|
88
88
|
local ____sirenHelpers = require("features.sirenHelpers")
|
|
89
89
|
local sirenHelpersInit = ____sirenHelpers.sirenHelpersInit
|
|
90
|
-
local
|
|
91
|
-
local areFeaturesInitialized =
|
|
92
|
-
local setFeaturesInitialized =
|
|
90
|
+
local ____featuresInitialized = require("featuresInitialized")
|
|
91
|
+
local areFeaturesInitialized = ____featuresInitialized.areFeaturesInitialized
|
|
92
|
+
local setFeaturesInitialized = ____featuresInitialized.setFeaturesInitialized
|
|
93
93
|
local ____patchErrorFunctions = require("patchErrorFunctions")
|
|
94
94
|
local patchErrorFunction = ____patchErrorFunctions.patchErrorFunction
|
|
95
95
|
local ____ModUpgraded = require("types.ModUpgraded")
|