isaacscript-common 1.2.246 → 1.2.249
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/SerializationBrand.d.ts +11 -1
- package/dist/enums/private/SerializationBrand.lua +0 -1
- package/dist/features/deployJSONRoom.lua +9 -6
- package/dist/features/saveDataManager/merge.d.ts +1 -1
- package/dist/functions/deepCopy.d.ts +1 -1
- package/dist/functions/deepCopy.lua +15 -50
- package/dist/functions/easing.d.ts +30 -0
- package/dist/functions/easing.lua +116 -0
- package/dist/functions/tstlClass.d.ts +15 -0
- package/dist/functions/tstlClass.lua +48 -0
- package/dist/functions/utils.d.ts +2 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.lua +16 -0
- package/dist/types/private/TSTLClass.d.ts +4 -0
- package/dist/types/private/TSTLClass.lua +3 -0
- package/dist/types/private/TSTLClassMetatable.d.ts +3 -1
- package/package.json +1 -1
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
/// <reference types="typescript-to-lua/language-extensions" />
|
|
2
|
+
/**
|
|
3
|
+
* During serialization, we write an arbitrary string key to the object with a value of an empty
|
|
4
|
+
* string. This is used during deserialization to instantiate the correct type of object.
|
|
5
|
+
*
|
|
6
|
+
* Note that we do not bother branding TSTL classes because we have no way to invoke the proper
|
|
7
|
+
* constructor during deserialization.
|
|
8
|
+
*/
|
|
2
9
|
export declare enum SerializationBrand {
|
|
3
10
|
DEFAULT_MAP = "__TSTL_DEFAULT_MAP",
|
|
4
11
|
/**
|
|
5
12
|
* This is set to the value that represents the default value (instead of an empty string like the
|
|
6
13
|
* other brands are).
|
|
14
|
+
*
|
|
15
|
+
* Default maps that use a factory function are unserializable, but do not throw runtime errors
|
|
16
|
+
* because the merge function can derive the factory function from the already-instantiated
|
|
17
|
+
* object.
|
|
7
18
|
*/
|
|
8
19
|
DEFAULT_MAP_VALUE = "__TSTL_DEFAULT_MAP_VALUE",
|
|
9
20
|
MAP = "__TSTL_MAP",
|
|
10
21
|
SET = "__TSTL_SET",
|
|
11
|
-
CLASS = "__TSTL_CLASS",
|
|
12
22
|
OBJECT_WITH_NUMBER_KEYS = "__TSTL_OBJECT_WITH_NUMBER_KEYS",
|
|
13
23
|
COLOR = "__COLOR",
|
|
14
24
|
KCOLOR = "__KCOLOR",
|
|
@@ -9,7 +9,6 @@ ____exports.SerializationBrand.DEFAULT_MAP = "__TSTL_DEFAULT_MAP"
|
|
|
9
9
|
____exports.SerializationBrand.DEFAULT_MAP_VALUE = "__TSTL_DEFAULT_MAP_VALUE"
|
|
10
10
|
____exports.SerializationBrand.MAP = "__TSTL_MAP"
|
|
11
11
|
____exports.SerializationBrand.SET = "__TSTL_SET"
|
|
12
|
-
____exports.SerializationBrand.CLASS = "__TSTL_CLASS"
|
|
13
12
|
____exports.SerializationBrand.OBJECT_WITH_NUMBER_KEYS = "__TSTL_OBJECT_WITH_NUMBER_KEYS"
|
|
14
13
|
____exports.SerializationBrand.COLOR = "__COLOR"
|
|
15
14
|
____exports.SerializationBrand.KCOLOR = "__KCOLOR"
|
|
@@ -62,7 +62,10 @@ function setDecorationsInvisible(self)
|
|
|
62
62
|
for ____, gridIndex in ipairs(decorationGridIndexes) do
|
|
63
63
|
local gridEntity = room:GetGridEntity(gridIndex)
|
|
64
64
|
if gridEntity ~= nil then
|
|
65
|
-
|
|
65
|
+
local gridEntityType = gridEntity:GetType()
|
|
66
|
+
if gridEntityType == GridEntityType.GRID_DECORATION then
|
|
67
|
+
setGridEntityInvisible(nil, gridEntity)
|
|
68
|
+
end
|
|
66
69
|
end
|
|
67
70
|
end
|
|
68
71
|
end
|
|
@@ -102,10 +105,10 @@ function removeSpecificNPCs(self)
|
|
|
102
105
|
for ____, npc in ipairs(getNPCs(nil)) do
|
|
103
106
|
do
|
|
104
107
|
if NPC_TYPES_TO_NOT_REMOVE:has(npc.Type) then
|
|
105
|
-
goto
|
|
108
|
+
goto __continue25
|
|
106
109
|
end
|
|
107
110
|
if npc:HasEntityFlags(EntityFlag.FLAG_CHARM) or npc:HasEntityFlags(EntityFlag.FLAG_FRIENDLY) or npc:HasEntityFlags(EntityFlag.FLAG_PERSISTENT) then
|
|
108
|
-
goto
|
|
111
|
+
goto __continue25
|
|
109
112
|
end
|
|
110
113
|
npc:ClearEntityFlags(EntityFlag.FLAG_APPEAR)
|
|
111
114
|
npc:Remove()
|
|
@@ -114,7 +117,7 @@ function removeSpecificNPCs(self)
|
|
|
114
117
|
room:SetGridPath(gridIndex, 0)
|
|
115
118
|
end
|
|
116
119
|
end
|
|
117
|
-
::
|
|
120
|
+
::__continue25::
|
|
118
121
|
end
|
|
119
122
|
end
|
|
120
123
|
function fillRoomWithDecorations(self)
|
|
@@ -126,7 +129,7 @@ function fillRoomWithDecorations(self)
|
|
|
126
129
|
do
|
|
127
130
|
local existingGridEntity = room:GetGridEntity(gridIndex)
|
|
128
131
|
if existingGridEntity ~= nil then
|
|
129
|
-
goto
|
|
132
|
+
goto __continue31
|
|
130
133
|
end
|
|
131
134
|
local position = room:GetGridPosition(gridIndex)
|
|
132
135
|
local decoration = Isaac.GridSpawn(GridEntityType.GRID_DECORATION, 0, position)
|
|
@@ -135,7 +138,7 @@ function fillRoomWithDecorations(self)
|
|
|
135
138
|
end
|
|
136
139
|
__TS__ArrayPush(decorationGridIndexes, gridIndex)
|
|
137
140
|
end
|
|
138
|
-
::
|
|
141
|
+
::__continue31::
|
|
139
142
|
end
|
|
140
143
|
end
|
|
141
144
|
function spawnAllEntities(self, jsonRoom, rng, verbose)
|
|
@@ -21,4 +21,4 @@
|
|
|
21
21
|
* are no longer used in the code, or copy over old variables of a different type, which can cause
|
|
22
22
|
* run-time errors. In such cases, users will have to manually delete their save data.
|
|
23
23
|
*/
|
|
24
|
-
export declare function merge(oldObject: LuaTable | Map<AnyNotNil, unknown> | Set<AnyNotNil>, newTable: LuaTable, traversalDescription: string): void;
|
|
24
|
+
export declare function merge(oldObject: LuaTable<AnyNotNil, unknown> | Map<AnyNotNil, unknown> | Set<AnyNotNil>, newTable: LuaTable<AnyNotNil, unknown>, traversalDescription: string): void;
|
|
@@ -22,4 +22,4 @@ import { SerializationType } from "../enums/SerializationType";
|
|
|
22
22
|
* `SerializationType.NONE`.
|
|
23
23
|
* @param traversalDescription Used to track the current key that we are operating on.
|
|
24
24
|
*/
|
|
25
|
-
export declare function deepCopy(oldObject: LuaTable | Map<AnyNotNil, unknown> | Set<AnyNotNil>, serializationType?: SerializationType, traversalDescription?: string): LuaTable | Map<AnyNotNil, unknown> | Set<AnyNotNil>;
|
|
25
|
+
export declare function deepCopy(oldObject: LuaTable<AnyNotNil, unknown> | Map<AnyNotNil, unknown> | Set<AnyNotNil>, serializationType?: SerializationType, traversalDescription?: string): LuaTable<AnyNotNil, unknown> | Map<AnyNotNil, unknown> | Set<AnyNotNil>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
|
-
local Set = ____lualib.Set
|
|
3
|
-
local __TS__New = ____lualib.__TS__New
|
|
4
2
|
local Map = ____lualib.Map
|
|
5
3
|
local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
4
|
+
local Set = ____lualib.Set
|
|
5
|
+
local __TS__New = ____lualib.__TS__New
|
|
6
6
|
local __TS__Iterator = ____lualib.__TS__Iterator
|
|
7
7
|
local ____exports = {}
|
|
8
|
-
local
|
|
8
|
+
local checkMetatable, deepCopyValue, validateValue, getNewValue
|
|
9
9
|
local ____DefaultMap = require("classes.DefaultMap")
|
|
10
10
|
local DefaultMap = ____DefaultMap.DefaultMap
|
|
11
11
|
local ____SerializationBrand = require("enums.private.SerializationBrand")
|
|
@@ -22,6 +22,9 @@ local copyIsaacAPIClass = ____serialization.copyIsaacAPIClass
|
|
|
22
22
|
local deserializeIsaacAPIClass = ____serialization.deserializeIsaacAPIClass
|
|
23
23
|
local isSerializableIsaacAPIClass = ____serialization.isSerializableIsaacAPIClass
|
|
24
24
|
local isSerializedIsaacAPIClass = ____serialization.isSerializedIsaacAPIClass
|
|
25
|
+
local ____tstlClass = require("functions.tstlClass")
|
|
26
|
+
local isTSTLClass = ____tstlClass.isTSTLClass
|
|
27
|
+
local newTSTLClass = ____tstlClass.newTSTLClass
|
|
25
28
|
local ____utils = require("functions.utils")
|
|
26
29
|
local getTraversalDescription = ____utils.getTraversalDescription
|
|
27
30
|
function ____exports.deepCopy(self, oldObject, serializationType, traversalDescription)
|
|
@@ -49,13 +52,11 @@ function ____exports.deepCopy(self, oldObject, serializationType, traversalDescr
|
|
|
49
52
|
local hasTSTLDefaultMapBrand = false
|
|
50
53
|
local hasTSTLMapBrand = false
|
|
51
54
|
local hasTSTLSetBrand = false
|
|
52
|
-
local hasTSTLClassBrand = false
|
|
53
55
|
if not __TS__InstanceOf(oldObject, Map) and not __TS__InstanceOf(oldObject, Set) and not isClass then
|
|
54
56
|
checkMetatable(nil, oldTable, traversalDescription)
|
|
55
57
|
hasTSTLDefaultMapBrand = oldTable[SerializationBrand.DEFAULT_MAP] ~= nil
|
|
56
58
|
hasTSTLMapBrand = oldTable[SerializationBrand.MAP] ~= nil
|
|
57
59
|
hasTSTLSetBrand = oldTable[SerializationBrand.SET] ~= nil
|
|
58
|
-
hasTSTLClassBrand = oldTable[SerializationBrand.CLASS] ~= nil
|
|
59
60
|
end
|
|
60
61
|
local newObject
|
|
61
62
|
if serializationType == SerializationType.NONE and __TS__InstanceOf(oldObject, DefaultMap) then
|
|
@@ -73,8 +74,9 @@ function ____exports.deepCopy(self, oldObject, serializationType, traversalDescr
|
|
|
73
74
|
newObject = __TS__New(Map)
|
|
74
75
|
elseif serializationType == SerializationType.NONE and __TS__InstanceOf(oldObject, Set) or serializationType == SerializationType.DESERIALIZE and hasTSTLSetBrand then
|
|
75
76
|
newObject = __TS__New(Set)
|
|
76
|
-
elseif serializationType == SerializationType.NONE and isClass
|
|
77
|
-
|
|
77
|
+
elseif serializationType == SerializationType.NONE and isClass then
|
|
78
|
+
local oldTSTLClass = oldObject
|
|
79
|
+
newObject = newTSTLClass(nil, oldTSTLClass)
|
|
78
80
|
else
|
|
79
81
|
newObject = {}
|
|
80
82
|
end
|
|
@@ -91,8 +93,6 @@ function ____exports.deepCopy(self, oldObject, serializationType, traversalDescr
|
|
|
91
93
|
newTable[SerializationBrand.MAP] = ""
|
|
92
94
|
elseif __TS__InstanceOf(oldObject, Set) then
|
|
93
95
|
newTable[SerializationBrand.SET] = ""
|
|
94
|
-
elseif isClass then
|
|
95
|
-
newTable[SerializationBrand.CLASS] = ""
|
|
96
96
|
end
|
|
97
97
|
end
|
|
98
98
|
if __TS__InstanceOf(oldObject, Map) then
|
|
@@ -101,7 +101,7 @@ function ____exports.deepCopy(self, oldObject, serializationType, traversalDescr
|
|
|
101
101
|
local value = ____value[2]
|
|
102
102
|
do
|
|
103
103
|
if isSerializationBrand(nil, key) then
|
|
104
|
-
goto
|
|
104
|
+
goto __continue22
|
|
105
105
|
end
|
|
106
106
|
deepCopyValue(
|
|
107
107
|
nil,
|
|
@@ -113,13 +113,13 @@ function ____exports.deepCopy(self, oldObject, serializationType, traversalDescr
|
|
|
113
113
|
serializationType
|
|
114
114
|
)
|
|
115
115
|
end
|
|
116
|
-
::
|
|
116
|
+
::__continue22::
|
|
117
117
|
end
|
|
118
118
|
elseif __TS__InstanceOf(oldObject, Set) then
|
|
119
119
|
for ____, key in __TS__Iterator(oldObject:values()) do
|
|
120
120
|
do
|
|
121
121
|
if isSerializationBrand(nil, key) then
|
|
122
|
-
goto
|
|
122
|
+
goto __continue26
|
|
123
123
|
end
|
|
124
124
|
local value = ""
|
|
125
125
|
deepCopyValue(
|
|
@@ -132,13 +132,13 @@ function ____exports.deepCopy(self, oldObject, serializationType, traversalDescr
|
|
|
132
132
|
serializationType
|
|
133
133
|
)
|
|
134
134
|
end
|
|
135
|
-
::
|
|
135
|
+
::__continue26::
|
|
136
136
|
end
|
|
137
137
|
else
|
|
138
138
|
for key, value in pairs(oldObject) do
|
|
139
139
|
do
|
|
140
140
|
if isSerializationBrand(nil, key) then
|
|
141
|
-
goto
|
|
141
|
+
goto __continue30
|
|
142
142
|
end
|
|
143
143
|
deepCopyValue(
|
|
144
144
|
nil,
|
|
@@ -150,31 +150,11 @@ function ____exports.deepCopy(self, oldObject, serializationType, traversalDescr
|
|
|
150
150
|
serializationType
|
|
151
151
|
)
|
|
152
152
|
end
|
|
153
|
-
::
|
|
153
|
+
::__continue30::
|
|
154
154
|
end
|
|
155
155
|
end
|
|
156
156
|
return newObject
|
|
157
157
|
end
|
|
158
|
-
function isTSTLClass(self, object)
|
|
159
|
-
local metatable = getmetatable(object)
|
|
160
|
-
if metatable == nil then
|
|
161
|
-
return false
|
|
162
|
-
end
|
|
163
|
-
if __TS__InstanceOf(object, Map) or __TS__InstanceOf(object, Set) then
|
|
164
|
-
return false
|
|
165
|
-
end
|
|
166
|
-
local numKeys = 0
|
|
167
|
-
for key in pairs(metatable) do
|
|
168
|
-
numKeys = numKeys + 1
|
|
169
|
-
if type(key) ~= "string" then
|
|
170
|
-
return false
|
|
171
|
-
end
|
|
172
|
-
if not TSTL_CLASS_KEYS:has(key) then
|
|
173
|
-
return false
|
|
174
|
-
end
|
|
175
|
-
end
|
|
176
|
-
return numKeys == TSTL_CLASS_KEYS.size
|
|
177
|
-
end
|
|
178
158
|
function checkMetatable(self, ____table, traversalDescription)
|
|
179
159
|
local metatable = getmetatable(____table)
|
|
180
160
|
if metatable == nil then
|
|
@@ -183,20 +163,6 @@ function checkMetatable(self, ____table, traversalDescription)
|
|
|
183
163
|
local tableDescription = traversalDescription == "" and "the table to copy" or ("\"" .. traversalDescription) .. "\""
|
|
184
164
|
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. Vectors, TypeScriptToLua Maps, etc.)")
|
|
185
165
|
end
|
|
186
|
-
function copyClass(self, oldClass)
|
|
187
|
-
local metatable = getmetatable(oldClass)
|
|
188
|
-
local newClass = getNewClassFromMetatable(nil, metatable)
|
|
189
|
-
for key, value in pairs(oldClass) do
|
|
190
|
-
newClass[key] = value
|
|
191
|
-
end
|
|
192
|
-
return newClass
|
|
193
|
-
end
|
|
194
|
-
function getNewClassFromMetatable(self, metatable)
|
|
195
|
-
local instance = setmetatable({}, metatable.constructor.prototype)
|
|
196
|
-
local newClass = instance
|
|
197
|
-
newClass:____constructor()
|
|
198
|
-
return newClass
|
|
199
|
-
end
|
|
200
166
|
function deepCopyValue(self, oldObject, newObject, key, value, traversalDescription, serializationType)
|
|
201
167
|
local valueType = type(value)
|
|
202
168
|
validateValue(nil, value, valueType, traversalDescription)
|
|
@@ -249,5 +215,4 @@ function getNewValue(self, key, value, traversalDescription, serializationType)
|
|
|
249
215
|
end
|
|
250
216
|
return value
|
|
251
217
|
end
|
|
252
|
-
TSTL_CLASS_KEYS = __TS__New(Set, {"____constructor", "__index", "constructor"})
|
|
253
218
|
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
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TSTLClass } from "../types/private/TSTLClass";
|
|
2
|
+
/**
|
|
3
|
+
* TypeScriptToLua classes are Lua tables that have a metatable with a certain amount of keys.
|
|
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.
|
|
7
|
+
*/
|
|
8
|
+
export declare function isTSTLClass(object: unknown): object is TSTLClass;
|
|
9
|
+
/**
|
|
10
|
+
* Initializes a new TypeScriptToLua class in the situation where you do not know what kind of class
|
|
11
|
+
* it is. This function requires that you provide an instantiated class of the same type, as it will
|
|
12
|
+
* use the class constructor that is present on the other object's metatable to initialize the new
|
|
13
|
+
* class.
|
|
14
|
+
*/
|
|
15
|
+
export declare function newTSTLClass(oldClass: TSTLClass): TSTLClass;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local Set = ____lualib.Set
|
|
3
|
+
local __TS__New = ____lualib.__TS__New
|
|
4
|
+
local Map = ____lualib.Map
|
|
5
|
+
local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
6
|
+
local WeakMap = ____lualib.WeakMap
|
|
7
|
+
local WeakSet = ____lualib.WeakSet
|
|
8
|
+
local ____exports = {}
|
|
9
|
+
local newTSTLClassFromMetatable
|
|
10
|
+
function newTSTLClassFromMetatable(self, metatable)
|
|
11
|
+
local newClass = {}
|
|
12
|
+
local newClassMetatable = setmetatable(newClass, metatable.constructor.prototype)
|
|
13
|
+
newClassMetatable:____constructor()
|
|
14
|
+
return newClass
|
|
15
|
+
end
|
|
16
|
+
local TSTL_CLASS_METATABLE_KEYS = __TS__New(Set, {"____constructor", "__index", "constructor"})
|
|
17
|
+
function ____exports.isTSTLClass(self, object)
|
|
18
|
+
if __TS__InstanceOf(object, Map) or __TS__InstanceOf(object, Set) or __TS__InstanceOf(object, WeakMap) or __TS__InstanceOf(object, WeakSet) then
|
|
19
|
+
return false
|
|
20
|
+
end
|
|
21
|
+
local objectType = type(object)
|
|
22
|
+
if objectType ~= "table" then
|
|
23
|
+
return false
|
|
24
|
+
end
|
|
25
|
+
local metatable = getmetatable(object)
|
|
26
|
+
if metatable == nil then
|
|
27
|
+
return false
|
|
28
|
+
end
|
|
29
|
+
local numKeys = 0
|
|
30
|
+
for key in pairs(metatable) do
|
|
31
|
+
numKeys = numKeys + 1
|
|
32
|
+
if type(key) ~= "string" then
|
|
33
|
+
return false
|
|
34
|
+
end
|
|
35
|
+
if not TSTL_CLASS_METATABLE_KEYS:has(key) then
|
|
36
|
+
return false
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
return numKeys == TSTL_CLASS_METATABLE_KEYS.size
|
|
40
|
+
end
|
|
41
|
+
function ____exports.newTSTLClass(self, oldClass)
|
|
42
|
+
local metatable = getmetatable(oldClass)
|
|
43
|
+
if metatable == nil then
|
|
44
|
+
error("Failed to instantiate a new TypeScriptToLua class since the provided old class does not have a metatable.")
|
|
45
|
+
end
|
|
46
|
+
return newTSTLClassFromMetatable(nil, metatable)
|
|
47
|
+
end
|
|
48
|
+
return ____exports
|
|
@@ -7,14 +7,14 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Example:
|
|
9
9
|
* ```ts
|
|
10
|
-
* enum
|
|
10
|
+
* enum Situation {
|
|
11
11
|
* ONE,
|
|
12
12
|
* TWO,
|
|
13
13
|
* THREE,
|
|
14
14
|
* // FOUR, // If we uncomment this line, the program will no longer compile
|
|
15
15
|
* }
|
|
16
16
|
*
|
|
17
|
-
* function
|
|
17
|
+
* function handleSituation(situation: Situation) {
|
|
18
18
|
* switch (situation) {
|
|
19
19
|
* case Situation.ONE: {
|
|
20
20
|
* return 41;
|
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";
|
|
@@ -94,6 +95,7 @@ export * from "./functions/trinketCacheFlag";
|
|
|
94
95
|
export * from "./functions/trinketGive";
|
|
95
96
|
export * from "./functions/trinkets";
|
|
96
97
|
export * from "./functions/trinketSet";
|
|
98
|
+
export * from "./functions/tstlClass";
|
|
97
99
|
export * from "./functions/ui";
|
|
98
100
|
export * from "./functions/utils";
|
|
99
101
|
export * from "./functions/vector";
|
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
|
|
@@ -752,6 +760,14 @@ do
|
|
|
752
760
|
end
|
|
753
761
|
end
|
|
754
762
|
end
|
|
763
|
+
do
|
|
764
|
+
local ____export = require("functions.tstlClass")
|
|
765
|
+
for ____exportKey, ____exportValue in pairs(____export) do
|
|
766
|
+
if ____exportKey ~= "default" then
|
|
767
|
+
____exports[____exportKey] = ____exportValue
|
|
768
|
+
end
|
|
769
|
+
end
|
|
770
|
+
end
|
|
755
771
|
do
|
|
756
772
|
local ____export = require("functions.ui")
|
|
757
773
|
for ____exportKey, ____exportValue in pairs(____export) do
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
/// <reference types="lua-types/5.3" />
|
|
2
|
+
/// <reference types="typescript-to-lua/language-extensions" />
|
|
1
3
|
export interface TSTLClassMetatable {
|
|
2
4
|
____constructor: () => void;
|
|
3
5
|
__index: unknown;
|
|
4
6
|
constructor: {
|
|
5
|
-
prototype: unknown
|
|
7
|
+
prototype: LuaMetatable<LuaTable<AnyNotNil, unknown>>;
|
|
6
8
|
name: string;
|
|
7
9
|
};
|
|
8
10
|
}
|