isaacscript-common 1.2.171 → 1.2.174
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/postNewRoomEarly.lua +5 -5
- package/dist/enums/SerializationType.d.ts +5 -0
- package/dist/enums/SerializationType.lua +10 -0
- package/dist/features/playerInventory.lua +10 -7
- package/dist/features/saveDataManager/exports.lua +2 -1
- package/dist/features/saveDataManager/main.lua +2 -1
- package/dist/features/saveDataManager/merge.lua +19 -10
- package/dist/features/saveDataManager/save.lua +2 -1
- package/dist/functions/deepCopy.d.ts +1 -5
- package/dist/functions/deepCopy.lua +18 -23
- package/dist/functions/deepCopyTests.lua +3 -6
- package/dist/functions/gridEntity.d.ts +7 -0
- package/dist/functions/gridEntity.lua +2 -6
- package/dist/functions/mergeTests.d.ts +1 -0
- package/dist/functions/mergeTests.lua +120 -0
- package/dist/functions/player.d.ts +2 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.lua +13 -0
- package/dist/types/private/TSTLClassMetatable.d.ts +8 -0
- package/dist/types/private/TSTLClassMetatable.lua +3 -0
- package/package.json +1 -1
|
@@ -29,21 +29,21 @@ end
|
|
|
29
29
|
function checkRoomChanged(self)
|
|
30
30
|
local room = game:GetRoom()
|
|
31
31
|
local topLeftWallGridIndex = getTopLeftWallGridIndex(nil)
|
|
32
|
+
local rightOfTopWallGridIndex = topLeftWallGridIndex + 1
|
|
32
33
|
local topLeftWall = room:GetGridEntity(topLeftWallGridIndex)
|
|
34
|
+
local topLeftWall2 = room:GetGridEntity(rightOfTopWallGridIndex)
|
|
33
35
|
if topLeftWall == nil then
|
|
34
36
|
topLeftWall = spawnGridEntity(nil, GridEntityType.GRID_WALL, topLeftWallGridIndex)
|
|
35
37
|
if topLeftWall == nil then
|
|
36
38
|
log("Error: Failed to spawn a new wall (1) for the PostNewRoomEarly callback.")
|
|
37
39
|
return
|
|
38
40
|
end
|
|
39
|
-
log("Spawned a new wall (
|
|
41
|
+
log("Spawned a new wall (1) for the PostNewRoomEarly callback.")
|
|
40
42
|
end
|
|
41
|
-
local rightOfTopWallGridIndex = topLeftWallGridIndex + 1
|
|
42
|
-
local topLeftWall2 = room:GetGridEntity(rightOfTopWallGridIndex)
|
|
43
43
|
if topLeftWall2 == nil then
|
|
44
|
-
topLeftWall2 = spawnGridEntity(nil, GridEntityType.GRID_WALL,
|
|
44
|
+
topLeftWall2 = spawnGridEntity(nil, GridEntityType.GRID_WALL, rightOfTopWallGridIndex)
|
|
45
45
|
if topLeftWall2 == nil then
|
|
46
|
-
log("Error: Failed to spawn a new wall (
|
|
46
|
+
log("Error: Failed to spawn a new wall (2) for the PostNewRoomEarly callback.")
|
|
47
47
|
return
|
|
48
48
|
end
|
|
49
49
|
log("Spawned a new wall (2) for the PostNewRoomEarly callback.")
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
|
+
local ____exports = {}
|
|
3
|
+
____exports.SerializationType = SerializationType or ({})
|
|
4
|
+
____exports.SerializationType.NONE = 0
|
|
5
|
+
____exports.SerializationType[____exports.SerializationType.NONE] = "NONE"
|
|
6
|
+
____exports.SerializationType.SERIALIZE = 1
|
|
7
|
+
____exports.SerializationType[____exports.SerializationType.SERIALIZE] = "SERIALIZE"
|
|
8
|
+
____exports.SerializationType.DESERIALIZE = 2
|
|
9
|
+
____exports.SerializationType[____exports.SerializationType.DESERIALIZE] = "DESERIALIZE"
|
|
10
|
+
return ____exports
|
|
@@ -5,7 +5,7 @@ local Set = ____lualib.Set
|
|
|
5
5
|
local __TS__ArrayPush = ____lualib.__TS__ArrayPush
|
|
6
6
|
local __TS__Iterator = ____lualib.__TS__Iterator
|
|
7
7
|
local ____exports = {}
|
|
8
|
-
local newPlayerInventory, useItemD4,
|
|
8
|
+
local newPlayerInventory, useItemD4, postGameStarted, postItemPickup, v
|
|
9
9
|
local ____DefaultMap = require("classes.DefaultMap")
|
|
10
10
|
local DefaultMap = ____DefaultMap.DefaultMap
|
|
11
11
|
local ____ModCallbacksCustom = require("enums.ModCallbacksCustom")
|
|
@@ -17,6 +17,7 @@ local copyArray = ____array.copyArray
|
|
|
17
17
|
local ____collectibleSet = require("functions.collectibleSet")
|
|
18
18
|
local getCollectibleSet = ____collectibleSet.getCollectibleSet
|
|
19
19
|
local ____player = require("functions.player")
|
|
20
|
+
local getAllPlayers = ____player.getAllPlayers
|
|
20
21
|
local getPlayerIndex = ____player.getPlayerIndex
|
|
21
22
|
local ____utils = require("functions.utils")
|
|
22
23
|
local ____repeat = ____utils["repeat"]
|
|
@@ -42,11 +43,13 @@ function useItemD4(self, _collectibleType, _rng, player)
|
|
|
42
43
|
local inventory = newPlayerInventory(nil, player)
|
|
43
44
|
v.run.playersInventory:set(playerIndex, inventory)
|
|
44
45
|
end
|
|
45
|
-
function
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
function postGameStarted(self)
|
|
47
|
+
for ____, player in ipairs(getAllPlayers(nil)) do
|
|
48
|
+
local playerIndex = getPlayerIndex(nil, player)
|
|
49
|
+
if not v.run.playersInventory:has(playerIndex) then
|
|
50
|
+
local inventory = newPlayerInventory(nil, player)
|
|
51
|
+
v.run.playersInventory:set(playerIndex, inventory)
|
|
52
|
+
end
|
|
50
53
|
end
|
|
51
54
|
end
|
|
52
55
|
function postItemPickup(self, player, pickingUpItem)
|
|
@@ -64,7 +67,7 @@ v = {run = {playersInventory = __TS__New(
|
|
|
64
67
|
function ____exports.playerInventoryInit(self, mod)
|
|
65
68
|
saveDataManager(nil, "playerInventory", v)
|
|
66
69
|
mod:AddCallback(ModCallbacks.MC_USE_ITEM, useItemD4, CollectibleType.COLLECTIBLE_D4)
|
|
67
|
-
mod:AddCallback(ModCallbacks.
|
|
70
|
+
mod:AddCallback(ModCallbacks.MC_POST_GAME_STARTED, postGameStarted)
|
|
68
71
|
mod:AddCallbackCustom(ModCallbacksCustom.MC_POST_ITEM_PICKUP, postItemPickup)
|
|
69
72
|
end
|
|
70
73
|
function ____exports.getPlayerInventory(self, player)
|
|
@@ -3,11 +3,12 @@ local ____lualib = require("lualib_bundle")
|
|
|
3
3
|
local Map = ____lualib.Map
|
|
4
4
|
local __TS__ObjectKeys = ____lualib.__TS__ObjectKeys
|
|
5
5
|
local ____exports = {}
|
|
6
|
+
local ____SerializationType = require("enums.SerializationType")
|
|
7
|
+
local SerializationType = ____SerializationType.SerializationType
|
|
6
8
|
local ____featuresInitialized = require("featuresInitialized")
|
|
7
9
|
local errorIfFeaturesNotInitialized = ____featuresInitialized.errorIfFeaturesNotInitialized
|
|
8
10
|
local ____deepCopy = require("functions.deepCopy")
|
|
9
11
|
local deepCopy = ____deepCopy.deepCopy
|
|
10
|
-
local SerializationType = ____deepCopy.SerializationType
|
|
11
12
|
local ____constants = require("features.saveDataManager.constants")
|
|
12
13
|
local SAVE_DATA_MANAGER_FEATURE_NAME = ____constants.SAVE_DATA_MANAGER_FEATURE_NAME
|
|
13
14
|
local ____main = require("features.saveDataManager.main")
|
|
@@ -9,9 +9,10 @@ local ____ModCallbacksCustom = require("enums.ModCallbacksCustom")
|
|
|
9
9
|
local ModCallbacksCustom = ____ModCallbacksCustom.ModCallbacksCustom
|
|
10
10
|
local ____SaveDataKeys = require("enums.private.SaveDataKeys")
|
|
11
11
|
local SaveDataKeys = ____SaveDataKeys.SaveDataKeys
|
|
12
|
+
local ____SerializationType = require("enums.SerializationType")
|
|
13
|
+
local SerializationType = ____SerializationType.SerializationType
|
|
12
14
|
local ____deepCopy = require("functions.deepCopy")
|
|
13
15
|
local deepCopy = ____deepCopy.deepCopy
|
|
14
|
-
local SerializationType = ____deepCopy.SerializationType
|
|
15
16
|
local ____log = require("functions.log")
|
|
16
17
|
local log = ____log.log
|
|
17
18
|
local ____table = require("functions.table")
|
|
@@ -8,6 +8,8 @@ local mergeArray, mergeTSTLObject, mergeTable, mergeVector
|
|
|
8
8
|
local ____SerializationBrand = require("enums.private.SerializationBrand")
|
|
9
9
|
local isSerializationBrand = ____SerializationBrand.isSerializationBrand
|
|
10
10
|
local SerializationBrand = ____SerializationBrand.SerializationBrand
|
|
11
|
+
local ____SerializationType = require("enums.SerializationType")
|
|
12
|
+
local SerializationType = ____SerializationType.SerializationType
|
|
11
13
|
local ____array = require("functions.array")
|
|
12
14
|
local isArray = ____array.isArray
|
|
13
15
|
local ____deepCopy = require("functions.deepCopy")
|
|
@@ -15,7 +17,6 @@ local addTraversalDescription = ____deepCopy.addTraversalDescription
|
|
|
15
17
|
local deepCopy = ____deepCopy.deepCopy
|
|
16
18
|
local deserializeVector = ____deepCopy.deserializeVector
|
|
17
19
|
local isSerializedVector = ____deepCopy.isSerializedVector
|
|
18
|
-
local SerializationType = ____deepCopy.SerializationType
|
|
19
20
|
local ____log = require("functions.log")
|
|
20
21
|
local log = ____log.log
|
|
21
22
|
local ____table = require("functions.table")
|
|
@@ -23,6 +24,9 @@ local clearTable = ____table.clearTable
|
|
|
23
24
|
local ____constants = require("features.saveDataManager.constants")
|
|
24
25
|
local SAVE_DATA_MANAGER_DEBUG = ____constants.SAVE_DATA_MANAGER_DEBUG
|
|
25
26
|
function ____exports.merge(self, oldObject, newTable, traversalDescription)
|
|
27
|
+
if SAVE_DATA_MANAGER_DEBUG then
|
|
28
|
+
log("merge is operating on: " .. traversalDescription)
|
|
29
|
+
end
|
|
26
30
|
local oldObjectType = type(oldObject)
|
|
27
31
|
if oldObjectType ~= "table" then
|
|
28
32
|
error("The first argument given to the merge function is not a table.")
|
|
@@ -31,9 +35,6 @@ function ____exports.merge(self, oldObject, newTable, traversalDescription)
|
|
|
31
35
|
if newTableType ~= "table" then
|
|
32
36
|
error("The second argument given to the merge function is not a table.")
|
|
33
37
|
end
|
|
34
|
-
if SAVE_DATA_MANAGER_DEBUG then
|
|
35
|
-
log("merge is operating on: " .. traversalDescription)
|
|
36
|
-
end
|
|
37
38
|
if mergeArray(nil, oldObject, newTable) then
|
|
38
39
|
return
|
|
39
40
|
end
|
|
@@ -87,22 +88,30 @@ function mergeTSTLObject(self, oldObject, newTable, traversalDescription)
|
|
|
87
88
|
end
|
|
88
89
|
end
|
|
89
90
|
function mergeTable(self, oldTable, newTable, traversalDescription)
|
|
91
|
+
if SAVE_DATA_MANAGER_DEBUG then
|
|
92
|
+
log("merge is operating on a table. Iterating through the keys...")
|
|
93
|
+
end
|
|
90
94
|
for key, value in pairs(newTable) do
|
|
91
95
|
do
|
|
96
|
+
if SAVE_DATA_MANAGER_DEBUG then
|
|
97
|
+
log((("merge is operating on: " .. tostring(key)) .. " --> ") .. tostring(value))
|
|
98
|
+
end
|
|
92
99
|
if isSerializationBrand(nil, key) then
|
|
93
|
-
goto
|
|
100
|
+
goto __continue23
|
|
94
101
|
end
|
|
95
102
|
if mergeVector(nil, oldTable, key, value) then
|
|
96
|
-
goto
|
|
103
|
+
goto __continue23
|
|
97
104
|
end
|
|
98
105
|
local valueType = type(value)
|
|
99
106
|
if valueType == "table" then
|
|
100
107
|
local oldValue = oldTable[key]
|
|
101
108
|
local oldValueType = type(oldValue)
|
|
102
|
-
if oldValueType
|
|
103
|
-
|
|
104
|
-
|
|
109
|
+
if oldValueType ~= "table" then
|
|
110
|
+
oldValue = {}
|
|
111
|
+
oldTable[key] = oldValue
|
|
105
112
|
end
|
|
113
|
+
traversalDescription = addTraversalDescription(nil, key, traversalDescription)
|
|
114
|
+
____exports.merge(nil, oldValue, value, traversalDescription)
|
|
106
115
|
else
|
|
107
116
|
if SAVE_DATA_MANAGER_DEBUG then
|
|
108
117
|
log((("Merging key \"" .. tostring(key)) .. "\" with value: ") .. tostring(value))
|
|
@@ -110,7 +119,7 @@ function mergeTable(self, oldTable, newTable, traversalDescription)
|
|
|
110
119
|
oldTable[key] = value
|
|
111
120
|
end
|
|
112
121
|
end
|
|
113
|
-
::
|
|
122
|
+
::__continue23::
|
|
114
123
|
end
|
|
115
124
|
end
|
|
116
125
|
function mergeVector(self, oldTable, key, value)
|
|
@@ -4,9 +4,10 @@ local Map = ____lualib.Map
|
|
|
4
4
|
local __TS__ObjectKeys = ____lualib.__TS__ObjectKeys
|
|
5
5
|
local ____exports = {}
|
|
6
6
|
local getAllSaveDataToWriteToDisk
|
|
7
|
+
local ____SerializationType = require("enums.SerializationType")
|
|
8
|
+
local SerializationType = ____SerializationType.SerializationType
|
|
7
9
|
local ____deepCopy = require("functions.deepCopy")
|
|
8
10
|
local deepCopy = ____deepCopy.deepCopy
|
|
9
|
-
local SerializationType = ____deepCopy.SerializationType
|
|
10
11
|
local ____jsonHelpers = require("functions.jsonHelpers")
|
|
11
12
|
local jsonEncode = ____jsonHelpers.jsonEncode
|
|
12
13
|
local ____log = require("functions.log")
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
/// <reference types="typescript-to-lua/language-extensions" />
|
|
2
2
|
/// <reference types="isaac-typescript-definitions" />
|
|
3
|
-
|
|
4
|
-
NONE = 0,
|
|
5
|
-
SERIALIZE = 1,
|
|
6
|
-
DESERIALIZE = 2
|
|
7
|
-
}
|
|
3
|
+
import { SerializationType } from "../enums/SerializationType";
|
|
8
4
|
/**
|
|
9
5
|
* deepCopy is a semi-generic deep cloner. It will recursively copy all of the values so that none
|
|
10
6
|
* of the nested references remain.
|
|
@@ -12,6 +12,8 @@ local DefaultMap = ____DefaultMap.DefaultMap
|
|
|
12
12
|
local ____SerializationBrand = require("enums.private.SerializationBrand")
|
|
13
13
|
local isSerializationBrand = ____SerializationBrand.isSerializationBrand
|
|
14
14
|
local SerializationBrand = ____SerializationBrand.SerializationBrand
|
|
15
|
+
local ____SerializationType = require("enums.SerializationType")
|
|
16
|
+
local SerializationType = ____SerializationType.SerializationType
|
|
15
17
|
local ____constants = require("features.saveDataManager.constants")
|
|
16
18
|
local SAVE_DATA_MANAGER_DEBUG = ____constants.SAVE_DATA_MANAGER_DEBUG
|
|
17
19
|
local ____log = require("functions.log")
|
|
@@ -20,24 +22,24 @@ local ____vector = require("functions.vector")
|
|
|
20
22
|
local isVector = ____vector.isVector
|
|
21
23
|
function ____exports.deepCopy(self, oldObject, serializationType, traversalDescription)
|
|
22
24
|
if serializationType == nil then
|
|
23
|
-
serializationType =
|
|
25
|
+
serializationType = SerializationType.NONE
|
|
24
26
|
end
|
|
25
27
|
if traversalDescription == nil then
|
|
26
28
|
traversalDescription = ""
|
|
27
29
|
end
|
|
28
|
-
local oldObjectType = type(oldObject)
|
|
29
|
-
if oldObjectType ~= "table" then
|
|
30
|
-
error(("The deepCopy function was given a " .. oldObjectType) .. " instead of a table.")
|
|
31
|
-
end
|
|
32
30
|
if SAVE_DATA_MANAGER_DEBUG then
|
|
33
31
|
local logString = "deepCopy is operating on: " .. traversalDescription
|
|
34
|
-
if serializationType ==
|
|
32
|
+
if serializationType == SerializationType.SERIALIZE then
|
|
35
33
|
logString = logString .. " (serializing)"
|
|
36
|
-
elseif serializationType ==
|
|
34
|
+
elseif serializationType == SerializationType.DESERIALIZE then
|
|
37
35
|
logString = logString .. " (deserializing)"
|
|
38
36
|
end
|
|
39
37
|
log(logString)
|
|
40
38
|
end
|
|
39
|
+
local oldObjectType = type(oldObject)
|
|
40
|
+
if oldObjectType ~= "table" then
|
|
41
|
+
error(("The deepCopy function was given a " .. oldObjectType) .. " instead of a table.")
|
|
42
|
+
end
|
|
41
43
|
local oldTable = oldObject
|
|
42
44
|
local isClass = isTSTLClass(nil, oldTable)
|
|
43
45
|
local hasTSTLDefaultMapBrand = false
|
|
@@ -52,27 +54,27 @@ function ____exports.deepCopy(self, oldObject, serializationType, traversalDescr
|
|
|
52
54
|
hasTSTLClassBrand = oldTable[SerializationBrand.CLASS] ~= nil
|
|
53
55
|
end
|
|
54
56
|
local newObject
|
|
55
|
-
if serializationType ==
|
|
57
|
+
if serializationType == SerializationType.NONE and __TS__InstanceOf(oldObject, DefaultMap) then
|
|
56
58
|
local oldDefaultMap = oldObject
|
|
57
59
|
local constructorArg = oldDefaultMap:getConstructorArg()
|
|
58
60
|
newObject = __TS__New(DefaultMap, constructorArg)
|
|
59
|
-
elseif serializationType ==
|
|
61
|
+
elseif serializationType == SerializationType.DESERIALIZE and hasTSTLDefaultMapBrand then
|
|
60
62
|
local defaultValue = oldTable[SerializationBrand.DEFAULT_MAP_VALUE]
|
|
61
63
|
if type(defaultValue) ~= "boolean" and type(defaultValue) ~= "number" and type(defaultValue) ~= "string" then
|
|
62
64
|
error("The deepCopy function failed to get a valid default value for a DefaultMap object when deserializing.")
|
|
63
65
|
else
|
|
64
66
|
newObject = __TS__New(DefaultMap, defaultValue)
|
|
65
67
|
end
|
|
66
|
-
elseif serializationType ==
|
|
68
|
+
elseif serializationType == SerializationType.NONE and __TS__InstanceOf(oldObject, Map) or serializationType == SerializationType.DESERIALIZE and hasTSTLMapBrand then
|
|
67
69
|
newObject = __TS__New(Map)
|
|
68
|
-
elseif serializationType ==
|
|
70
|
+
elseif serializationType == SerializationType.NONE and __TS__InstanceOf(oldObject, Set) or serializationType == SerializationType.DESERIALIZE and hasTSTLSetBrand then
|
|
69
71
|
newObject = __TS__New(Set)
|
|
70
|
-
elseif serializationType ==
|
|
72
|
+
elseif serializationType == SerializationType.NONE and isClass or serializationType == SerializationType.DESERIALIZE and hasTSTLClassBrand then
|
|
71
73
|
newObject = copyClass(nil, oldObject)
|
|
72
74
|
else
|
|
73
75
|
newObject = {}
|
|
74
76
|
end
|
|
75
|
-
if serializationType ==
|
|
77
|
+
if serializationType == SerializationType.SERIALIZE then
|
|
76
78
|
local newTable = newObject
|
|
77
79
|
if __TS__InstanceOf(oldObject, DefaultMap) then
|
|
78
80
|
newTable[SerializationBrand.DEFAULT_MAP] = ""
|
|
@@ -189,7 +191,7 @@ function deepCopyValue(self, oldObject, newObject, key, value, traversalDescript
|
|
|
189
191
|
local convertNumberKeysToString = false
|
|
190
192
|
local isTSTLObject = __TS__InstanceOf(oldObject, Map) or __TS__InstanceOf(oldObject, Set)
|
|
191
193
|
local keyType = type(key)
|
|
192
|
-
if serializationType ==
|
|
194
|
+
if serializationType == SerializationType.SERIALIZE and isTSTLObject and keyType == "number" then
|
|
193
195
|
convertNumberKeysToString = true
|
|
194
196
|
local newTable = newObject
|
|
195
197
|
newTable[SerializationBrand.OBJECT_WITH_NUMBER_KEYS] = ""
|
|
@@ -201,7 +203,7 @@ function deepCopyValue(self, oldObject, newObject, key, value, traversalDescript
|
|
|
201
203
|
if isVector(nil, value) then
|
|
202
204
|
local vector = value
|
|
203
205
|
newValue = copyVector(nil, vector, serializationType)
|
|
204
|
-
elseif ____exports.isSerializedVector(nil, value) and serializationType ==
|
|
206
|
+
elseif ____exports.isSerializedVector(nil, value) and serializationType == SerializationType.DESERIALIZE then
|
|
205
207
|
local serializedVector = value
|
|
206
208
|
newValue = ____exports.deserializeVector(nil, serializedVector)
|
|
207
209
|
elseif valueType == "table" then
|
|
@@ -221,7 +223,7 @@ function deepCopyValue(self, oldObject, newObject, key, value, traversalDescript
|
|
|
221
223
|
end
|
|
222
224
|
end
|
|
223
225
|
function copyVector(self, vector, serializationType)
|
|
224
|
-
if serializationType ==
|
|
226
|
+
if serializationType == SerializationType.SERIALIZE then
|
|
225
227
|
local vectorTable = {}
|
|
226
228
|
vectorTable.X = vector.X
|
|
227
229
|
vectorTable.Y = vector.Y
|
|
@@ -275,12 +277,5 @@ function ____exports.isSerializedVector(self, object)
|
|
|
275
277
|
local ____table = object
|
|
276
278
|
return ____table[SerializationBrand.VECTOR] ~= nil and ____table.X ~= nil and ____table.Y ~= nil
|
|
277
279
|
end
|
|
278
|
-
____exports.SerializationType = SerializationType or ({})
|
|
279
|
-
____exports.SerializationType.NONE = 0
|
|
280
|
-
____exports.SerializationType[____exports.SerializationType.NONE] = "NONE"
|
|
281
|
-
____exports.SerializationType.SERIALIZE = 1
|
|
282
|
-
____exports.SerializationType[____exports.SerializationType.SERIALIZE] = "SERIALIZE"
|
|
283
|
-
____exports.SerializationType.DESERIALIZE = 2
|
|
284
|
-
____exports.SerializationType[____exports.SerializationType.DESERIALIZE] = "DESERIALIZE"
|
|
285
280
|
TSTL_CLASS_KEYS = __TS__New(Set, {"____constructor", "__index", "constructor"})
|
|
286
281
|
return ____exports
|
|
@@ -10,11 +10,12 @@ local ____DefaultMap = require("classes.DefaultMap")
|
|
|
10
10
|
local DefaultMap = ____DefaultMap.DefaultMap
|
|
11
11
|
local ____SerializationBrand = require("enums.private.SerializationBrand")
|
|
12
12
|
local SerializationBrand = ____SerializationBrand.SerializationBrand
|
|
13
|
+
local ____SerializationType = require("enums.SerializationType")
|
|
14
|
+
local SerializationType = ____SerializationType.SerializationType
|
|
13
15
|
local ____array = require("functions.array")
|
|
14
16
|
local arrayEquals = ____array.arrayEquals
|
|
15
17
|
local ____deepCopy = require("functions.deepCopy")
|
|
16
18
|
local deepCopy = ____deepCopy.deepCopy
|
|
17
|
-
local SerializationType = ____deepCopy.SerializationType
|
|
18
19
|
local ____log = require("functions.log")
|
|
19
20
|
local log = ____log.log
|
|
20
21
|
function copiedObjectIsTable(self)
|
|
@@ -294,10 +295,6 @@ function copiedDefaultMapHasBrand(self)
|
|
|
294
295
|
if not (newTable[SerializationBrand.DEFAULT_MAP] ~= nil) then
|
|
295
296
|
error("The copied DefaultMap does not have the brand: " .. SerializationBrand.DEFAULT_MAP)
|
|
296
297
|
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
298
|
end
|
|
302
299
|
function ____exports.deepCopyTests(self)
|
|
303
300
|
copiedObjectIsTable(nil)
|
|
@@ -315,6 +312,6 @@ function ____exports.deepCopyTests(self)
|
|
|
315
312
|
copiedMapHasChildMap(nil)
|
|
316
313
|
copiedDefaultMapHasChildDefaultMap(nil)
|
|
317
314
|
copiedDefaultMapHasBrand(nil)
|
|
318
|
-
log("All tests passed!")
|
|
315
|
+
log("All deep copy tests passed!")
|
|
319
316
|
end
|
|
320
317
|
return ____exports
|
|
@@ -5,6 +5,13 @@
|
|
|
5
5
|
* 1000.0 in a room XML file, but `GridEntityType.GRID_ROCK` is equal to 2.
|
|
6
6
|
*/
|
|
7
7
|
export declare function convertXMLGridEntityType(gridEntityXMLType: int, gridEntityXMLVariant: int): [int, int] | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Gets the entities that have a hitbox that overlaps with any part of the square that the grid
|
|
10
|
+
* entity is on.
|
|
11
|
+
*
|
|
12
|
+
* Note that this function will not work properly in the PostNewRoom callback, since entities do not
|
|
13
|
+
* have collision yet in that callback.
|
|
14
|
+
*/
|
|
8
15
|
export declare function getCollidingEntitiesWithGridEntity(gridEntity: GridEntity): Entity[];
|
|
9
16
|
/**
|
|
10
17
|
* Helper function to get every grid entity in the current room.
|
|
@@ -112,13 +112,9 @@ function ____exports.getCollidingEntitiesWithGridEntity(self, gridEntity)
|
|
|
112
112
|
local gridEntityCollisionTopLeft = Vector(gridEntity.Position.X - DISTANCE_OF_GRID_TILE / 2, gridEntity.Position.Y - DISTANCE_OF_GRID_TILE / 2)
|
|
113
113
|
local gridEntityCollisionBottomRight = Vector(gridEntity.Position.X + DISTANCE_OF_GRID_TILE / 2, gridEntity.Position.Y + DISTANCE_OF_GRID_TILE / 2)
|
|
114
114
|
local closeEntities = Isaac.FindInRadius(gridEntity.Position, DISTANCE_OF_GRID_TILE * 2)
|
|
115
|
-
local closeEntitiesThatCollideWithGrid = __TS__ArrayFilter(
|
|
116
|
-
closeEntities,
|
|
117
|
-
function(____, entity) return entity:CollidesWithGrid() end
|
|
118
|
-
)
|
|
119
115
|
return __TS__ArrayFilter(
|
|
120
|
-
|
|
121
|
-
function(____, entity) return isCircleIntersectingRectangle(
|
|
116
|
+
closeEntities,
|
|
117
|
+
function(____, entity) return entity:CollidesWithGrid() and isCircleIntersectingRectangle(
|
|
122
118
|
nil,
|
|
123
119
|
entity.Position,
|
|
124
120
|
entity.Size + 0.1,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function mergeTests(): void;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
|
+
local ____exports = {}
|
|
3
|
+
local oldTableHasUpdatedValue, newTableHasSameValue, oldTableHasUpdatedValueFromNull, oldTableHasFilledInterface, oldTableHasVector, oldTableHasVectorSerialized
|
|
4
|
+
local ____SerializationType = require("enums.SerializationType")
|
|
5
|
+
local SerializationType = ____SerializationType.SerializationType
|
|
6
|
+
local ____merge = require("features.saveDataManager.merge")
|
|
7
|
+
local merge = ____merge.merge
|
|
8
|
+
local ____deepCopy = require("functions.deepCopy")
|
|
9
|
+
local deepCopy = ____deepCopy.deepCopy
|
|
10
|
+
local ____log = require("functions.log")
|
|
11
|
+
local log = ____log.log
|
|
12
|
+
local ____vector = require("functions.vector")
|
|
13
|
+
local isVector = ____vector.isVector
|
|
14
|
+
function oldTableHasUpdatedValue(self)
|
|
15
|
+
local key = "foo"
|
|
16
|
+
local oldValue = "bar"
|
|
17
|
+
local newValue = "baz"
|
|
18
|
+
local oldTable = {foo = oldValue}
|
|
19
|
+
local newTable = {foo = newValue}
|
|
20
|
+
merge(nil, oldTable, newTable, "oldTableHasUpdatedValue")
|
|
21
|
+
local oldTableValue = oldTable[key]
|
|
22
|
+
if oldTableValue ~= newValue then
|
|
23
|
+
error("The old table does not have a value of: " .. newValue)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
function newTableHasSameValue(self)
|
|
27
|
+
local key = "foo"
|
|
28
|
+
local oldValue = "bar"
|
|
29
|
+
local newValue = "baz"
|
|
30
|
+
local oldTable = {foo = oldValue}
|
|
31
|
+
local newTable = {foo = newValue}
|
|
32
|
+
merge(nil, oldTable, newTable, "newTableHasSameValue")
|
|
33
|
+
local newTableValue = newTable[key]
|
|
34
|
+
if newTableValue ~= newValue then
|
|
35
|
+
error("The new table does not have a value of: " .. newValue)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
function oldTableHasUpdatedValueFromNull(self)
|
|
39
|
+
local key = "foo"
|
|
40
|
+
local newValue = "baz"
|
|
41
|
+
local oldTable = {foo = nil}
|
|
42
|
+
local newTable = {foo = newValue}
|
|
43
|
+
merge(nil, oldTable, newTable, "oldTableHasUpdatedValueFromNull")
|
|
44
|
+
local oldTableValue = oldTable[key]
|
|
45
|
+
if oldTableValue ~= newValue then
|
|
46
|
+
error("The old table does not have a value of: " .. newValue)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
function oldTableHasFilledInterface(self)
|
|
50
|
+
local key = "foo"
|
|
51
|
+
local newValue = "baz"
|
|
52
|
+
local oldTable = {foo = nil}
|
|
53
|
+
local foo = {bar = newValue}
|
|
54
|
+
local newTable = {foo = foo}
|
|
55
|
+
merge(nil, oldTable, newTable, "oldTableHasFilledInterface")
|
|
56
|
+
local oldTableValue = oldTable[key]
|
|
57
|
+
if oldTableValue == nil then
|
|
58
|
+
error(("The old table's key of \"" .. key) .. "\" was not filled.")
|
|
59
|
+
end
|
|
60
|
+
if oldTableValue.bar ~= newValue then
|
|
61
|
+
error("The old table's key of \"bar\" was not filled.")
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
function oldTableHasVector(self)
|
|
65
|
+
local key = "foo"
|
|
66
|
+
local x = 50
|
|
67
|
+
local y = 60
|
|
68
|
+
local newValue = Vector(x, y)
|
|
69
|
+
local oldTable = {foo = nil}
|
|
70
|
+
local foo = {bar = newValue}
|
|
71
|
+
local newTable = {foo = foo}
|
|
72
|
+
merge(nil, oldTable, newTable, "oldTableHasVector")
|
|
73
|
+
local oldTableValue = oldTable[key]
|
|
74
|
+
if oldTableValue == nil then
|
|
75
|
+
error(("The old table's key of \"" .. key) .. "\" was not filled.")
|
|
76
|
+
end
|
|
77
|
+
if oldTableValue.bar.X ~= x then
|
|
78
|
+
error("The old table's value for \"x\" does not match: " .. tostring(x))
|
|
79
|
+
end
|
|
80
|
+
if oldTableValue.bar.Y ~= y then
|
|
81
|
+
error("The old table's value for \"y\" does not match: " .. tostring(y))
|
|
82
|
+
end
|
|
83
|
+
if not isVector(nil, oldTableValue.bar) then
|
|
84
|
+
error("The old table's value is not a Vector object.")
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
function oldTableHasVectorSerialized(self)
|
|
88
|
+
local key = "foo"
|
|
89
|
+
local x = 50
|
|
90
|
+
local y = 60
|
|
91
|
+
local newValue = Vector(x, y)
|
|
92
|
+
local oldTable = {foo = nil}
|
|
93
|
+
local foo = {bar = newValue}
|
|
94
|
+
local newTable = {foo = foo}
|
|
95
|
+
local newTableSerialized = deepCopy(nil, newTable, SerializationType.SERIALIZE)
|
|
96
|
+
merge(nil, oldTable, newTableSerialized, "oldTableHasVectorSerialized")
|
|
97
|
+
local oldTableValue = oldTable[key]
|
|
98
|
+
if oldTableValue == nil then
|
|
99
|
+
error(("The old table's key of \"" .. key) .. "\" was not filled.")
|
|
100
|
+
end
|
|
101
|
+
if oldTableValue.bar.X ~= x then
|
|
102
|
+
error("The old table's value for \"x\" does not match: " .. tostring(x))
|
|
103
|
+
end
|
|
104
|
+
if oldTableValue.bar.Y ~= y then
|
|
105
|
+
error("The old table's value for \"y\" does not match: " .. tostring(y))
|
|
106
|
+
end
|
|
107
|
+
if not isVector(nil, oldTableValue.bar) then
|
|
108
|
+
error("The old table's value is not a Vector object.")
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
function ____exports.mergeTests(self)
|
|
112
|
+
oldTableHasUpdatedValue(nil)
|
|
113
|
+
newTableHasSameValue(nil)
|
|
114
|
+
oldTableHasUpdatedValueFromNull(nil)
|
|
115
|
+
oldTableHasFilledInterface(nil)
|
|
116
|
+
oldTableHasVector(nil)
|
|
117
|
+
oldTableHasVectorSerialized(nil)
|
|
118
|
+
log("All merge tests passed!")
|
|
119
|
+
end
|
|
120
|
+
return ____exports
|
|
@@ -47,8 +47,8 @@ export declare function characterGetsBlackHeartFromEternalHeart(character: Playe
|
|
|
47
47
|
* Helper function to get every player with no restrictions, by using `Game.GetNumPlayers` and
|
|
48
48
|
* `Isaac.GetPlayer`.
|
|
49
49
|
*
|
|
50
|
-
* This function is almost never what you want to use. For most
|
|
51
|
-
*
|
|
50
|
+
* This function is almost never what you want to use. For most purposes, use the `getPlayers`
|
|
51
|
+
* helper function instead to get a filtered list of players.
|
|
52
52
|
*/
|
|
53
53
|
export declare function getAllPlayers(): EntityPlayer[];
|
|
54
54
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export * from "./enums/ModCallbacksCustom";
|
|
|
12
12
|
export * from "./enums/PillEffectClass";
|
|
13
13
|
export * from "./enums/PillEffectType";
|
|
14
14
|
export * from "./enums/PocketItemType";
|
|
15
|
+
export * from "./enums/SerializationType";
|
|
15
16
|
export { deployJSONRoom, deployRandomJSONRoom, emptyRoom, } from "./features/deployJSONRoom";
|
|
16
17
|
export { disableAllInputs, disableAllInputsExceptFor, disableMovementInputs, disableShootingInputs, enableAllInputs, enableAllInputsExceptFor, } from "./features/disableInputs";
|
|
17
18
|
export { disableAllSound, enableAllSound } from "./features/disableSound";
|
|
@@ -52,6 +53,7 @@ export * from "./functions/language";
|
|
|
52
53
|
export * from "./functions/log";
|
|
53
54
|
export * from "./functions/map";
|
|
54
55
|
export * from "./functions/math";
|
|
56
|
+
export { mergeTests } from "./functions/mergeTests";
|
|
55
57
|
export * from "./functions/npc";
|
|
56
58
|
export * from "./functions/pickups";
|
|
57
59
|
export * from "./functions/pills";
|
package/dist/index.lua
CHANGED
|
@@ -110,6 +110,14 @@ do
|
|
|
110
110
|
end
|
|
111
111
|
end
|
|
112
112
|
end
|
|
113
|
+
do
|
|
114
|
+
local ____export = require("enums.SerializationType")
|
|
115
|
+
for ____exportKey, ____exportValue in pairs(____export) do
|
|
116
|
+
if ____exportKey ~= "default" then
|
|
117
|
+
____exports[____exportKey] = ____exportValue
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
113
121
|
do
|
|
114
122
|
local ____deployJSONRoom = require("features.deployJSONRoom")
|
|
115
123
|
local deployJSONRoom = ____deployJSONRoom.deployJSONRoom
|
|
@@ -421,6 +429,11 @@ do
|
|
|
421
429
|
end
|
|
422
430
|
end
|
|
423
431
|
end
|
|
432
|
+
do
|
|
433
|
+
local ____mergeTests = require("functions.mergeTests")
|
|
434
|
+
local mergeTests = ____mergeTests.mergeTests
|
|
435
|
+
____exports.mergeTests = mergeTests
|
|
436
|
+
end
|
|
424
437
|
do
|
|
425
438
|
local ____export = require("functions.npc")
|
|
426
439
|
for ____exportKey, ____exportValue in pairs(____export) do
|