isaacscript-common 1.2.248 → 1.2.251
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/enums/private/CopyableIsaacAPIClassType.d.ts +7 -0
- package/dist/enums/private/CopyableIsaacAPIClassType.lua +8 -0
- package/dist/enums/private/SerializationBrand.d.ts +19 -9
- package/dist/enums/private/SerializationBrand.lua +2 -2
- package/dist/features/saveDataManager/exports.lua +1 -2
- package/dist/features/saveDataManager/main.lua +2 -3
- package/dist/functions/array.d.ts +1 -1
- package/dist/functions/array.lua +6 -6
- package/dist/functions/deepCopy.d.ts +9 -6
- package/dist/functions/deepCopy.lua +285 -147
- package/dist/functions/easing.d.ts +30 -0
- package/dist/functions/easing.lua +116 -0
- package/dist/functions/log.d.ts +1 -1
- package/dist/functions/serialization.d.ts +5 -6
- package/dist/functions/serialization.lua +11 -28
- package/dist/functions/table.d.ts +1 -1
- package/dist/functions/tstlClass.d.ts +10 -5
- package/dist/functions/tstlClass.lua +11 -3
- package/dist/functions/utils.d.ts +1 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.lua +8 -0
- package/dist/objects/isaacAPIClassTypeToBrand.d.ts +2 -2
- package/dist/objects/isaacAPIClassTypeToBrand.lua +3 -3
- package/dist/objects/isaacAPIClassTypeToCopyFunction.d.ts +2 -2
- package/dist/objects/isaacAPIClassTypeToCopyFunction.lua +3 -3
- package/dist/objects/serializedIsaacAPIClassTypeToIdentityFunction.d.ts +2 -2
- package/dist/objects/serializedIsaacAPIClassTypeToIdentityFunction.lua +3 -3
- package/dist/types/private/SaveData.d.ts +4 -0
- package/dist/types/private/TSTLClass.d.ts +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
|
+
local ____exports = {}
|
|
3
|
+
____exports.CopyableIsaacAPIClassType = CopyableIsaacAPIClassType or ({})
|
|
4
|
+
____exports.CopyableIsaacAPIClassType.COLOR = "Color"
|
|
5
|
+
____exports.CopyableIsaacAPIClassType.KCOLOR = "KColor"
|
|
6
|
+
____exports.CopyableIsaacAPIClassType.RNG = "RNG"
|
|
7
|
+
____exports.CopyableIsaacAPIClassType.VECTOR = "Vector"
|
|
8
|
+
return ____exports
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="typescript-to-lua/language-extensions" />
|
|
2
1
|
/**
|
|
3
2
|
* During serialization, we write an arbitrary string key to the object with a value of an empty
|
|
4
3
|
* string. This is used during deserialization to instantiate the correct type of object.
|
|
@@ -8,6 +7,12 @@
|
|
|
8
7
|
*/
|
|
9
8
|
export declare enum SerializationBrand {
|
|
10
9
|
DEFAULT_MAP = "__TSTL_DEFAULT_MAP",
|
|
10
|
+
MAP = "__TSTL_MAP",
|
|
11
|
+
SET = "__TSTL_SET",
|
|
12
|
+
COLOR = "__COLOR",
|
|
13
|
+
KCOLOR = "__KCOLOR",
|
|
14
|
+
RNG = "__RNG",
|
|
15
|
+
VECTOR = "__VECTOR",
|
|
11
16
|
/**
|
|
12
17
|
* This is set to the value that represents the default value (instead of an empty string like the
|
|
13
18
|
* other brands are).
|
|
@@ -17,12 +22,17 @@ export declare enum SerializationBrand {
|
|
|
17
22
|
* object.
|
|
18
23
|
*/
|
|
19
24
|
DEFAULT_MAP_VALUE = "__TSTL_DEFAULT_MAP_VALUE",
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
/**
|
|
26
|
+
* The JSON library is unable to distinguish between a maps with number keys and an array. It will
|
|
27
|
+
* assume that both of these are an array. Thus, in the case of a map with number keys, it will
|
|
28
|
+
* insert null in every empty spot, leading to crashes.
|
|
29
|
+
*
|
|
30
|
+
* For example, a map with keys of 5 and 10 would be converted to the following array:
|
|
31
|
+
* `[null, null, null, null, "myValueForKey5", null, null, null, null, "myValueForKey10"]`
|
|
32
|
+
*
|
|
33
|
+
* The deep copier works around this by converting number keys to strings. It inserts this brand
|
|
34
|
+
* to keep track of the mutation.
|
|
35
|
+
*/
|
|
36
|
+
OBJECT_WITH_NUMBER_KEYS = "__TSTL_OBJECT_WITH_NUMBER_KEYS"
|
|
27
37
|
}
|
|
28
|
-
export declare function isSerializationBrand(key:
|
|
38
|
+
export declare function isSerializationBrand(key: unknown): boolean;
|
|
@@ -6,14 +6,14 @@ local ____utils = require("functions.utils")
|
|
|
6
6
|
local getEnumValues = ____utils.getEnumValues
|
|
7
7
|
____exports.SerializationBrand = SerializationBrand or ({})
|
|
8
8
|
____exports.SerializationBrand.DEFAULT_MAP = "__TSTL_DEFAULT_MAP"
|
|
9
|
-
____exports.SerializationBrand.DEFAULT_MAP_VALUE = "__TSTL_DEFAULT_MAP_VALUE"
|
|
10
9
|
____exports.SerializationBrand.MAP = "__TSTL_MAP"
|
|
11
10
|
____exports.SerializationBrand.SET = "__TSTL_SET"
|
|
12
|
-
____exports.SerializationBrand.OBJECT_WITH_NUMBER_KEYS = "__TSTL_OBJECT_WITH_NUMBER_KEYS"
|
|
13
11
|
____exports.SerializationBrand.COLOR = "__COLOR"
|
|
14
12
|
____exports.SerializationBrand.KCOLOR = "__KCOLOR"
|
|
15
13
|
____exports.SerializationBrand.RNG = "__RNG"
|
|
16
14
|
____exports.SerializationBrand.VECTOR = "__VECTOR"
|
|
15
|
+
____exports.SerializationBrand.DEFAULT_MAP_VALUE = "__TSTL_DEFAULT_MAP_VALUE"
|
|
16
|
+
____exports.SerializationBrand.OBJECT_WITH_NUMBER_KEYS = "__TSTL_OBJECT_WITH_NUMBER_KEYS"
|
|
17
17
|
local SERIALIZATION_BRANDS = getEnumValues(nil, ____exports.SerializationBrand)
|
|
18
18
|
local SERIALIZATION_BRAND_SET = __TS__New(Set, SERIALIZATION_BRANDS)
|
|
19
19
|
function ____exports.isSerializationBrand(self, key)
|
|
@@ -32,8 +32,7 @@ function ____exports.saveDataManager(self, key, v, conditionalFunc)
|
|
|
32
32
|
conditionalFunc = function() return false end
|
|
33
33
|
end
|
|
34
34
|
local saveDataTable = v
|
|
35
|
-
local
|
|
36
|
-
local saveDataCopy = saveDataTableCopy
|
|
35
|
+
local saveDataCopy = deepCopy(nil, saveDataTable, SerializationType.NONE, key)
|
|
37
36
|
saveDataDefaultsMap[key] = saveDataCopy
|
|
38
37
|
if conditionalFunc ~= nil then
|
|
39
38
|
saveDataConditionalFuncMap:set(key, conditionalFunc)
|
|
@@ -80,9 +80,8 @@ function restoreDefaults(self, childTableName)
|
|
|
80
80
|
logError(((("Failed to find the default copy of the child table \"" .. childTableName) .. "\" for subscriber \"") .. subscriberName) .. "\". This error usually means that your save data is out of date. You can try purging all of your save data by deleting the following directory: C:\\Program Files (x86)\\Steam\\steamapps\\common\\The Binding of Isaac Rebirth\\data")
|
|
81
81
|
goto __continue14
|
|
82
82
|
end
|
|
83
|
-
local
|
|
84
|
-
|
|
85
|
-
clearAndCopyAllElements(nil, childTable, childTableDefaultsTableCopy)
|
|
83
|
+
local childTableDefaultsCopy = deepCopy(nil, childTableDefaults, SerializationType.NONE, (subscriberName .. " --> ") .. childTableName)
|
|
84
|
+
clearAndCopyAllElements(nil, childTable, childTableDefaultsCopy)
|
|
86
85
|
end
|
|
87
86
|
::__continue14::
|
|
88
87
|
end
|
|
@@ -82,7 +82,7 @@ export declare function initArray<T>(defaultValue: T, size: int): T[];
|
|
|
82
82
|
* - the table contains all numerical indexes that are contiguous, starting at 1
|
|
83
83
|
* - the table has no keys (i.e. an "empty" table)
|
|
84
84
|
*/
|
|
85
|
-
export declare function isArray(
|
|
85
|
+
export declare function isArray(object: unknown): object is unknown[];
|
|
86
86
|
/** Checks if an array is in the provided 2-dimensional array. */
|
|
87
87
|
export declare function isArrayInArray<T>(arrayToMatch: T[] | readonly T[], parentArray: Array<T[] | readonly T[]>): boolean;
|
|
88
88
|
/**
|
package/dist/functions/array.lua
CHANGED
|
@@ -155,17 +155,17 @@ function ____exports.initArray(self, defaultValue, size)
|
|
|
155
155
|
)
|
|
156
156
|
return array
|
|
157
157
|
end
|
|
158
|
-
function ____exports.isArray(self,
|
|
159
|
-
if type(
|
|
158
|
+
function ____exports.isArray(self, object)
|
|
159
|
+
if type(object) ~= "table" then
|
|
160
160
|
return false
|
|
161
161
|
end
|
|
162
|
-
local
|
|
163
|
-
local metatable = getmetatable(
|
|
162
|
+
local ____table = object
|
|
163
|
+
local metatable = getmetatable(____table)
|
|
164
164
|
if metatable ~= nil then
|
|
165
165
|
return false
|
|
166
166
|
end
|
|
167
167
|
local numEntries = 0
|
|
168
|
-
for key in pairs(
|
|
168
|
+
for key in pairs(____table) do
|
|
169
169
|
numEntries = numEntries + 1
|
|
170
170
|
if type(key) ~= "number" then
|
|
171
171
|
return false
|
|
@@ -177,7 +177,7 @@ function ____exports.isArray(self, thing)
|
|
|
177
177
|
do
|
|
178
178
|
local i = 1
|
|
179
179
|
while i <= numEntries do
|
|
180
|
-
local element =
|
|
180
|
+
local element = ____table[i]
|
|
181
181
|
if element == nil then
|
|
182
182
|
return false
|
|
183
183
|
end
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="typescript-to-lua/language-extensions" />
|
|
2
1
|
import { SerializationType } from "../enums/SerializationType";
|
|
3
2
|
/**
|
|
4
3
|
* deepCopy is a semi-generic deep cloner. It will recursively copy all of the values so that none
|
|
@@ -6,6 +5,7 @@ import { SerializationType } from "../enums/SerializationType";
|
|
|
6
5
|
*
|
|
7
6
|
* It supports the following object types:
|
|
8
7
|
*
|
|
8
|
+
* - Primitives (i.e. strings, numbers, and booleans)
|
|
9
9
|
* - `LuaTable` / basic TSTL objects
|
|
10
10
|
* - TSTL `Map`
|
|
11
11
|
* - TSTL `Set`
|
|
@@ -16,10 +16,13 @@ import { SerializationType } from "../enums/SerializationType";
|
|
|
16
16
|
* - Isaac `RNG` objects
|
|
17
17
|
* - Isaac `Vector` objects
|
|
18
18
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
19
|
+
* It does not support:
|
|
20
|
+
* - objects with values of `null` (since that transpiles to `nil`)
|
|
21
|
+
* - other Isaac API objects such as `EntityPtr` (that have a type of "userdata")
|
|
22
|
+
*
|
|
23
|
+
* @param value The primitive or object to copy.
|
|
24
|
+
* @param serializationType Has 3 possible values. Can leave objects as-is, or can serialize objects
|
|
25
|
+
* to Lua tables, or can deserialize Lua tables to objects. Default is `SerializationType.NONE`.
|
|
23
26
|
* @param traversalDescription Used to track the current key that we are operating on.
|
|
24
27
|
*/
|
|
25
|
-
export declare function deepCopy(
|
|
28
|
+
export declare function deepCopy(value: unknown, serializationType?: SerializationType, traversalDescription?: string): unknown;
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
|
-
local Map = ____lualib.Map
|
|
3
|
-
local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
4
2
|
local Set = ____lualib.Set
|
|
5
3
|
local __TS__New = ____lualib.__TS__New
|
|
4
|
+
local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
5
|
+
local Map = ____lualib.Map
|
|
6
|
+
local WeakMap = ____lualib.WeakMap
|
|
7
|
+
local WeakSet = ____lualib.WeakSet
|
|
8
|
+
local __TS__ArrayPush = ____lualib.__TS__ArrayPush
|
|
6
9
|
local __TS__Iterator = ____lualib.__TS__Iterator
|
|
10
|
+
local __TS__ArraySome = ____lualib.__TS__ArraySome
|
|
7
11
|
local ____exports = {}
|
|
8
|
-
local
|
|
12
|
+
local deepCopyTable, deepCopyDefaultMap, deepCopyMap, deepCopySet, deepCopyTSTLClass, deepCopyArray, deepCopyNormalLuaTable, getCopiedEntries, checkMetatable, deepCopyUserdata, COPYABLE_ISAAC_API_CLASS_TYPES_SET
|
|
9
13
|
local ____DefaultMap = require("classes.DefaultMap")
|
|
10
14
|
local DefaultMap = ____DefaultMap.DefaultMap
|
|
15
|
+
local ____CopyableIsaacAPIClassType = require("enums.private.CopyableIsaacAPIClassType")
|
|
16
|
+
local CopyableIsaacAPIClassType = ____CopyableIsaacAPIClassType.CopyableIsaacAPIClassType
|
|
11
17
|
local ____SerializationBrand = require("enums.private.SerializationBrand")
|
|
12
18
|
local isSerializationBrand = ____SerializationBrand.isSerializationBrand
|
|
13
19
|
local SerializationBrand = ____SerializationBrand.SerializationBrand
|
|
@@ -15,19 +21,24 @@ local ____SerializationType = require("enums.SerializationType")
|
|
|
15
21
|
local SerializationType = ____SerializationType.SerializationType
|
|
16
22
|
local ____constants = require("features.saveDataManager.constants")
|
|
17
23
|
local SAVE_DATA_MANAGER_DEBUG = ____constants.SAVE_DATA_MANAGER_DEBUG
|
|
24
|
+
local ____array = require("functions.array")
|
|
25
|
+
local isArray = ____array.isArray
|
|
26
|
+
local ____isaacAPIClass = require("functions.isaacAPIClass")
|
|
27
|
+
local getIsaacAPIClassType = ____isaacAPIClass.getIsaacAPIClassType
|
|
18
28
|
local ____log = require("functions.log")
|
|
19
29
|
local log = ____log.log
|
|
20
30
|
local ____serialization = require("functions.serialization")
|
|
21
31
|
local copyIsaacAPIClass = ____serialization.copyIsaacAPIClass
|
|
22
32
|
local deserializeIsaacAPIClass = ____serialization.deserializeIsaacAPIClass
|
|
23
|
-
local isSerializableIsaacAPIClass = ____serialization.isSerializableIsaacAPIClass
|
|
24
33
|
local isSerializedIsaacAPIClass = ____serialization.isSerializedIsaacAPIClass
|
|
25
34
|
local ____tstlClass = require("functions.tstlClass")
|
|
26
|
-
local
|
|
35
|
+
local isUserDefinedTSTLClass = ____tstlClass.isUserDefinedTSTLClass
|
|
27
36
|
local newTSTLClass = ____tstlClass.newTSTLClass
|
|
28
37
|
local ____utils = require("functions.utils")
|
|
38
|
+
local ensureAllCases = ____utils.ensureAllCases
|
|
39
|
+
local getEnumValues = ____utils.getEnumValues
|
|
29
40
|
local getTraversalDescription = ____utils.getTraversalDescription
|
|
30
|
-
function ____exports.deepCopy(self,
|
|
41
|
+
function ____exports.deepCopy(self, value, serializationType, traversalDescription)
|
|
31
42
|
if serializationType == nil then
|
|
32
43
|
serializationType = SerializationType.NONE
|
|
33
44
|
end
|
|
@@ -41,178 +52,305 @@ function ____exports.deepCopy(self, oldObject, serializationType, traversalDescr
|
|
|
41
52
|
elseif serializationType == SerializationType.DESERIALIZE then
|
|
42
53
|
logString = logString .. " (deserializing)"
|
|
43
54
|
end
|
|
55
|
+
logString = logString .. ": " .. tostring(value)
|
|
44
56
|
log(logString)
|
|
45
57
|
end
|
|
46
|
-
local
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
58
|
+
local valueType = type(value)
|
|
59
|
+
repeat
|
|
60
|
+
local ____switch6 = valueType
|
|
61
|
+
local ____cond6 = ____switch6 == "nil" or ____switch6 == "boolean" or ____switch6 == "number" or ____switch6 == "string"
|
|
62
|
+
if ____cond6 then
|
|
63
|
+
do
|
|
64
|
+
return value
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
____cond6 = ____cond6 or (____switch6 == "function" or ____switch6 == "thread")
|
|
68
|
+
if ____cond6 then
|
|
69
|
+
do
|
|
70
|
+
if serializationType == SerializationType.SERIALIZE then
|
|
71
|
+
error((("The deep copy function does not support serialization of \"" .. traversalDescription) .. "\", since it is type: ") .. valueType)
|
|
72
|
+
end
|
|
73
|
+
return value
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
____cond6 = ____cond6 or ____switch6 == "table"
|
|
77
|
+
if ____cond6 then
|
|
78
|
+
do
|
|
79
|
+
local valueTable = value
|
|
80
|
+
return deepCopyTable(nil, valueTable, serializationType, traversalDescription)
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
____cond6 = ____cond6 or ____switch6 == "userdata"
|
|
84
|
+
if ____cond6 then
|
|
85
|
+
do
|
|
86
|
+
return deepCopyUserdata(nil, value, serializationType, traversalDescription)
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
do
|
|
90
|
+
do
|
|
91
|
+
return ensureAllCases(nil, valueType)
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
until true
|
|
95
|
+
end
|
|
96
|
+
function deepCopyTable(self, ____table, serializationType, traversalDescription)
|
|
97
|
+
if __TS__InstanceOf(____table, DefaultMap) or ____table[SerializationBrand.DEFAULT_MAP] ~= nil then
|
|
98
|
+
return deepCopyDefaultMap(nil, ____table, serializationType, traversalDescription)
|
|
99
|
+
end
|
|
100
|
+
if __TS__InstanceOf(____table, Map) or ____table[SerializationBrand.MAP] ~= nil then
|
|
101
|
+
return deepCopyMap(nil, ____table, serializationType, traversalDescription)
|
|
102
|
+
end
|
|
103
|
+
if __TS__InstanceOf(____table, Set) or ____table[SerializationBrand.SET] ~= nil then
|
|
104
|
+
return deepCopySet(nil, ____table, serializationType, traversalDescription)
|
|
105
|
+
end
|
|
106
|
+
if __TS__InstanceOf(____table, WeakMap) then
|
|
107
|
+
error("The deep copy function does not support copying the \"WeakMap\" class for: " .. traversalDescription)
|
|
108
|
+
end
|
|
109
|
+
if __TS__InstanceOf(____table, WeakSet) then
|
|
110
|
+
error("The deep copy function does not support copying the \"WeakSet\" class for: " .. traversalDescription)
|
|
111
|
+
end
|
|
112
|
+
if isUserDefinedTSTLClass(nil, ____table) then
|
|
113
|
+
return deepCopyTSTLClass(nil, ____table, serializationType, traversalDescription)
|
|
114
|
+
end
|
|
115
|
+
checkMetatable(nil, ____table, traversalDescription)
|
|
116
|
+
if isSerializedIsaacAPIClass(nil, ____table) and serializationType == SerializationType.DESERIALIZE then
|
|
117
|
+
return deserializeIsaacAPIClass(nil, ____table)
|
|
118
|
+
end
|
|
119
|
+
if isArray(nil, ____table) then
|
|
120
|
+
return deepCopyArray(nil, ____table, serializationType, traversalDescription)
|
|
121
|
+
end
|
|
122
|
+
return deepCopyNormalLuaTable(nil, ____table, serializationType, traversalDescription)
|
|
123
|
+
end
|
|
124
|
+
function deepCopyDefaultMap(self, defaultMap, serializationType, traversalDescription)
|
|
125
|
+
local ____temp_0
|
|
126
|
+
if __TS__InstanceOf(defaultMap, DefaultMap) then
|
|
127
|
+
____temp_0 = defaultMap:getConstructorArg()
|
|
80
128
|
else
|
|
81
|
-
|
|
129
|
+
____temp_0 = nil
|
|
82
130
|
end
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
131
|
+
local constructorArg = ____temp_0
|
|
132
|
+
local newDefaultMap
|
|
133
|
+
repeat
|
|
134
|
+
local ____switch23 = serializationType
|
|
135
|
+
local ____cond23 = ____switch23 == SerializationType.NONE
|
|
136
|
+
if ____cond23 then
|
|
137
|
+
do
|
|
138
|
+
newDefaultMap = __TS__New(DefaultMap, constructorArg)
|
|
139
|
+
break
|
|
91
140
|
end
|
|
92
|
-
elseif __TS__InstanceOf(oldObject, Map) then
|
|
93
|
-
newTable[SerializationBrand.MAP] = ""
|
|
94
|
-
elseif __TS__InstanceOf(oldObject, Set) then
|
|
95
|
-
newTable[SerializationBrand.SET] = ""
|
|
96
141
|
end
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
for ____, ____value in __TS__Iterator(oldObject:entries()) do
|
|
100
|
-
local key = ____value[1]
|
|
101
|
-
local value = ____value[2]
|
|
142
|
+
____cond23 = ____cond23 or ____switch23 == SerializationType.SERIALIZE
|
|
143
|
+
if ____cond23 then
|
|
102
144
|
do
|
|
103
|
-
if
|
|
104
|
-
|
|
145
|
+
if type(constructorArg) ~= "boolean" and type(constructorArg) ~= "number" and type(constructorArg) ~= "string" then
|
|
146
|
+
return deepCopyMap(nil, defaultMap, serializationType, traversalDescription)
|
|
105
147
|
end
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
key,
|
|
111
|
-
value,
|
|
112
|
-
traversalDescription,
|
|
113
|
-
serializationType
|
|
114
|
-
)
|
|
148
|
+
newDefaultMap = {}
|
|
149
|
+
newDefaultMap[SerializationBrand.DEFAULT_MAP] = ""
|
|
150
|
+
newDefaultMap[SerializationBrand.DEFAULT_MAP_VALUE] = constructorArg
|
|
151
|
+
break
|
|
115
152
|
end
|
|
116
|
-
::__continue22::
|
|
117
153
|
end
|
|
118
|
-
|
|
119
|
-
|
|
154
|
+
____cond23 = ____cond23 or ____switch23 == SerializationType.DESERIALIZE
|
|
155
|
+
if ____cond23 then
|
|
120
156
|
do
|
|
121
|
-
if
|
|
122
|
-
|
|
157
|
+
if __TS__InstanceOf(defaultMap, DefaultMap) then
|
|
158
|
+
error(("The deep copy function failed to deserialize a default map of \"" .. traversalDescription) .. "\", since it was not a Lua table.")
|
|
159
|
+
end
|
|
160
|
+
local defaultMapValue = defaultMap[SerializationBrand.DEFAULT_MAP_VALUE]
|
|
161
|
+
if defaultMapValue == nil then
|
|
162
|
+
error((("The deep copy function failed to deserialize a default map of \"" .. traversalDescription) .. "\", since there was no serialization brand of: ") .. SerializationBrand.DEFAULT_MAP_VALUE)
|
|
123
163
|
end
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
nil,
|
|
127
|
-
oldObject,
|
|
128
|
-
newObject,
|
|
129
|
-
key,
|
|
130
|
-
value,
|
|
131
|
-
traversalDescription,
|
|
132
|
-
serializationType
|
|
133
|
-
)
|
|
164
|
+
newDefaultMap = __TS__New(DefaultMap, defaultMapValue)
|
|
165
|
+
break
|
|
134
166
|
end
|
|
135
|
-
::__continue26::
|
|
136
167
|
end
|
|
137
|
-
|
|
138
|
-
for key, value in pairs(oldObject) do
|
|
168
|
+
do
|
|
139
169
|
do
|
|
140
|
-
|
|
141
|
-
goto __continue30
|
|
142
|
-
end
|
|
143
|
-
deepCopyValue(
|
|
144
|
-
nil,
|
|
145
|
-
oldObject,
|
|
146
|
-
newObject,
|
|
147
|
-
key,
|
|
148
|
-
value,
|
|
149
|
-
traversalDescription,
|
|
150
|
-
serializationType
|
|
151
|
-
)
|
|
170
|
+
return ensureAllCases(nil, serializationType)
|
|
152
171
|
end
|
|
153
|
-
|
|
172
|
+
end
|
|
173
|
+
until true
|
|
174
|
+
local ____getCopiedEntries_result_1 = getCopiedEntries(nil, defaultMap, serializationType, traversalDescription)
|
|
175
|
+
local entries = ____getCopiedEntries_result_1.entries
|
|
176
|
+
local convertedNumberKeysToStrings = ____getCopiedEntries_result_1.convertedNumberKeysToStrings
|
|
177
|
+
if convertedNumberKeysToStrings then
|
|
178
|
+
if __TS__InstanceOf(newDefaultMap, DefaultMap) then
|
|
179
|
+
newDefaultMap:set(SerializationBrand.OBJECT_WITH_NUMBER_KEYS, "")
|
|
180
|
+
else
|
|
181
|
+
newDefaultMap[SerializationBrand.OBJECT_WITH_NUMBER_KEYS] = ""
|
|
154
182
|
end
|
|
155
183
|
end
|
|
156
|
-
|
|
184
|
+
for ____, ____value in ipairs(entries) do
|
|
185
|
+
local key = ____value[1]
|
|
186
|
+
local value = ____value[2]
|
|
187
|
+
if __TS__InstanceOf(newDefaultMap, DefaultMap) then
|
|
188
|
+
newDefaultMap:set(key, value)
|
|
189
|
+
else
|
|
190
|
+
newDefaultMap[key] = value
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
return newDefaultMap
|
|
157
194
|
end
|
|
158
|
-
function
|
|
159
|
-
local
|
|
160
|
-
if
|
|
161
|
-
|
|
195
|
+
function deepCopyMap(self, map, serializationType, traversalDescription)
|
|
196
|
+
local newMap
|
|
197
|
+
if serializationType == SerializationType.SERIALIZE then
|
|
198
|
+
newMap = {}
|
|
199
|
+
newMap[SerializationBrand.MAP] = ""
|
|
200
|
+
else
|
|
201
|
+
newMap = __TS__New(Map)
|
|
162
202
|
end
|
|
163
|
-
local
|
|
164
|
-
|
|
203
|
+
local ____getCopiedEntries_result_2 = getCopiedEntries(nil, map, serializationType, traversalDescription)
|
|
204
|
+
local entries = ____getCopiedEntries_result_2.entries
|
|
205
|
+
local convertedNumberKeysToStrings = ____getCopiedEntries_result_2.convertedNumberKeysToStrings
|
|
206
|
+
if convertedNumberKeysToStrings then
|
|
207
|
+
if __TS__InstanceOf(newMap, Map) then
|
|
208
|
+
newMap:set(SerializationBrand.OBJECT_WITH_NUMBER_KEYS, "")
|
|
209
|
+
else
|
|
210
|
+
newMap[SerializationBrand.OBJECT_WITH_NUMBER_KEYS] = ""
|
|
211
|
+
end
|
|
212
|
+
end
|
|
213
|
+
for ____, ____value in ipairs(entries) do
|
|
214
|
+
local key = ____value[1]
|
|
215
|
+
local value = ____value[2]
|
|
216
|
+
if __TS__InstanceOf(newMap, Map) then
|
|
217
|
+
newMap:set(key, value)
|
|
218
|
+
else
|
|
219
|
+
newMap[key] = value
|
|
220
|
+
end
|
|
221
|
+
end
|
|
222
|
+
return newMap
|
|
165
223
|
end
|
|
166
|
-
function
|
|
167
|
-
local
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
224
|
+
function deepCopySet(self, set, serializationType, traversalDescription)
|
|
225
|
+
local newSet
|
|
226
|
+
if serializationType == SerializationType.SERIALIZE then
|
|
227
|
+
newSet = {}
|
|
228
|
+
newSet[SerializationBrand.SET] = ""
|
|
229
|
+
else
|
|
230
|
+
newSet = __TS__New(Set)
|
|
231
|
+
end
|
|
232
|
+
local ____getCopiedEntries_result_3 = getCopiedEntries(nil, set, serializationType, traversalDescription)
|
|
233
|
+
local entries = ____getCopiedEntries_result_3.entries
|
|
234
|
+
local convertedNumberKeysToStrings = ____getCopiedEntries_result_3.convertedNumberKeysToStrings
|
|
235
|
+
if convertedNumberKeysToStrings then
|
|
236
|
+
if __TS__InstanceOf(newSet, Set) then
|
|
237
|
+
error("The deep copy function cannot convert number keys to strings for a Set.")
|
|
238
|
+
else
|
|
239
|
+
newSet[SerializationBrand.OBJECT_WITH_NUMBER_KEYS] = ""
|
|
178
240
|
end
|
|
179
241
|
end
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
242
|
+
for ____, ____value in ipairs(entries) do
|
|
243
|
+
local key = ____value[1]
|
|
244
|
+
if __TS__InstanceOf(newSet, Set) then
|
|
245
|
+
newSet:add(key)
|
|
246
|
+
else
|
|
247
|
+
newSet[key] = ""
|
|
248
|
+
end
|
|
249
|
+
end
|
|
250
|
+
return newSet
|
|
251
|
+
end
|
|
252
|
+
function deepCopyTSTLClass(self, tstlClass, serializationType, traversalDescription)
|
|
253
|
+
local newClass
|
|
254
|
+
if serializationType == SerializationType.SERIALIZE then
|
|
255
|
+
newClass = {}
|
|
191
256
|
else
|
|
192
|
-
|
|
193
|
-
|
|
257
|
+
newClass = newTSTLClass(nil, tstlClass)
|
|
258
|
+
end
|
|
259
|
+
local ____getCopiedEntries_result_4 = getCopiedEntries(nil, tstlClass, serializationType, traversalDescription)
|
|
260
|
+
local entries = ____getCopiedEntries_result_4.entries
|
|
261
|
+
local convertedNumberKeysToStrings = ____getCopiedEntries_result_4.convertedNumberKeysToStrings
|
|
262
|
+
if convertedNumberKeysToStrings then
|
|
263
|
+
newClass[SerializationBrand.OBJECT_WITH_NUMBER_KEYS] = ""
|
|
194
264
|
end
|
|
265
|
+
for ____, ____value in ipairs(entries) do
|
|
266
|
+
local key = ____value[1]
|
|
267
|
+
local value = ____value[2]
|
|
268
|
+
newClass[key] = value
|
|
269
|
+
end
|
|
270
|
+
return newClass
|
|
195
271
|
end
|
|
196
|
-
function
|
|
197
|
-
|
|
198
|
-
|
|
272
|
+
function deepCopyArray(self, array, serializationType, traversalDescription)
|
|
273
|
+
local newArray = {}
|
|
274
|
+
for ____, value in ipairs(array) do
|
|
275
|
+
local newValue = ____exports.deepCopy(nil, value, serializationType, traversalDescription)
|
|
276
|
+
__TS__ArrayPush(newArray, newValue)
|
|
277
|
+
end
|
|
278
|
+
return newArray
|
|
279
|
+
end
|
|
280
|
+
function deepCopyNormalLuaTable(self, ____table, serializationType, traversalDescription)
|
|
281
|
+
local newTable = {}
|
|
282
|
+
local ____getCopiedEntries_result_5 = getCopiedEntries(nil, ____table, serializationType, traversalDescription)
|
|
283
|
+
local entries = ____getCopiedEntries_result_5.entries
|
|
284
|
+
local convertedNumberKeysToStrings = ____getCopiedEntries_result_5.convertedNumberKeysToStrings
|
|
285
|
+
if convertedNumberKeysToStrings then
|
|
286
|
+
newTable[SerializationBrand.OBJECT_WITH_NUMBER_KEYS] = ""
|
|
199
287
|
end
|
|
200
|
-
|
|
201
|
-
|
|
288
|
+
for ____, ____value in ipairs(entries) do
|
|
289
|
+
local key = ____value[1]
|
|
290
|
+
local value = ____value[2]
|
|
291
|
+
newTable[key] = value
|
|
202
292
|
end
|
|
293
|
+
return newTable
|
|
203
294
|
end
|
|
204
|
-
function
|
|
205
|
-
|
|
206
|
-
|
|
295
|
+
function getCopiedEntries(self, object, serializationType, traversalDescription)
|
|
296
|
+
local entries = {}
|
|
297
|
+
if __TS__InstanceOf(object, Map) or __TS__InstanceOf(object, Set) then
|
|
298
|
+
for ____, ____value in __TS__Iterator(object:entries()) do
|
|
299
|
+
local key = ____value[1]
|
|
300
|
+
local value = ____value[2]
|
|
301
|
+
__TS__ArrayPush(entries, {key, value})
|
|
302
|
+
end
|
|
303
|
+
else
|
|
304
|
+
for key, value in pairs(object) do
|
|
305
|
+
__TS__ArrayPush(entries, {key, value})
|
|
306
|
+
end
|
|
207
307
|
end
|
|
208
|
-
|
|
209
|
-
|
|
308
|
+
local hasNumberKeys = __TS__ArraySome(
|
|
309
|
+
entries,
|
|
310
|
+
function(____, ____bindingPattern0)
|
|
311
|
+
local key
|
|
312
|
+
key = ____bindingPattern0[1]
|
|
313
|
+
return type(key) == "number"
|
|
314
|
+
end
|
|
315
|
+
)
|
|
316
|
+
local convertNumberKeysToStrings = serializationType == SerializationType.SERIALIZE and hasNumberKeys
|
|
317
|
+
local copiedEntries = {}
|
|
318
|
+
for ____, ____value in ipairs(entries) do
|
|
319
|
+
local key = ____value[1]
|
|
320
|
+
local value = ____value[2]
|
|
321
|
+
do
|
|
322
|
+
if isSerializationBrand(nil, key) then
|
|
323
|
+
goto __continue78
|
|
324
|
+
end
|
|
325
|
+
traversalDescription = getTraversalDescription(nil, key, traversalDescription)
|
|
326
|
+
local newValue = ____exports.deepCopy(nil, value, serializationType, traversalDescription)
|
|
327
|
+
local keyToUse = convertNumberKeysToStrings and tostring(key) or key
|
|
328
|
+
__TS__ArrayPush(copiedEntries, {keyToUse, newValue})
|
|
329
|
+
end
|
|
330
|
+
::__continue78::
|
|
331
|
+
end
|
|
332
|
+
return {entries = copiedEntries, convertedNumberKeysToStrings = convertNumberKeysToStrings}
|
|
333
|
+
end
|
|
334
|
+
function checkMetatable(self, ____table, traversalDescription)
|
|
335
|
+
local metatable = getmetatable(____table)
|
|
336
|
+
if metatable == nil then
|
|
337
|
+
return
|
|
338
|
+
end
|
|
339
|
+
local tableDescription = traversalDescription == "" and "the table to copy" or ("\"" .. traversalDescription) .. "\""
|
|
340
|
+
error(("The deepCopy function detected that \"" .. tableDescription) .. "\" has a metatable. Copying tables with metatables is not supported, unless they are explicitly handled by the save data manager. (e.g. TypeScriptToLua Maps, TypeScriptToLua Sets, etc.)")
|
|
341
|
+
end
|
|
342
|
+
function deepCopyUserdata(self, value, serializationType, traversalDescription)
|
|
343
|
+
local classType = getIsaacAPIClassType(nil, value)
|
|
344
|
+
if classType == nil then
|
|
345
|
+
error("The deep copy function was not able to derive the Isaac API class type for: " .. traversalDescription)
|
|
210
346
|
end
|
|
211
|
-
if
|
|
212
|
-
|
|
213
|
-
traversalDescription = getTraversalDescription(nil, key, traversalDescription)
|
|
214
|
-
return ____exports.deepCopy(nil, ____table, serializationType, traversalDescription)
|
|
347
|
+
if not COPYABLE_ISAAC_API_CLASS_TYPES_SET:has(classType) then
|
|
348
|
+
error((("The deep copy function does not support copying \"" .. traversalDescription) .. "\", since it is an Isaac API class of type: ") .. classType)
|
|
215
349
|
end
|
|
216
|
-
return value
|
|
350
|
+
return copyIsaacAPIClass(nil, value, serializationType)
|
|
217
351
|
end
|
|
352
|
+
COPYABLE_ISAAC_API_CLASS_TYPES_SET = __TS__New(
|
|
353
|
+
Set,
|
|
354
|
+
getEnumValues(nil, CopyableIsaacAPIClassType)
|
|
355
|
+
)
|
|
218
356
|
return ____exports
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare function easeInSine(x: number): number;
|
|
2
|
+
export declare function easeOutSine(x: number): number;
|
|
3
|
+
export declare function easeInOutSine(x: number): number;
|
|
4
|
+
export declare function easeInCubic(x: number): number;
|
|
5
|
+
export declare function easeOutCubic(x: number): number;
|
|
6
|
+
export declare function easeInOutCubic(x: number): number;
|
|
7
|
+
export declare function easeInQuint(x: number): number;
|
|
8
|
+
export declare function easeOutQuint(x: number): number;
|
|
9
|
+
export declare function easeInOutQuint(x: number): number;
|
|
10
|
+
export declare function easeInCirc(x: number): number;
|
|
11
|
+
export declare function easeOutCirc(x: number): number;
|
|
12
|
+
export declare function easeInOutCirc(x: number): number;
|
|
13
|
+
export declare function easeInElastic(x: number): number;
|
|
14
|
+
export declare function easeOutElastic(x: number): number;
|
|
15
|
+
export declare function easeInOutElastic(x: number): number;
|
|
16
|
+
export declare function easeInQuad(x: number): number;
|
|
17
|
+
export declare function easeOutQuad(x: number): number;
|
|
18
|
+
export declare function easeInOutQuad(x: number): number;
|
|
19
|
+
export declare function easeInQuart(x: number): number;
|
|
20
|
+
export declare function easeOutQuart(x: number): number;
|
|
21
|
+
export declare function easeInOutQuart(x: number): number;
|
|
22
|
+
export declare function easeInExpo(x: number): number;
|
|
23
|
+
export declare function easeOutExpo(x: number): number;
|
|
24
|
+
export declare function easeInOutExpo(x: number): number;
|
|
25
|
+
export declare function easeInBack(x: number): number;
|
|
26
|
+
export declare function easeOutBack(x: number): number;
|
|
27
|
+
export declare function easeInOutBack(x: number): number;
|
|
28
|
+
export declare function easeInBounce(x: number): number;
|
|
29
|
+
export declare function easeOutBounce(x: number): number;
|
|
30
|
+
export declare function easeInOutBounce(x: number): number;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
|
+
local ____exports = {}
|
|
3
|
+
function ____exports.easeOutBounce(self, x)
|
|
4
|
+
local n1 = 7.5625
|
|
5
|
+
local d1 = 2.75
|
|
6
|
+
if x < 1 / d1 then
|
|
7
|
+
return n1 * x * x
|
|
8
|
+
end
|
|
9
|
+
if x < 2 / d1 then
|
|
10
|
+
x = x - 1.5 / d1
|
|
11
|
+
return n1 * x * x + 0.75
|
|
12
|
+
end
|
|
13
|
+
if x < 2.5 / d1 then
|
|
14
|
+
x = x - 2.25 / d1
|
|
15
|
+
return n1 * x * x + 0.9375
|
|
16
|
+
end
|
|
17
|
+
x = x - 2.625 / d1
|
|
18
|
+
return n1 * x * x + 0.984375
|
|
19
|
+
end
|
|
20
|
+
function ____exports.easeInSine(self, x)
|
|
21
|
+
return 1 - math.cos(x * math.pi / 2)
|
|
22
|
+
end
|
|
23
|
+
function ____exports.easeOutSine(self, x)
|
|
24
|
+
return math.sin(x * math.pi / 2)
|
|
25
|
+
end
|
|
26
|
+
function ____exports.easeInOutSine(self, x)
|
|
27
|
+
return -(math.cos(math.pi * x) - 1) / 2
|
|
28
|
+
end
|
|
29
|
+
function ____exports.easeInCubic(self, x)
|
|
30
|
+
return x * x * x
|
|
31
|
+
end
|
|
32
|
+
function ____exports.easeOutCubic(self, x)
|
|
33
|
+
return 1 - (1 - x) ^ 3
|
|
34
|
+
end
|
|
35
|
+
function ____exports.easeInOutCubic(self, x)
|
|
36
|
+
return x < 0.5 and 4 * x * x * x or 1 - (-2 * x + 2) ^ 3 / 2
|
|
37
|
+
end
|
|
38
|
+
function ____exports.easeInQuint(self, x)
|
|
39
|
+
return x * x * x * x * x
|
|
40
|
+
end
|
|
41
|
+
function ____exports.easeOutQuint(self, x)
|
|
42
|
+
return 1 - (1 - x) ^ 5
|
|
43
|
+
end
|
|
44
|
+
function ____exports.easeInOutQuint(self, x)
|
|
45
|
+
return x < 0.5 and 16 * x * x * x * x * x or 1 - (-2 * x + 2) ^ 5 / 2
|
|
46
|
+
end
|
|
47
|
+
function ____exports.easeInCirc(self, x)
|
|
48
|
+
return 1 - math.sqrt(1 - x ^ 2)
|
|
49
|
+
end
|
|
50
|
+
function ____exports.easeOutCirc(self, x)
|
|
51
|
+
return math.sqrt(1 - (x - 1) ^ 2)
|
|
52
|
+
end
|
|
53
|
+
function ____exports.easeInOutCirc(self, x)
|
|
54
|
+
return x < 0.5 and (1 - math.sqrt(1 - (2 * x) ^ 2)) / 2 or (math.sqrt(1 - (-2 * x + 2) ^ 2) + 1) / 2
|
|
55
|
+
end
|
|
56
|
+
function ____exports.easeInElastic(self, x)
|
|
57
|
+
local c4 = 2 * math.pi / 3
|
|
58
|
+
return x == 0 and 0 or (x == 1 and 1 or -2 ^ (10 * x - 10) * math.sin((x * 10 - 10.75) * c4))
|
|
59
|
+
end
|
|
60
|
+
function ____exports.easeOutElastic(self, x)
|
|
61
|
+
local c4 = 2 * math.pi / 3
|
|
62
|
+
return x == 0 and 0 or (x == 1 and 1 or 2 ^ (-10 * x) * math.sin((x * 10 - 0.75) * c4) + 1)
|
|
63
|
+
end
|
|
64
|
+
function ____exports.easeInOutElastic(self, x)
|
|
65
|
+
local c5 = 2 * math.pi / 4.5
|
|
66
|
+
return x == 0 and 0 or (x == 1 and 1 or (x < 0.5 and -(2 ^ (20 * x - 10) * math.sin((20 * x - 11.125) * c5)) / 2 or 2 ^ (-20 * x + 10) * math.sin((20 * x - 11.125) * c5) / 2 + 1))
|
|
67
|
+
end
|
|
68
|
+
function ____exports.easeInQuad(self, x)
|
|
69
|
+
return x * x
|
|
70
|
+
end
|
|
71
|
+
function ____exports.easeOutQuad(self, x)
|
|
72
|
+
return 1 - (1 - x) * (1 - x)
|
|
73
|
+
end
|
|
74
|
+
function ____exports.easeInOutQuad(self, x)
|
|
75
|
+
return x < 0.5 and 2 * x * x or 1 - (-2 * x + 2) ^ 2 / 2
|
|
76
|
+
end
|
|
77
|
+
function ____exports.easeInQuart(self, x)
|
|
78
|
+
return x * x * x * x
|
|
79
|
+
end
|
|
80
|
+
function ____exports.easeOutQuart(self, x)
|
|
81
|
+
return 1 - (1 - x) ^ 4
|
|
82
|
+
end
|
|
83
|
+
function ____exports.easeInOutQuart(self, x)
|
|
84
|
+
return x < 0.5 and 8 * x * x * x * x or 1 - (-2 * x + 2) ^ 4 / 2
|
|
85
|
+
end
|
|
86
|
+
function ____exports.easeInExpo(self, x)
|
|
87
|
+
return x == 0 and 0 or 2 ^ (10 * x - 10)
|
|
88
|
+
end
|
|
89
|
+
function ____exports.easeOutExpo(self, x)
|
|
90
|
+
return x == 1 and 1 or 1 - 2 ^ (-10 * x)
|
|
91
|
+
end
|
|
92
|
+
function ____exports.easeInOutExpo(self, x)
|
|
93
|
+
return x == 0 and 0 or (x == 1 and 1 or (x < 0.5 and 2 ^ (20 * x - 10) / 2 or (2 - 2 ^ (-20 * x + 10)) / 2))
|
|
94
|
+
end
|
|
95
|
+
function ____exports.easeInBack(self, x)
|
|
96
|
+
local c1 = 1.70158
|
|
97
|
+
local c3 = c1 + 1
|
|
98
|
+
return c3 * x * x * x - c1 * x * x
|
|
99
|
+
end
|
|
100
|
+
function ____exports.easeOutBack(self, x)
|
|
101
|
+
local c1 = 1.70158
|
|
102
|
+
local c3 = c1 + 1
|
|
103
|
+
return 1 + c3 * (x - 1) ^ 3 + c1 * (x - 1) ^ 2
|
|
104
|
+
end
|
|
105
|
+
function ____exports.easeInOutBack(self, x)
|
|
106
|
+
local c1 = 1.70158
|
|
107
|
+
local c2 = c1 * 1.525
|
|
108
|
+
return x < 0.5 and (2 * x) ^ 2 * ((c2 + 1) * 2 * x - c2) / 2 or ((2 * x - 2) ^ 2 * ((c2 + 1) * (x * 2 - 2) + c2) + 2) / 2
|
|
109
|
+
end
|
|
110
|
+
function ____exports.easeInBounce(self, x)
|
|
111
|
+
return 1 - ____exports.easeOutBounce(nil, 1 - x)
|
|
112
|
+
end
|
|
113
|
+
function ____exports.easeInOutBounce(self, x)
|
|
114
|
+
return x < 0.5 and (1 - ____exports.easeOutBounce(nil, 1 - 2 * x)) / 2 or (1 + ____exports.easeOutBounce(nil, 2 * x - 1)) / 2
|
|
115
|
+
end
|
|
116
|
+
return ____exports
|
package/dist/functions/log.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export declare function logEntityID(this: void, entity: Entity): void;
|
|
|
27
27
|
*/
|
|
28
28
|
export declare function logError(this: void, msg: string): void;
|
|
29
29
|
/** Helper function for printing out every flag that is turned on. Useful when debugging. */
|
|
30
|
-
export declare function logFlags(this: void, flags: int, flagEnum?: LuaTable, description?: string): void;
|
|
30
|
+
export declare function logFlags(this: void, flags: int, flagEnum?: LuaTable<AnyNotNil, unknown>, description?: string): void;
|
|
31
31
|
/**
|
|
32
32
|
* Helper function for printing out every game state flag that is turned on. Useful when debugging.
|
|
33
33
|
*/
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { SerializationType } from "../enums/SerializationType";
|
|
2
|
-
import { SerializableIsaacAPIClass } from "../types/private/SerializableIsaacAPIClass";
|
|
3
2
|
import { SerializedIsaacAPIClass } from "../types/private/SerializedIsaacAPIClass";
|
|
4
|
-
export declare function copyIsaacAPIClass(isaacAPIClass:
|
|
3
|
+
export declare function copyIsaacAPIClass(isaacAPIClass: unknown, serializationType: SerializationType): unknown;
|
|
5
4
|
/**
|
|
6
|
-
* Deserialization is a special case, so we make a dedicated function for this.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* Deserialization is a special case, so we make a dedicated function for this.
|
|
6
|
+
*
|
|
7
|
+
* There is no need for a corresponding "serializeIsaacAPIClass" function because the
|
|
8
|
+
* "copyIsaacAPIClass" function can handles all serialization types.
|
|
9
9
|
*/
|
|
10
10
|
export declare function deserializeIsaacAPIClass(serializedIsaacAPIClass: SerializedIsaacAPIClass): unknown;
|
|
11
|
-
export declare function isSerializableIsaacAPIClass(object: unknown): object is SerializableIsaacAPIClass;
|
|
12
11
|
export declare function isSerializedIsaacAPIClass(object: unknown): object is SerializedIsaacAPIClass;
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
|
-
local Set = ____lualib.Set
|
|
3
|
-
local __TS__New = ____lualib.__TS__New
|
|
4
2
|
local __TS__ObjectEntries = ____lualib.__TS__ObjectEntries
|
|
5
3
|
local __TS__ObjectValues = ____lualib.__TS__ObjectValues
|
|
6
4
|
local __TS__ArraySome = ____lualib.__TS__ArraySome
|
|
7
5
|
local ____exports = {}
|
|
8
6
|
local getSerializedTableType
|
|
9
|
-
local ____SerializableIsaacAPIClassType = require("enums.private.SerializableIsaacAPIClassType")
|
|
10
|
-
local SerializableIsaacAPIClassType = ____SerializableIsaacAPIClassType.SerializableIsaacAPIClassType
|
|
11
7
|
local ____SerializationType = require("enums.SerializationType")
|
|
12
8
|
local SerializationType = ____SerializationType.SerializationType
|
|
13
9
|
local ____isaacAPIClassTypeToBrand = require("objects.isaacAPIClassTypeToBrand")
|
|
@@ -18,35 +14,29 @@ local ____serializedIsaacAPIClassTypeToIdentityFunction = require("objects.seria
|
|
|
18
14
|
local SERIALIZED_ISAAC_API_CLASS_TYPE_TO_IDENTITY_FUNCTION = ____serializedIsaacAPIClassTypeToIdentityFunction.SERIALIZED_ISAAC_API_CLASS_TYPE_TO_IDENTITY_FUNCTION
|
|
19
15
|
local ____isaacAPIClass = require("functions.isaacAPIClass")
|
|
20
16
|
local getIsaacAPIClassType = ____isaacAPIClass.getIsaacAPIClassType
|
|
21
|
-
local ____utils = require("functions.utils")
|
|
22
|
-
local getEnumValues = ____utils.getEnumValues
|
|
23
17
|
function getSerializedTableType(self, serializedIsaacAPIClass)
|
|
24
18
|
for ____, ____value in ipairs(__TS__ObjectEntries(ISAAC_API_CLASS_TYPE_TO_BRAND)) do
|
|
25
|
-
local
|
|
19
|
+
local copyableIsaacAPIClassType = ____value[1]
|
|
26
20
|
local serializationBrand = ____value[2]
|
|
27
21
|
if serializedIsaacAPIClass[serializationBrand] ~= nil then
|
|
28
|
-
return
|
|
22
|
+
return copyableIsaacAPIClassType
|
|
29
23
|
end
|
|
30
24
|
end
|
|
31
25
|
return nil
|
|
32
26
|
end
|
|
33
|
-
local SERIALIZABLE_ISAAC_API_CLASS_TYPES_SET = __TS__New(
|
|
34
|
-
Set,
|
|
35
|
-
getEnumValues(nil, SerializableIsaacAPIClassType)
|
|
36
|
-
)
|
|
37
27
|
function ____exports.copyIsaacAPIClass(self, isaacAPIClass, serializationType)
|
|
38
28
|
local objectType = type(isaacAPIClass)
|
|
39
29
|
if objectType ~= "userdata" then
|
|
40
|
-
error("Failed to
|
|
30
|
+
error("Failed to copy an Isaac API class since the provided object was of type: " .. objectType)
|
|
41
31
|
end
|
|
42
32
|
local isaacAPIClassType = getIsaacAPIClassType(nil, isaacAPIClass)
|
|
43
33
|
if isaacAPIClassType == nil then
|
|
44
|
-
error("Failed to
|
|
34
|
+
error("Failed to copy an Isaac API class since it does not have a class type.")
|
|
45
35
|
end
|
|
46
|
-
local
|
|
47
|
-
local copyFunction = ISAAC_API_CLASS_TYPE_TO_COPY_FUNCTION[
|
|
36
|
+
local copyableIsaacAPIClassType = isaacAPIClassType
|
|
37
|
+
local copyFunction = ISAAC_API_CLASS_TYPE_TO_COPY_FUNCTION[copyableIsaacAPIClassType]
|
|
48
38
|
if copyFunction == nil then
|
|
49
|
-
error(("Failed to copy Isaac API class \"" ..
|
|
39
|
+
error(("Failed to copy Isaac API class \"" .. copyableIsaacAPIClassType) .. "\" since there is not a defined copy function for this class type.")
|
|
50
40
|
end
|
|
51
41
|
return copyFunction(nil, isaacAPIClass, serializationType)
|
|
52
42
|
end
|
|
@@ -55,23 +45,16 @@ function ____exports.deserializeIsaacAPIClass(self, serializedIsaacAPIClass)
|
|
|
55
45
|
if objectType ~= "table" then
|
|
56
46
|
error("Failed to deserialize an Isaac API class since the provided object was of type: " .. objectType)
|
|
57
47
|
end
|
|
58
|
-
local
|
|
59
|
-
if
|
|
48
|
+
local copyableIsaacAPIClassType = getSerializedTableType(nil, serializedIsaacAPIClass)
|
|
49
|
+
if copyableIsaacAPIClassType == nil then
|
|
60
50
|
error("Failed to deserialize an API class since a valid class type brand was not found.")
|
|
61
51
|
end
|
|
62
|
-
local copyFunction = ISAAC_API_CLASS_TYPE_TO_COPY_FUNCTION[
|
|
52
|
+
local copyFunction = ISAAC_API_CLASS_TYPE_TO_COPY_FUNCTION[copyableIsaacAPIClassType]
|
|
63
53
|
if copyFunction == nil then
|
|
64
|
-
error(("Failed to deserialize Isaac API class \"" ..
|
|
54
|
+
error(("Failed to deserialize Isaac API class \"" .. copyableIsaacAPIClassType) .. "\" since there is not a defined copy function for this class type.")
|
|
65
55
|
end
|
|
66
56
|
return copyFunction(nil, serializedIsaacAPIClass, SerializationType.DESERIALIZE)
|
|
67
57
|
end
|
|
68
|
-
function ____exports.isSerializableIsaacAPIClass(self, object)
|
|
69
|
-
local classType = getIsaacAPIClassType(nil, object)
|
|
70
|
-
if classType == nil then
|
|
71
|
-
return false
|
|
72
|
-
end
|
|
73
|
-
return SERIALIZABLE_ISAAC_API_CLASS_TYPES_SET:has(classType)
|
|
74
|
-
end
|
|
75
58
|
function ____exports.isSerializedIsaacAPIClass(self, object)
|
|
76
59
|
local identityFunctions = __TS__ObjectValues(SERIALIZED_ISAAC_API_CLASS_TYPE_TO_IDENTITY_FUNCTION)
|
|
77
60
|
return __TS__ArraySome(
|
|
@@ -33,4 +33,4 @@ export declare function getStringsFromTable(table: LuaTable<string, unknown>, ob
|
|
|
33
33
|
* This function is variadic, meaning that you can specify as many arguments as you want to check
|
|
34
34
|
* for.
|
|
35
35
|
*/
|
|
36
|
-
export declare function tableHasKeys(table: LuaTable, ...keys: string[]): boolean;
|
|
36
|
+
export declare function tableHasKeys(table: LuaTable<AnyNotNil, unknown>, ...keys: string[]): boolean;
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { TSTLClass } from "../types/private/TSTLClass";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* For the purposes of this function, TSTL Maps, Sets, WeakMaps, and WeakSets do not count as TSTL
|
|
6
|
-
* classes, because this function is intended to detect user-defined classes.
|
|
3
|
+
* Returns whether or not this is a class that is provided by the `isaacscript-common` library, such
|
|
4
|
+
* as a `DefaultMap`.
|
|
7
5
|
*/
|
|
8
|
-
export declare function
|
|
6
|
+
export declare function isIsaacScriptCommonClass(object: unknown): boolean;
|
|
7
|
+
/** TypeScriptToLua classes are Lua tables that have a metatable with a certain amount of keys. */
|
|
8
|
+
export declare function isUserDefinedTSTLClass(object: unknown): object is TSTLClass;
|
|
9
|
+
/**
|
|
10
|
+
* Returns whether or not this is a class that is provided as part of the TypeScriptToLua
|
|
11
|
+
* transpiler, such as a `Map` or a `Set`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function isVanillaTSTLClass(object: unknown): boolean;
|
|
9
14
|
/**
|
|
10
15
|
* Initializes a new TypeScriptToLua class in the situation where you do not know what kind of class
|
|
11
16
|
* it is. This function requires that you provide an instantiated class of the same type, as it will
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
2
|
local Set = ____lualib.Set
|
|
3
3
|
local __TS__New = ____lualib.__TS__New
|
|
4
|
-
local Map = ____lualib.Map
|
|
5
4
|
local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
5
|
+
local Map = ____lualib.Map
|
|
6
6
|
local WeakMap = ____lualib.WeakMap
|
|
7
7
|
local WeakSet = ____lualib.WeakSet
|
|
8
8
|
local ____exports = {}
|
|
9
9
|
local newTSTLClassFromMetatable
|
|
10
|
+
local ____DefaultMap = require("classes.DefaultMap")
|
|
11
|
+
local DefaultMap = ____DefaultMap.DefaultMap
|
|
12
|
+
function ____exports.isVanillaTSTLClass(self, object)
|
|
13
|
+
return __TS__InstanceOf(object, Map) or __TS__InstanceOf(object, Set) or __TS__InstanceOf(object, WeakMap) or __TS__InstanceOf(object, WeakSet)
|
|
14
|
+
end
|
|
10
15
|
function newTSTLClassFromMetatable(self, metatable)
|
|
11
16
|
local newClass = {}
|
|
12
17
|
local newClassMetatable = setmetatable(newClass, metatable.constructor.prototype)
|
|
@@ -14,8 +19,11 @@ function newTSTLClassFromMetatable(self, metatable)
|
|
|
14
19
|
return newClass
|
|
15
20
|
end
|
|
16
21
|
local TSTL_CLASS_METATABLE_KEYS = __TS__New(Set, {"____constructor", "__index", "constructor"})
|
|
17
|
-
function ____exports.
|
|
18
|
-
|
|
22
|
+
function ____exports.isIsaacScriptCommonClass(self, object)
|
|
23
|
+
return __TS__InstanceOf(object, DefaultMap)
|
|
24
|
+
end
|
|
25
|
+
function ____exports.isUserDefinedTSTLClass(self, object)
|
|
26
|
+
if ____exports.isVanillaTSTLClass(nil, object) or ____exports.isIsaacScriptCommonClass(nil, object) then
|
|
19
27
|
return false
|
|
20
28
|
end
|
|
21
29
|
local objectType = type(object)
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
-
/// <reference types="typescript-to-lua/language-extensions" />
|
|
3
2
|
/**
|
|
4
3
|
* Helper function to get type safety on a switch statement.
|
|
5
4
|
*
|
|
@@ -74,7 +73,7 @@ export declare function getEnumValues<T>(transpiledEnum: T): Array<T[keyof T]>;
|
|
|
74
73
|
* Helper function to log what is happening in functions that recursively move through nested data
|
|
75
74
|
* structures.
|
|
76
75
|
*/
|
|
77
|
-
export declare function getTraversalDescription(key:
|
|
76
|
+
export declare function getTraversalDescription(key: unknown, traversalDescription: string): string;
|
|
78
77
|
/**
|
|
79
78
|
* Converts a hex string like "#33aa33" to a KColor object.
|
|
80
79
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -45,6 +45,7 @@ export * from "./functions/debug";
|
|
|
45
45
|
export { deepCopy } from "./functions/deepCopy";
|
|
46
46
|
export { deepCopyTests } from "./functions/deepCopyTests";
|
|
47
47
|
export * from "./functions/doors";
|
|
48
|
+
export * from "./functions/easing";
|
|
48
49
|
export * from "./functions/entity";
|
|
49
50
|
export * from "./functions/entitySpecific";
|
|
50
51
|
export * from "./functions/familiars";
|
package/dist/index.lua
CHANGED
|
@@ -363,6 +363,14 @@ do
|
|
|
363
363
|
end
|
|
364
364
|
end
|
|
365
365
|
end
|
|
366
|
+
do
|
|
367
|
+
local ____export = require("functions.easing")
|
|
368
|
+
for ____exportKey, ____exportValue in pairs(____export) do
|
|
369
|
+
if ____exportKey ~= "default" then
|
|
370
|
+
____exports[____exportKey] = ____exportValue
|
|
371
|
+
end
|
|
372
|
+
end
|
|
373
|
+
end
|
|
366
374
|
do
|
|
367
375
|
local ____export = require("functions.entity")
|
|
368
376
|
for ____exportKey, ____exportValue in pairs(____export) do
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CopyableIsaacAPIClassType } from "../enums/private/CopyableIsaacAPIClassType";
|
|
2
2
|
import { SerializationBrand } from "../enums/private/SerializationBrand";
|
|
3
3
|
export declare const ISAAC_API_CLASS_TYPE_TO_BRAND: {
|
|
4
|
-
readonly [key in
|
|
4
|
+
readonly [key in CopyableIsaacAPIClassType]: SerializationBrand;
|
|
5
5
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
2
|
local ____exports = {}
|
|
3
|
-
local
|
|
4
|
-
local
|
|
3
|
+
local ____CopyableIsaacAPIClassType = require("enums.private.CopyableIsaacAPIClassType")
|
|
4
|
+
local CopyableIsaacAPIClassType = ____CopyableIsaacAPIClassType.CopyableIsaacAPIClassType
|
|
5
5
|
local ____SerializationBrand = require("enums.private.SerializationBrand")
|
|
6
6
|
local SerializationBrand = ____SerializationBrand.SerializationBrand
|
|
7
|
-
____exports.ISAAC_API_CLASS_TYPE_TO_BRAND = {[
|
|
7
|
+
____exports.ISAAC_API_CLASS_TYPE_TO_BRAND = {[CopyableIsaacAPIClassType.COLOR] = SerializationBrand.COLOR, [CopyableIsaacAPIClassType.KCOLOR] = SerializationBrand.KCOLOR, [CopyableIsaacAPIClassType.RNG] = SerializationBrand.RNG, [CopyableIsaacAPIClassType.VECTOR] = SerializationBrand.VECTOR}
|
|
8
8
|
return ____exports
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CopyableIsaacAPIClassType } from "../enums/private/CopyableIsaacAPIClassType";
|
|
2
2
|
import { SerializationType } from "../enums/SerializationType";
|
|
3
3
|
export declare const ISAAC_API_CLASS_TYPE_TO_COPY_FUNCTION: {
|
|
4
|
-
readonly [key in
|
|
4
|
+
readonly [key in CopyableIsaacAPIClassType]: (object: unknown, serializationType: SerializationType) => boolean;
|
|
5
5
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
2
|
local ____exports = {}
|
|
3
|
-
local
|
|
4
|
-
local
|
|
3
|
+
local ____CopyableIsaacAPIClassType = require("enums.private.CopyableIsaacAPIClassType")
|
|
4
|
+
local CopyableIsaacAPIClassType = ____CopyableIsaacAPIClassType.CopyableIsaacAPIClassType
|
|
5
5
|
local ____color = require("functions.color")
|
|
6
6
|
local copyColor = ____color.copyColor
|
|
7
7
|
local ____kColor = require("functions.kColor")
|
|
@@ -10,5 +10,5 @@ local ____rng = require("functions.rng")
|
|
|
10
10
|
local copyRNG = ____rng.copyRNG
|
|
11
11
|
local ____vector = require("functions.vector")
|
|
12
12
|
local copyVector = ____vector.copyVector
|
|
13
|
-
____exports.ISAAC_API_CLASS_TYPE_TO_COPY_FUNCTION = {[
|
|
13
|
+
____exports.ISAAC_API_CLASS_TYPE_TO_COPY_FUNCTION = {[CopyableIsaacAPIClassType.COLOR] = copyColor, [CopyableIsaacAPIClassType.KCOLOR] = copyKColor, [CopyableIsaacAPIClassType.RNG] = copyRNG, [CopyableIsaacAPIClassType.VECTOR] = copyVector}
|
|
14
14
|
return ____exports
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CopyableIsaacAPIClassType } from "../enums/private/CopyableIsaacAPIClassType";
|
|
2
2
|
export declare const SERIALIZED_ISAAC_API_CLASS_TYPE_TO_IDENTITY_FUNCTION: {
|
|
3
|
-
readonly [key in
|
|
3
|
+
readonly [key in CopyableIsaacAPIClassType]: (object: unknown) => boolean;
|
|
4
4
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
2
|
local ____exports = {}
|
|
3
|
-
local
|
|
4
|
-
local
|
|
3
|
+
local ____CopyableIsaacAPIClassType = require("enums.private.CopyableIsaacAPIClassType")
|
|
4
|
+
local CopyableIsaacAPIClassType = ____CopyableIsaacAPIClassType.CopyableIsaacAPIClassType
|
|
5
5
|
local ____color = require("functions.color")
|
|
6
6
|
local isSerializedColor = ____color.isSerializedColor
|
|
7
7
|
local ____kColor = require("functions.kColor")
|
|
@@ -10,5 +10,5 @@ local ____rng = require("functions.rng")
|
|
|
10
10
|
local isSerializedRNG = ____rng.isSerializedRNG
|
|
11
11
|
local ____vector = require("functions.vector")
|
|
12
12
|
local isSerializedVector = ____vector.isSerializedVector
|
|
13
|
-
____exports.SERIALIZED_ISAAC_API_CLASS_TYPE_TO_IDENTITY_FUNCTION = {[
|
|
13
|
+
____exports.SERIALIZED_ISAAC_API_CLASS_TYPE_TO_IDENTITY_FUNCTION = {[CopyableIsaacAPIClassType.COLOR] = isSerializedColor, [CopyableIsaacAPIClassType.KCOLOR] = isSerializedKColor, [CopyableIsaacAPIClassType.RNG] = isSerializedRNG, [CopyableIsaacAPIClassType.VECTOR] = isSerializedVector}
|
|
14
14
|
return ____exports
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { Primitive } from "../Primitive";
|
|
2
|
+
/**
|
|
3
|
+
* I don't know how to create a recursive type definition for only primitive values. For now, this
|
|
4
|
+
* is typed as "unknown", which provides no type safety.
|
|
5
|
+
*/
|
|
2
6
|
declare type Serializable = Primitive | unknown;
|
|
3
7
|
/**
|
|
4
8
|
* Each sub-object of save data has a string as a key, without arbitrary data as a value. However,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isaacscript-common",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.251",
|
|
4
4
|
"description": "Helper functions for IsaacScript mods",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"isaac",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
],
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"isaac-typescript-definitions": "^1.0.388",
|
|
29
|
-
"isaacscript-lint": "^1.0.
|
|
29
|
+
"isaacscript-lint": "^1.0.99",
|
|
30
30
|
"isaacscript-tsconfig": "^1.1.8",
|
|
31
31
|
"typedoc": "^0.22.13",
|
|
32
32
|
"typescript": "4.6.3",
|