isaacscript-common 1.2.219 → 1.2.222
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/SerializableIsaacAPIClassType.d.ts +7 -0
- package/dist/enums/private/SerializableIsaacAPIClassType.lua +8 -0
- package/dist/enums/private/SerializationBrand.d.ts +1 -0
- package/dist/enums/private/SerializationBrand.lua +1 -0
- package/dist/features/extraConsoleCommands/commands.lua +3 -2
- package/dist/features/saveDataManager/merge.d.ts +1 -0
- package/dist/features/saveDataManager/merge.lua +7 -19
- package/dist/functions/collectibles.d.ts +6 -2
- package/dist/functions/collectibles.lua +41 -2
- package/dist/functions/color.d.ts +9 -3
- package/dist/functions/color.lua +26 -15
- package/dist/functions/deepCopy.d.ts +1 -0
- package/dist/functions/deepCopy.lua +35 -34
- package/dist/functions/isaacAPIClass.d.ts +25 -0
- package/dist/functions/isaacAPIClass.lua +52 -0
- package/dist/functions/kColor.d.ts +30 -0
- package/dist/functions/kColor.lua +90 -0
- package/dist/functions/log.lua +3 -3
- package/dist/functions/rng.d.ts +6 -3
- package/dist/functions/rng.lua +7 -3
- package/dist/functions/roomData.d.ts +7 -0
- package/dist/functions/roomData.lua +10 -0
- package/dist/functions/rooms.d.ts +4 -0
- package/dist/functions/rooms.lua +32 -6
- package/dist/functions/serialization.d.ts +5 -0
- package/dist/functions/serialization.lua +115 -0
- package/dist/functions/sprite.d.ts +10 -0
- package/dist/functions/sprite.lua +32 -0
- package/dist/functions/table.d.ts +4 -4
- package/dist/functions/vector.d.ts +6 -3
- package/dist/functions/vector.lua +7 -3
- package/dist/index.d.ts +3 -1
- package/dist/index.lua +24 -8
- package/dist/types/private/IsaacAPIClass.d.ts +4 -0
- package/dist/types/private/IsaacAPIClass.lua +3 -0
- package/dist/types/private/SerializableIsaacAPIClass.d.ts +4 -0
- package/dist/types/private/SerializableIsaacAPIClass.lua +3 -0
- package/dist/types/private/SerializedIsaacAPIClass.d.ts +4 -0
- package/dist/types/private/SerializedIsaacAPIClass.lua +3 -0
- package/package.json +2 -2
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
|
+
local ____exports = {}
|
|
3
|
+
local OBJECT_NAME
|
|
4
|
+
local ____SerializationBrand = require("enums.private.SerializationBrand")
|
|
5
|
+
local SerializationBrand = ____SerializationBrand.SerializationBrand
|
|
6
|
+
local ____SerializationType = require("enums.SerializationType")
|
|
7
|
+
local SerializationType = ____SerializationType.SerializationType
|
|
8
|
+
local ____isaacAPIClass = require("functions.isaacAPIClass")
|
|
9
|
+
local isaacAPIClassEquals = ____isaacAPIClass.isaacAPIClassEquals
|
|
10
|
+
local isIsaacAPIClassOfType = ____isaacAPIClass.isIsaacAPIClassOfType
|
|
11
|
+
local ____table = require("functions.table")
|
|
12
|
+
local copyValuesToTable = ____table.copyValuesToTable
|
|
13
|
+
local getNumbersFromTable = ____table.getNumbersFromTable
|
|
14
|
+
local tableHasKeys = ____table.tableHasKeys
|
|
15
|
+
local ____utils = require("functions.utils")
|
|
16
|
+
local ensureAllCases = ____utils.ensureAllCases
|
|
17
|
+
function ____exports.isKColor(self, object)
|
|
18
|
+
return isIsaacAPIClassOfType(nil, object, OBJECT_NAME)
|
|
19
|
+
end
|
|
20
|
+
local KEYS = {"Red", "Green", "Blue", "Alpha"}
|
|
21
|
+
OBJECT_NAME = "KColor"
|
|
22
|
+
function ____exports.copyKColor(self, kColor, serializationType)
|
|
23
|
+
if serializationType == nil then
|
|
24
|
+
serializationType = SerializationType.NONE
|
|
25
|
+
end
|
|
26
|
+
repeat
|
|
27
|
+
local ____switch3 = serializationType
|
|
28
|
+
local ____cond3 = ____switch3 == SerializationType.NONE
|
|
29
|
+
if ____cond3 then
|
|
30
|
+
do
|
|
31
|
+
if not ____exports.isKColor(nil, kColor) then
|
|
32
|
+
error(((("Failed to copy a " .. OBJECT_NAME) .. " object since the provided object was not a userdata ") .. OBJECT_NAME) .. " class.")
|
|
33
|
+
end
|
|
34
|
+
return KColor(kColor.Red, kColor.Green, kColor.Blue, kColor.Alpha)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
____cond3 = ____cond3 or ____switch3 == SerializationType.SERIALIZE
|
|
38
|
+
if ____cond3 then
|
|
39
|
+
do
|
|
40
|
+
if not ____exports.isKColor(nil, kColor) then
|
|
41
|
+
error(((("Failed to serialize a " .. OBJECT_NAME) .. " object since the provided object was not a userdata ") .. OBJECT_NAME) .. " class.")
|
|
42
|
+
end
|
|
43
|
+
local kColorTable = {}
|
|
44
|
+
copyValuesToTable(nil, kColor, KEYS, kColorTable)
|
|
45
|
+
kColorTable[SerializationBrand.KCOLOR] = ""
|
|
46
|
+
return kColorTable
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
____cond3 = ____cond3 or ____switch3 == SerializationType.DESERIALIZE
|
|
50
|
+
if ____cond3 then
|
|
51
|
+
do
|
|
52
|
+
local kColorType = type(kColor)
|
|
53
|
+
if ____exports.isKColor(nil, kColor) or kColorType ~= "table" then
|
|
54
|
+
error(("Failed to deserialize a " .. OBJECT_NAME) .. " object since the provided object was not a Lua table.")
|
|
55
|
+
end
|
|
56
|
+
local r, g, b, a = table.unpack(getNumbersFromTable(
|
|
57
|
+
nil,
|
|
58
|
+
kColor,
|
|
59
|
+
OBJECT_NAME,
|
|
60
|
+
table.unpack(KEYS)
|
|
61
|
+
))
|
|
62
|
+
return KColor(r, g, b, a)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
do
|
|
66
|
+
do
|
|
67
|
+
return ensureAllCases(nil, serializationType)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
until true
|
|
71
|
+
end
|
|
72
|
+
function ____exports.getDefaultKColor(self)
|
|
73
|
+
return KColor(1, 1, 1, 1)
|
|
74
|
+
end
|
|
75
|
+
function ____exports.isSerializedKColor(self, object)
|
|
76
|
+
local objectType = type(object)
|
|
77
|
+
if objectType ~= "table" then
|
|
78
|
+
return false
|
|
79
|
+
end
|
|
80
|
+
local ____table = object
|
|
81
|
+
return tableHasKeys(
|
|
82
|
+
nil,
|
|
83
|
+
____table,
|
|
84
|
+
table.unpack(KEYS)
|
|
85
|
+
) and ____table[SerializationBrand.KCOLOR] ~= nil
|
|
86
|
+
end
|
|
87
|
+
function ____exports.kColorEquals(self, kColor1, kColor2)
|
|
88
|
+
return isaacAPIClassEquals(nil, kColor1, kColor2, KEYS)
|
|
89
|
+
end
|
|
90
|
+
return ____exports
|
package/dist/functions/log.lua
CHANGED
|
@@ -20,6 +20,8 @@ local ____flag = require("functions.flag")
|
|
|
20
20
|
local hasFlag = ____flag.hasFlag
|
|
21
21
|
local ____gridEntity = require("functions.gridEntity")
|
|
22
22
|
local getGridEntities = ____gridEntity.getGridEntities
|
|
23
|
+
local ____isaacAPIClass = require("functions.isaacAPIClass")
|
|
24
|
+
local getIsaacAPIClassType = ____isaacAPIClass.getIsaacAPIClassType
|
|
23
25
|
local ____math = require("functions.math")
|
|
24
26
|
local range = ____math.range
|
|
25
27
|
local ____player = require("functions.player")
|
|
@@ -35,8 +37,6 @@ local ____set = require("functions.set")
|
|
|
35
37
|
local getSortedSetValues = ____set.getSortedSetValues
|
|
36
38
|
local ____trinkets = require("functions.trinkets")
|
|
37
39
|
local getTrinketName = ____trinkets.getTrinketName
|
|
38
|
-
local ____userdata = require("functions.userdata")
|
|
39
|
-
local getUserdataType = ____userdata.getUserdataType
|
|
40
40
|
local ____utils = require("functions.utils")
|
|
41
41
|
local printConsole = ____utils.printConsole
|
|
42
42
|
function ____exports.getDebugPrependString(self, msg, numParentFunctions)
|
|
@@ -434,7 +434,7 @@ function ____exports.logUserdata(userdata)
|
|
|
434
434
|
____exports.log("Userdata: [no metatable]")
|
|
435
435
|
return
|
|
436
436
|
end
|
|
437
|
-
local classType =
|
|
437
|
+
local classType = getIsaacAPIClassType(nil, userdata)
|
|
438
438
|
if classType == nil then
|
|
439
439
|
____exports.log("Userdata: [no class type]")
|
|
440
440
|
else
|
package/dist/functions/rng.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
2
|
/// <reference types="typescript-to-lua/language-extensions" />
|
|
3
3
|
import { SerializationType } from "../enums/SerializationType";
|
|
4
|
-
declare type SerializedRNG = LuaTable<string,
|
|
4
|
+
declare type SerializedRNG = LuaTable<string, unknown> & {
|
|
5
|
+
__serializedRNGBrand: unknown;
|
|
6
|
+
};
|
|
5
7
|
interface CopyRNGReturn {
|
|
6
8
|
[SerializationType.NONE]: RNG;
|
|
7
9
|
[SerializationType.SERIALIZE]: SerializedRNG;
|
|
@@ -25,8 +27,8 @@ export declare function getRandomSeed(): Seed;
|
|
|
25
27
|
/** Helper function to check if something is an instantiated RNG object. */
|
|
26
28
|
export declare function isRNG(object: unknown): object is RNG;
|
|
27
29
|
/**
|
|
28
|
-
* Used to determine is the given table is a serialized
|
|
29
|
-
* and/or the `deepCopy` function.
|
|
30
|
+
* Used to determine is the given table is a serialized `RNG` object created by the save data
|
|
31
|
+
* manager and/or the `deepCopy` function.
|
|
30
32
|
*/
|
|
31
33
|
export declare function isSerializedRNG(object: unknown): object is SerializedRNG;
|
|
32
34
|
/**
|
|
@@ -35,6 +37,7 @@ export declare function isSerializedRNG(object: unknown): object is SerializedRN
|
|
|
35
37
|
* @param seed The seed to initialize it with. Default is `getRandomSeed()`.
|
|
36
38
|
*/
|
|
37
39
|
export declare function newRNG(seed?: Seed): RNG;
|
|
40
|
+
export declare function rngEquals(rng1: RNG, rng2: RNG): boolean;
|
|
38
41
|
/**
|
|
39
42
|
* Helper function to iterate over the provided object and set the seed for all of the values that
|
|
40
43
|
* are RNG objects equal to a particular seed.
|
package/dist/functions/rng.lua
CHANGED
|
@@ -8,11 +8,12 @@ local ____SerializationBrand = require("enums.private.SerializationBrand")
|
|
|
8
8
|
local SerializationBrand = ____SerializationBrand.SerializationBrand
|
|
9
9
|
local ____SerializationType = require("enums.SerializationType")
|
|
10
10
|
local SerializationType = ____SerializationType.SerializationType
|
|
11
|
+
local ____isaacAPIClass = require("functions.isaacAPIClass")
|
|
12
|
+
local isaacAPIClassEquals = ____isaacAPIClass.isaacAPIClassEquals
|
|
13
|
+
local isIsaacAPIClassOfType = ____isaacAPIClass.isIsaacAPIClassOfType
|
|
11
14
|
local ____table = require("functions.table")
|
|
12
15
|
local getNumbersFromTable = ____table.getNumbersFromTable
|
|
13
16
|
local tableHasKeys = ____table.tableHasKeys
|
|
14
|
-
local ____userdata = require("functions.userdata")
|
|
15
|
-
local isUserdataObject = ____userdata.isUserdataObject
|
|
16
17
|
local ____utils = require("functions.utils")
|
|
17
18
|
local ensureAllCases = ____utils.ensureAllCases
|
|
18
19
|
function ____exports.getRandomSeed(self)
|
|
@@ -21,7 +22,7 @@ function ____exports.getRandomSeed(self)
|
|
|
21
22
|
return safeRandomNumber
|
|
22
23
|
end
|
|
23
24
|
function ____exports.isRNG(self, object)
|
|
24
|
-
return
|
|
25
|
+
return isIsaacAPIClassOfType(nil, object, OBJECT_NAME)
|
|
25
26
|
end
|
|
26
27
|
function ____exports.newRNG(self, seed)
|
|
27
28
|
if seed == nil then
|
|
@@ -105,6 +106,9 @@ function ____exports.isSerializedRNG(self, object)
|
|
|
105
106
|
table.unpack(KEYS)
|
|
106
107
|
) and ____table[SerializationBrand.RNG] ~= nil
|
|
107
108
|
end
|
|
109
|
+
function ____exports.rngEquals(self, rng1, rng2)
|
|
110
|
+
return isaacAPIClassEquals(nil, rng1, rng2, KEYS)
|
|
111
|
+
end
|
|
108
112
|
function ____exports.setAllRNGToSeed(self, object, seed)
|
|
109
113
|
local objectType = type(object)
|
|
110
114
|
if objectType ~= "table" then
|
|
@@ -56,6 +56,13 @@ export declare function getRoomListIndex(roomGridIndex?: int): int;
|
|
|
56
56
|
* @returns The room name. Returns "Unknown" if the type was not found.
|
|
57
57
|
*/
|
|
58
58
|
export declare function getRoomName(roomGridIndex?: int): string;
|
|
59
|
+
/**
|
|
60
|
+
* Helper function to get the name of the room as it appears in the STB/XML data.
|
|
61
|
+
*
|
|
62
|
+
* @param roomGridIndex Optional. Default is the current room index.
|
|
63
|
+
* @returns The room name. Returns "Unknown" if the type was not found.
|
|
64
|
+
*/
|
|
65
|
+
export declare function getRoomShape(roomGridIndex?: int): RoomShape | undefined;
|
|
59
66
|
/**
|
|
60
67
|
* Helper function to get the stage ID for a room from the XML/STB data. The room stage ID will
|
|
61
68
|
* correspond to the first number in the filename of the XML/STB file. For example, a Depths room
|
|
@@ -61,6 +61,16 @@ function ____exports.getRoomName(self, roomGridIndex)
|
|
|
61
61
|
local roomData = ____exports.getRoomData(nil, roomGridIndex)
|
|
62
62
|
return roomData == nil and "Unknown" or roomData.Name
|
|
63
63
|
end
|
|
64
|
+
function ____exports.getRoomShape(self, roomGridIndex)
|
|
65
|
+
local roomData = ____exports.getRoomData(nil, roomGridIndex)
|
|
66
|
+
local ____temp_0
|
|
67
|
+
if roomData == nil then
|
|
68
|
+
____temp_0 = nil
|
|
69
|
+
else
|
|
70
|
+
____temp_0 = roomData.Shape
|
|
71
|
+
end
|
|
72
|
+
return ____temp_0
|
|
73
|
+
end
|
|
64
74
|
function ____exports.getRoomStageID(self, roomGridIndex)
|
|
65
75
|
local roomData = ____exports.getRoomData(nil, roomGridIndex)
|
|
66
76
|
return roomData == nil and -1 or roomData.StageID
|
|
@@ -114,6 +114,8 @@ export declare function inStartingRoom(): boolean;
|
|
|
114
114
|
* default.
|
|
115
115
|
*/
|
|
116
116
|
export declare function isAllRoomsClear(onlyCheckRoomTypes?: RoomType[]): boolean;
|
|
117
|
+
export declare function isDoorSlotValidAtGridIndex(doorSlot: DoorSlot, roomGridIndex: int): boolean;
|
|
118
|
+
export declare function isDoorSlotValidAtGridIndexForRedRoom(doorSlot: DoorSlot, roomGridIndex: int): boolean;
|
|
117
119
|
/**
|
|
118
120
|
* Helper function to detect if the provided room was created by the Red Key item. Under the hood,
|
|
119
121
|
* this checks for the `RoomDescriptorFlag.FLAG_RED_ROOM` flag.
|
|
@@ -128,6 +130,8 @@ export declare function isRedKeyRoom(roomGridIndex?: int): boolean;
|
|
|
128
130
|
* @param roomGridIndex Optional. Default is the current room index.
|
|
129
131
|
*/
|
|
130
132
|
export declare function isRoomInsideMap(roomGridIndex?: int): boolean;
|
|
133
|
+
/** Helper function to check if a room exists at the given room grid index. */
|
|
134
|
+
export declare function roomExists(roomGridIndex: int): boolean;
|
|
131
135
|
/**
|
|
132
136
|
* If the `Room.Update` method is called in a PostNewRoom callback, then some entities will slide
|
|
133
137
|
* around (such as the player). Since those entity velocities are already at zero, setting them to
|
package/dist/functions/rooms.lua
CHANGED
|
@@ -33,9 +33,11 @@ local setEntityPositions = ____positionVelocity.setEntityPositions
|
|
|
33
33
|
local setEntityVelocities = ____positionVelocity.setEntityVelocities
|
|
34
34
|
local ____roomData = require("functions.roomData")
|
|
35
35
|
local getCurrentRoomDescriptorReadOnly = ____roomData.getCurrentRoomDescriptorReadOnly
|
|
36
|
+
local getRoomAllowedDoors = ____roomData.getRoomAllowedDoors
|
|
36
37
|
local getRoomData = ____roomData.getRoomData
|
|
37
38
|
local getRoomDescriptor = ____roomData.getRoomDescriptor
|
|
38
39
|
local getRoomGridIndex = ____roomData.getRoomGridIndex
|
|
40
|
+
local getRoomShape = ____roomData.getRoomShape
|
|
39
41
|
local getRoomStageID = ____roomData.getRoomStageID
|
|
40
42
|
local getRoomSubType = ____roomData.getRoomSubType
|
|
41
43
|
function ____exports.getRooms(self, includeExtraDimensionalRooms)
|
|
@@ -75,6 +77,10 @@ function ____exports.inDeathCertificateArea(self)
|
|
|
75
77
|
local roomSubType = getRoomSubType(nil)
|
|
76
78
|
return roomStageID == 35 and (roomSubType == 33 or roomSubType == 34)
|
|
77
79
|
end
|
|
80
|
+
function ____exports.roomExists(self, roomGridIndex)
|
|
81
|
+
local roomData = getRoomData(nil, roomGridIndex)
|
|
82
|
+
return roomData ~= nil
|
|
83
|
+
end
|
|
78
84
|
function ____exports.changeRoom(self, roomGridIndex)
|
|
79
85
|
local level = game:GetLevel()
|
|
80
86
|
local roomData = getRoomData(nil, roomGridIndex)
|
|
@@ -97,11 +103,11 @@ function ____exports.getCurrentDimension(self)
|
|
|
97
103
|
return 2
|
|
98
104
|
end
|
|
99
105
|
local startingRoomGridIndex = level:GetStartingRoomIndex()
|
|
100
|
-
local
|
|
101
|
-
local startingRoomHash = GetPtrHash(
|
|
106
|
+
local startingRoomDescription = level:GetRoomByIdx(startingRoomGridIndex, -1)
|
|
107
|
+
local startingRoomHash = GetPtrHash(startingRoomDescription)
|
|
102
108
|
for ____, dimension in ipairs(range(nil, 0, NUM_DIMENSIONS - 1)) do
|
|
103
|
-
local
|
|
104
|
-
local dimensionRoomHash = GetPtrHash(
|
|
109
|
+
local dimensionRoomDescription = level:GetRoomByIdx(startingRoomGridIndex, dimension)
|
|
110
|
+
local dimensionRoomHash = GetPtrHash(dimensionRoomDescription)
|
|
105
111
|
if dimensionRoomHash == startingRoomHash then
|
|
106
112
|
return dimension
|
|
107
113
|
end
|
|
@@ -226,6 +232,26 @@ function ____exports.isAllRoomsClear(self, onlyCheckRoomTypes)
|
|
|
226
232
|
function(____, roomDescriptor) return roomDescriptor.Clear end
|
|
227
233
|
)
|
|
228
234
|
end
|
|
235
|
+
function ____exports.isDoorSlotValidAtGridIndex(self, doorSlot, roomGridIndex)
|
|
236
|
+
local allowedDoors = getRoomAllowedDoors(nil, roomGridIndex)
|
|
237
|
+
return allowedDoors:has(doorSlot)
|
|
238
|
+
end
|
|
239
|
+
function ____exports.isDoorSlotValidAtGridIndexForRedRoom(self, doorSlot, roomGridIndex)
|
|
240
|
+
local doorSlotValidAtGridIndex = ____exports.isDoorSlotValidAtGridIndex(nil, doorSlot, roomGridIndex)
|
|
241
|
+
if not doorSlotValidAtGridIndex then
|
|
242
|
+
return false
|
|
243
|
+
end
|
|
244
|
+
local roomShape = getRoomShape(nil, roomGridIndex)
|
|
245
|
+
if roomShape == nil then
|
|
246
|
+
return false
|
|
247
|
+
end
|
|
248
|
+
local delta = ____exports.getGridIndexDelta(nil, roomShape, doorSlot)
|
|
249
|
+
if delta == nil then
|
|
250
|
+
return false
|
|
251
|
+
end
|
|
252
|
+
local redRoomGridIndex = roomGridIndex + delta
|
|
253
|
+
return not ____exports.roomExists(nil, redRoomGridIndex)
|
|
254
|
+
end
|
|
229
255
|
function ____exports.isRedKeyRoom(self, roomGridIndex)
|
|
230
256
|
local roomDescriptor = getRoomDescriptor(nil, roomGridIndex)
|
|
231
257
|
return hasFlag(nil, roomDescriptor.Flags, 1024)
|
|
@@ -255,12 +281,12 @@ function ____exports.setRoomCleared(self)
|
|
|
255
281
|
for ____, door in ipairs(getDoors(nil)) do
|
|
256
282
|
do
|
|
257
283
|
if isHiddenSecretRoomDoor(nil, door) then
|
|
258
|
-
goto
|
|
284
|
+
goto __continue54
|
|
259
285
|
end
|
|
260
286
|
openDoorFast(nil, door)
|
|
261
287
|
door.ExtraVisible = false
|
|
262
288
|
end
|
|
263
|
-
::
|
|
289
|
+
::__continue54::
|
|
264
290
|
end
|
|
265
291
|
sfxManager:Stop(SoundEffect.SOUND_DOOR_HEAVY_OPEN)
|
|
266
292
|
game:ShakeScreen(0)
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { SerializationType } from "../enums/SerializationType";
|
|
2
|
+
import { SerializableIsaacAPIClass } from "../types/private/SerializableIsaacAPIClass";
|
|
3
|
+
import { SerializedIsaacAPIClass } from "../types/private/SerializedIsaacAPIClass";
|
|
4
|
+
export declare function copySerializableIsaacAPIClass(isaacAPIClassOrSerializedTable: SerializableIsaacAPIClass | SerializedIsaacAPIClass, serializationType: SerializationType): unknown;
|
|
5
|
+
export declare function isSerializedIsaacAPIClass(object: unknown): object is SerializedIsaacAPIClass;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
|
+
local ____exports = {}
|
|
3
|
+
local ____SerializableIsaacAPIClassType = require("enums.private.SerializableIsaacAPIClassType")
|
|
4
|
+
local SerializableIsaacAPIClassType = ____SerializableIsaacAPIClassType.SerializableIsaacAPIClassType
|
|
5
|
+
local ____color = require("functions.color")
|
|
6
|
+
local copyColor = ____color.copyColor
|
|
7
|
+
local isSerializedColor = ____color.isSerializedColor
|
|
8
|
+
local ____isaacAPIClass = require("functions.isaacAPIClass")
|
|
9
|
+
local getIsaacAPIClassType = ____isaacAPIClass.getIsaacAPIClassType
|
|
10
|
+
local ____kColor = require("functions.kColor")
|
|
11
|
+
local copyKColor = ____kColor.copyKColor
|
|
12
|
+
local isSerializedKColor = ____kColor.isSerializedKColor
|
|
13
|
+
local ____rng = require("functions.rng")
|
|
14
|
+
local copyRNG = ____rng.copyRNG
|
|
15
|
+
local isSerializedRNG = ____rng.isSerializedRNG
|
|
16
|
+
local ____utils = require("functions.utils")
|
|
17
|
+
local ensureAllCases = ____utils.ensureAllCases
|
|
18
|
+
local getEnumValues = ____utils.getEnumValues
|
|
19
|
+
local ____vector = require("functions.vector")
|
|
20
|
+
local copyVector = ____vector.copyVector
|
|
21
|
+
local isSerializedVector = ____vector.isSerializedVector
|
|
22
|
+
function ____exports.copySerializableIsaacAPIClass(self, isaacAPIClassOrSerializedTable, serializationType)
|
|
23
|
+
local isaacAPIClassType = getIsaacAPIClassType(nil, isaacAPIClassOrSerializedTable)
|
|
24
|
+
repeat
|
|
25
|
+
local ____switch3 = isaacAPIClassType
|
|
26
|
+
local ____cond3 = ____switch3 == SerializableIsaacAPIClassType.COLOR
|
|
27
|
+
if ____cond3 then
|
|
28
|
+
do
|
|
29
|
+
local color = isaacAPIClassOrSerializedTable
|
|
30
|
+
return copyColor(nil, color, serializationType)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
____cond3 = ____cond3 or ____switch3 == SerializableIsaacAPIClassType.KCOLOR
|
|
34
|
+
if ____cond3 then
|
|
35
|
+
do
|
|
36
|
+
local kColor = isaacAPIClassOrSerializedTable
|
|
37
|
+
return copyKColor(nil, kColor, serializationType)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
____cond3 = ____cond3 or ____switch3 == SerializableIsaacAPIClassType.RNG
|
|
41
|
+
if ____cond3 then
|
|
42
|
+
do
|
|
43
|
+
local rng = isaacAPIClassOrSerializedTable
|
|
44
|
+
return copyRNG(nil, rng)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
____cond3 = ____cond3 or ____switch3 == SerializableIsaacAPIClassType.VECTOR
|
|
48
|
+
if ____cond3 then
|
|
49
|
+
do
|
|
50
|
+
local vector = isaacAPIClassOrSerializedTable
|
|
51
|
+
return copyVector(nil, vector)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
do
|
|
55
|
+
do
|
|
56
|
+
return ensureAllCases(nil, isaacAPIClassType)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
until true
|
|
60
|
+
end
|
|
61
|
+
function ____exports.isSerializedIsaacAPIClass(self, object)
|
|
62
|
+
local objectType = type(object)
|
|
63
|
+
if objectType ~= "table" then
|
|
64
|
+
return false
|
|
65
|
+
end
|
|
66
|
+
local serializableIsaacAPIClassTypes = getEnumValues(nil, SerializableIsaacAPIClassType)
|
|
67
|
+
for ____, serializableIsaacAPIClassType in ipairs(serializableIsaacAPIClassTypes) do
|
|
68
|
+
repeat
|
|
69
|
+
local ____switch12 = serializableIsaacAPIClassType
|
|
70
|
+
local ____cond12 = ____switch12 == SerializableIsaacAPIClassType.COLOR
|
|
71
|
+
if ____cond12 then
|
|
72
|
+
do
|
|
73
|
+
if isSerializedColor(nil, object) then
|
|
74
|
+
return true
|
|
75
|
+
end
|
|
76
|
+
break
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
____cond12 = ____cond12 or ____switch12 == SerializableIsaacAPIClassType.KCOLOR
|
|
80
|
+
if ____cond12 then
|
|
81
|
+
do
|
|
82
|
+
if isSerializedKColor(nil, object) then
|
|
83
|
+
return true
|
|
84
|
+
end
|
|
85
|
+
break
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
____cond12 = ____cond12 or ____switch12 == SerializableIsaacAPIClassType.RNG
|
|
89
|
+
if ____cond12 then
|
|
90
|
+
do
|
|
91
|
+
if isSerializedRNG(nil, object) then
|
|
92
|
+
return true
|
|
93
|
+
end
|
|
94
|
+
break
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
____cond12 = ____cond12 or ____switch12 == SerializableIsaacAPIClassType.VECTOR
|
|
98
|
+
if ____cond12 then
|
|
99
|
+
do
|
|
100
|
+
if isSerializedVector(nil, object) then
|
|
101
|
+
return true
|
|
102
|
+
end
|
|
103
|
+
break
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
do
|
|
107
|
+
do
|
|
108
|
+
ensureAllCases(nil, serializableIsaacAPIClassType)
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
until true
|
|
112
|
+
end
|
|
113
|
+
return false
|
|
114
|
+
end
|
|
115
|
+
return ____exports
|
|
@@ -24,3 +24,13 @@ export declare function clearSprite(sprite: Sprite, ...layerIDs: int[]): void;
|
|
|
24
24
|
* as player animations.
|
|
25
25
|
*/
|
|
26
26
|
export declare function getFinalFrameOfAnimation(sprite: Sprite, animation?: string): int;
|
|
27
|
+
/**
|
|
28
|
+
* Helper function to check if two sprite layers have the same sprite sheet by using the
|
|
29
|
+
* `Sprite.GetTexel` method.
|
|
30
|
+
*
|
|
31
|
+
* Since checking every single texel in the entire sprite is very expensive, this function requires
|
|
32
|
+
* that you provide a range of specific texels to check.
|
|
33
|
+
*/
|
|
34
|
+
export declare function spriteEquals(sprite1: Sprite, sprite2: Sprite, layerID: int, xStart: int, xFinish: int, xIncrement: int, yStart: int, yFinish: int, yIncrement: int): boolean;
|
|
35
|
+
/** Helper function to check if two texels on a sprite are equivalent to each other. */
|
|
36
|
+
export declare function texelEquals(sprite1: Sprite, sprite2: Sprite, position: Vector, layerID: int): boolean;
|
|
@@ -2,8 +2,15 @@
|
|
|
2
2
|
local ____exports = {}
|
|
3
3
|
local ____constants = require("constants")
|
|
4
4
|
local EMPTY_PNG_PATH = ____constants.EMPTY_PNG_PATH
|
|
5
|
+
local ____kColor = require("functions.kColor")
|
|
6
|
+
local kColorEquals = ____kColor.kColorEquals
|
|
5
7
|
local ____math = require("functions.math")
|
|
6
8
|
local range = ____math.range
|
|
9
|
+
function ____exports.texelEquals(self, sprite1, sprite2, position, layerID)
|
|
10
|
+
local kColor1 = sprite1:GetTexel(position, Vector.Zero, 1, layerID)
|
|
11
|
+
local kColor2 = sprite2:GetTexel(position, Vector.Zero, 1, layerID)
|
|
12
|
+
return kColorEquals(nil, kColor1, kColor2)
|
|
13
|
+
end
|
|
7
14
|
function ____exports.clearSprite(self, sprite, ...)
|
|
8
15
|
local layerIDs = {...}
|
|
9
16
|
if #layerIDs == 0 then
|
|
@@ -29,4 +36,29 @@ function ____exports.getFinalFrameOfAnimation(self, sprite, animation)
|
|
|
29
36
|
sprite:SetFrame(currentFrame)
|
|
30
37
|
return finalFrame
|
|
31
38
|
end
|
|
39
|
+
function ____exports.spriteEquals(self, sprite1, sprite2, layerID, xStart, xFinish, xIncrement, yStart, yFinish, yIncrement)
|
|
40
|
+
do
|
|
41
|
+
local x = xStart
|
|
42
|
+
while x <= xFinish do
|
|
43
|
+
do
|
|
44
|
+
local y = yStart
|
|
45
|
+
while y <= yFinish do
|
|
46
|
+
local position = Vector(x, y)
|
|
47
|
+
if not ____exports.texelEquals(
|
|
48
|
+
nil,
|
|
49
|
+
sprite1,
|
|
50
|
+
sprite2,
|
|
51
|
+
position,
|
|
52
|
+
layerID
|
|
53
|
+
) then
|
|
54
|
+
return false
|
|
55
|
+
end
|
|
56
|
+
y = y + yIncrement
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
x = x + xIncrement
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
return true
|
|
63
|
+
end
|
|
32
64
|
return ____exports
|
|
@@ -5,28 +5,28 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export declare function clearTable(table: LuaTable): void;
|
|
7
7
|
/** Helper function to copy specific values from a object to a table. */
|
|
8
|
-
export declare function copyValuesToTable(object: unknown, keys: string[], table: LuaTable<string,
|
|
8
|
+
export declare function copyValuesToTable(object: unknown, keys: string[], table: LuaTable<string, unknown>): void;
|
|
9
9
|
/**
|
|
10
10
|
* Helper function to safely get boolean values from a Lua table. Will throw an error if the
|
|
11
11
|
* specific value does not exist on the table.
|
|
12
12
|
*
|
|
13
13
|
* This function is variadic, meaning that you can specify N arguments to get N values.
|
|
14
14
|
*/
|
|
15
|
-
export declare function getBooleansFromTable(table: LuaTable<string,
|
|
15
|
+
export declare function getBooleansFromTable(table: LuaTable<string, unknown>, objectName: string, ...keys: string[]): boolean[];
|
|
16
16
|
/**
|
|
17
17
|
* Helper function to safely get number values from a Lua table. Will throw an error if the specific
|
|
18
18
|
* value does not exist on the table or if it cannot be converted to a number.
|
|
19
19
|
*
|
|
20
20
|
* This function is variadic, meaning that you can specify N arguments to get N values.
|
|
21
21
|
*/
|
|
22
|
-
export declare function getNumbersFromTable(table: LuaTable<string,
|
|
22
|
+
export declare function getNumbersFromTable(table: LuaTable<string, unknown>, objectName: string, ...keys: string[]): number[];
|
|
23
23
|
/**
|
|
24
24
|
* Helper function to safely get string values from a Lua table. Will throw an error if the specific
|
|
25
25
|
* value does not exist on the table.
|
|
26
26
|
*
|
|
27
27
|
* This function is variadic, meaning that you can specify N arguments to get N values.
|
|
28
28
|
*/
|
|
29
|
-
export declare function getStringsFromTable(table: LuaTable<string,
|
|
29
|
+
export declare function getStringsFromTable(table: LuaTable<string, unknown>, objectName: string, ...keys: string[]): string[];
|
|
30
30
|
/**
|
|
31
31
|
* Helper function to check if a Lua table has all of the provided keys.
|
|
32
32
|
*
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
2
|
/// <reference types="typescript-to-lua/language-extensions" />
|
|
3
3
|
import { SerializationType } from "../enums/SerializationType";
|
|
4
|
-
declare type SerializedVector = LuaTable<string,
|
|
4
|
+
declare type SerializedVector = LuaTable<string, unknown> & {
|
|
5
|
+
__serializedVectorBrand: unknown;
|
|
6
|
+
};
|
|
5
7
|
interface CopyVectorReturn {
|
|
6
8
|
[SerializationType.NONE]: Vector;
|
|
7
9
|
[SerializationType.SERIALIZE]: SerializedVector;
|
|
@@ -28,12 +30,13 @@ export declare function getOneVector(): Vector;
|
|
|
28
30
|
*/
|
|
29
31
|
export declare function getZeroVector(): Vector;
|
|
30
32
|
/**
|
|
31
|
-
* Used to determine is the given table is a serialized Vector created by the save data
|
|
32
|
-
* and/or the `deepCopy` function.
|
|
33
|
+
* Used to determine is the given table is a serialized `Vector` object created by the save data
|
|
34
|
+
* manager and/or the `deepCopy` function.
|
|
33
35
|
*/
|
|
34
36
|
export declare function isSerializedVector(object: unknown): object is SerializedVector;
|
|
35
37
|
/** Helper function to check if something is an instantiated Vector object. */
|
|
36
38
|
export declare function isVector(object: unknown): object is Vector;
|
|
39
|
+
export declare function vectorEquals(vector1: Vector, vector2: Vector): boolean;
|
|
37
40
|
/** Helper function for finding out which way a vector is pointing. */
|
|
38
41
|
export declare function vectorToDirection(vector: Vector): Direction;
|
|
39
42
|
export {};
|
|
@@ -7,16 +7,17 @@ local ____SerializationType = require("enums.SerializationType")
|
|
|
7
7
|
local SerializationType = ____SerializationType.SerializationType
|
|
8
8
|
local ____directionToVector = require("objects.directionToVector")
|
|
9
9
|
local DIRECTION_TO_VECTOR = ____directionToVector.DIRECTION_TO_VECTOR
|
|
10
|
+
local ____isaacAPIClass = require("functions.isaacAPIClass")
|
|
11
|
+
local isaacAPIClassEquals = ____isaacAPIClass.isaacAPIClassEquals
|
|
12
|
+
local isIsaacAPIClassOfType = ____isaacAPIClass.isIsaacAPIClassOfType
|
|
10
13
|
local ____table = require("functions.table")
|
|
11
14
|
local copyValuesToTable = ____table.copyValuesToTable
|
|
12
15
|
local getNumbersFromTable = ____table.getNumbersFromTable
|
|
13
16
|
local tableHasKeys = ____table.tableHasKeys
|
|
14
|
-
local ____userdata = require("functions.userdata")
|
|
15
|
-
local isUserdataObject = ____userdata.isUserdataObject
|
|
16
17
|
local ____utils = require("functions.utils")
|
|
17
18
|
local ensureAllCases = ____utils.ensureAllCases
|
|
18
19
|
function ____exports.isVector(self, object)
|
|
19
|
-
return
|
|
20
|
+
return isIsaacAPIClassOfType(nil, object, OBJECT_NAME)
|
|
20
21
|
end
|
|
21
22
|
local KEYS = {"X", "Y"}
|
|
22
23
|
OBJECT_NAME = "Vector"
|
|
@@ -91,6 +92,9 @@ function ____exports.isSerializedVector(self, object)
|
|
|
91
92
|
table.unpack(KEYS)
|
|
92
93
|
) and ____table[SerializationBrand.VECTOR] ~= nil
|
|
93
94
|
end
|
|
95
|
+
function ____exports.vectorEquals(self, vector1, vector2)
|
|
96
|
+
return isaacAPIClassEquals(nil, vector1, vector2, KEYS)
|
|
97
|
+
end
|
|
94
98
|
function ____exports.vectorToDirection(self, vector)
|
|
95
99
|
local degrees = vector:GetAngleDegrees()
|
|
96
100
|
if degrees > -45 and degrees < 45 then
|
package/dist/index.d.ts
CHANGED
|
@@ -51,8 +51,10 @@ export * from "./functions/flying";
|
|
|
51
51
|
export * from "./functions/globals";
|
|
52
52
|
export * from "./functions/gridEntity";
|
|
53
53
|
export * from "./functions/input";
|
|
54
|
+
export * from "./functions/isaacAPIClass";
|
|
54
55
|
export * from "./functions/jsonHelpers";
|
|
55
56
|
export * from "./functions/jsonRoom";
|
|
57
|
+
export * from "./functions/kColor";
|
|
56
58
|
export * from "./functions/language";
|
|
57
59
|
export * from "./functions/log";
|
|
58
60
|
export * from "./functions/map";
|
|
@@ -74,6 +76,7 @@ export * from "./functions/roomData";
|
|
|
74
76
|
export * from "./functions/rooms";
|
|
75
77
|
export * from "./functions/run";
|
|
76
78
|
export * from "./functions/seeds";
|
|
79
|
+
export * from "./functions/serialization";
|
|
77
80
|
export * from "./functions/set";
|
|
78
81
|
export * from "./functions/sound";
|
|
79
82
|
export * from "./functions/spawnCollectible";
|
|
@@ -88,7 +91,6 @@ export * from "./functions/trinketGive";
|
|
|
88
91
|
export * from "./functions/trinkets";
|
|
89
92
|
export * from "./functions/trinketSet";
|
|
90
93
|
export * from "./functions/ui";
|
|
91
|
-
export * from "./functions/userdata";
|
|
92
94
|
export * from "./functions/utils";
|
|
93
95
|
export * from "./functions/vector";
|
|
94
96
|
export * from "./maps/cardMap";
|