isaacscript-common 5.0.3 → 5.1.2
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/functions/array.d.ts +1 -0
- package/functions/array.lua +1 -0
- package/functions/bitwise.d.ts +10 -2
- package/functions/bitwise.lua +21 -6
- package/functions/doors.d.ts +5 -0
- package/functions/doors.lua +8 -0
- package/functions/set.d.ts +1 -1
- package/functions/set.lua +1 -1
- package/objects/roomShapeToDoorSlotCoordinates.d.ts +4 -0
- package/objects/roomShapeToDoorSlotCoordinates.lua +84 -0
- package/package.json +1 -1
package/functions/array.d.ts
CHANGED
|
@@ -63,6 +63,7 @@ export declare function emptyArray<T>(array: T[]): void;
|
|
|
63
63
|
* For example, if this function is provided an array containing 1, 2, and 3, then it will return an
|
|
64
64
|
* array containing the following arrays:
|
|
65
65
|
*
|
|
66
|
+
* - [] (if `includeEmptyArray` is set to true)
|
|
66
67
|
* - [1]
|
|
67
68
|
* - [2]
|
|
68
69
|
* - [3]
|
package/functions/array.lua
CHANGED
package/functions/bitwise.d.ts
CHANGED
|
@@ -6,8 +6,16 @@
|
|
|
6
6
|
export declare function arrayToBitFlags<T extends BitFlag | BitFlag128>(array: T[] | readonly T[]): BitFlags<T>;
|
|
7
7
|
/** Helper function to convert an array of bits to the resulting decimal number. */
|
|
8
8
|
export declare function convertBinaryToDecimal(bits: int[]): number;
|
|
9
|
-
/**
|
|
10
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Helper function to convert a number to an array of bits.
|
|
11
|
+
*
|
|
12
|
+
* @param number The number to convert.
|
|
13
|
+
* @param minLength Optional. Equal to the minimum amount of bits that should be returned. If the
|
|
14
|
+
* converted number of bits is below this number, 0's will be padded to the left
|
|
15
|
+
* side until the minimum length is met. Default is undefined (which will not cause
|
|
16
|
+
* any padding).
|
|
17
|
+
*/
|
|
18
|
+
export declare function convertDecimalToBinary(number: number, minLength?: int): int[];
|
|
11
19
|
/**
|
|
12
20
|
* Helper function to count the number of bits that are set to 1 in a binary representation of a
|
|
13
21
|
* number.
|
package/functions/bitwise.lua
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
2
|
local __TS__ParseInt = ____lualib.__TS__ParseInt
|
|
3
|
+
local __TS__NumberToString = ____lualib.__TS__NumberToString
|
|
3
4
|
local __TS__Iterator = ____lualib.__TS__Iterator
|
|
5
|
+
local __TS__ArrayUnshift = ____lualib.__TS__ArrayUnshift
|
|
4
6
|
local ____exports = {}
|
|
5
7
|
local ____flag = require("functions.flag")
|
|
6
8
|
local addFlag = ____flag.addFlag
|
|
@@ -18,13 +20,26 @@ function ____exports.convertBinaryToDecimal(self, bits)
|
|
|
18
20
|
return __TS__ParseInt(bitsString, 2)
|
|
19
21
|
end
|
|
20
22
|
--- Helper function to convert a number to an array of bits.
|
|
21
|
-
|
|
23
|
+
--
|
|
24
|
+
-- @param number The number to convert.
|
|
25
|
+
-- @param minLength Optional. Equal to the minimum amount of bits that should be returned. If the
|
|
26
|
+
-- converted number of bits is below this number, 0's will be padded to the left
|
|
27
|
+
-- side until the minimum length is met. Default is undefined (which will not cause
|
|
28
|
+
-- any padding).
|
|
29
|
+
function ____exports.convertDecimalToBinary(self, number, minLength)
|
|
22
30
|
local bits = {}
|
|
23
|
-
local
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
31
|
+
local bitsString = __TS__NumberToString(number, 2)
|
|
32
|
+
for ____, bitString in __TS__Iterator(bitsString) do
|
|
33
|
+
local bit = tonumber(bitString)
|
|
34
|
+
if bit == nil then
|
|
35
|
+
error("Failed to convert the following number to binary: " .. tostring(number))
|
|
36
|
+
end
|
|
37
|
+
bits[#bits + 1] = bit
|
|
38
|
+
end
|
|
39
|
+
if minLength ~= nil then
|
|
40
|
+
while #bits < minLength do
|
|
41
|
+
__TS__ArrayUnshift(bits, 0)
|
|
42
|
+
end
|
|
28
43
|
end
|
|
29
44
|
return bits
|
|
30
45
|
end
|
package/functions/doors.d.ts
CHANGED
|
@@ -53,6 +53,11 @@ export declare function getDoors(...roomTypes: RoomType[]): GridEntityDoor[];
|
|
|
53
53
|
export declare function getDoorsToRoomIndex(...roomGridIndex: int[]): GridEntityDoor[];
|
|
54
54
|
export declare function getOppositeDoorSlot(doorSlot: DoorSlot): DoorSlot | undefined;
|
|
55
55
|
export declare function getRepentanceDoor(): GridEntityDoor | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Helper function to get the room grid coordinates for a specific room shape and door slot
|
|
58
|
+
* combination.
|
|
59
|
+
*/
|
|
60
|
+
export declare function getRoomShapeDoorSlotCoordinates(roomShape: RoomShape, doorSlot: DoorSlot): readonly [x: int, y: int] | undefined;
|
|
56
61
|
/** Helper function to find unused door slots in the room that can be used to make custom doors. */
|
|
57
62
|
export declare function getUnusedDoorSlots(): DoorSlot[];
|
|
58
63
|
export declare function isAngelRoomDoor(door: GridEntityDoor): boolean;
|
package/functions/doors.lua
CHANGED
|
@@ -24,6 +24,8 @@ local ____doorSlotToDoorSlotFlag = require("objects.doorSlotToDoorSlotFlag")
|
|
|
24
24
|
local DOOR_SLOT_TO_DOOR_SLOT_FLAG = ____doorSlotToDoorSlotFlag.DOOR_SLOT_TO_DOOR_SLOT_FLAG
|
|
25
25
|
local ____oppositeDoorSlots = require("objects.oppositeDoorSlots")
|
|
26
26
|
local OPPOSITE_DOOR_SLOTS = ____oppositeDoorSlots.OPPOSITE_DOOR_SLOTS
|
|
27
|
+
local ____roomShapeToDoorSlotCoordinates = require("objects.roomShapeToDoorSlotCoordinates")
|
|
28
|
+
local ROOM_SHAPE_TO_DOOR_SLOT_COORDINATES = ____roomShapeToDoorSlotCoordinates.ROOM_SHAPE_TO_DOOR_SLOT_COORDINATES
|
|
27
29
|
local ____roomShapeToDoorSlots = require("objects.roomShapeToDoorSlots")
|
|
28
30
|
local ROOM_SHAPE_TO_DOOR_SLOTS = ____roomShapeToDoorSlots.ROOM_SHAPE_TO_DOOR_SLOTS
|
|
29
31
|
local ____bitwise = require("functions.bitwise")
|
|
@@ -190,6 +192,12 @@ function ____exports.getRepentanceDoor(self)
|
|
|
190
192
|
function(____, door) return ____exports.isRepentanceDoor(nil, door) end
|
|
191
193
|
)
|
|
192
194
|
end
|
|
195
|
+
--- Helper function to get the room grid coordinates for a specific room shape and door slot
|
|
196
|
+
-- combination.
|
|
197
|
+
function ____exports.getRoomShapeDoorSlotCoordinates(self, roomShape, doorSlot)
|
|
198
|
+
local coordinatesMap = ROOM_SHAPE_TO_DOOR_SLOT_COORDINATES[roomShape]
|
|
199
|
+
return coordinatesMap:get(doorSlot)
|
|
200
|
+
end
|
|
193
201
|
--- Helper function to find unused door slots in the room that can be used to make custom doors.
|
|
194
202
|
function ____exports.getUnusedDoorSlots(self)
|
|
195
203
|
local room = game:GetRoom()
|
package/functions/set.d.ts
CHANGED
|
@@ -38,7 +38,7 @@ export declare function getRandomSetElement<T>(set: Set<T> | ReadonlySet<T>, see
|
|
|
38
38
|
* For example, if this function is provided a set containing 1, 2, and 3, then it will return an
|
|
39
39
|
* array containing the following sets:
|
|
40
40
|
*
|
|
41
|
-
* - []
|
|
41
|
+
* - [] (if `includeEmptyArray` is set to true)
|
|
42
42
|
* - [1]
|
|
43
43
|
* - [2]
|
|
44
44
|
* - [3]
|
package/functions/set.lua
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import { DoorSlot, RoomShape } from "isaac-typescript-definitions";
|
|
1
2
|
/**
|
|
2
3
|
* The coordinates correspond to the x and y values that are present in a room's XML file.
|
|
3
4
|
*
|
|
4
5
|
* e.g. `<door exists="False" x="-1" y="3" />`
|
|
5
6
|
*/
|
|
7
|
+
export declare const ROOM_SHAPE_TO_DOOR_SLOT_COORDINATES: {
|
|
8
|
+
readonly [key in RoomShape]: ReadonlyMap<DoorSlot, [x: int, y: int]>;
|
|
9
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local Map = ____lualib.Map
|
|
3
|
+
local __TS__New = ____lualib.__TS__New
|
|
4
|
+
local ____exports = {}
|
|
5
|
+
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
|
|
6
|
+
local DoorSlot = ____isaac_2Dtypescript_2Ddefinitions.DoorSlot
|
|
7
|
+
local RoomShape = ____isaac_2Dtypescript_2Ddefinitions.RoomShape
|
|
8
|
+
--- The coordinates correspond to the x and y values that are present in a room's XML file.
|
|
9
|
+
--
|
|
10
|
+
-- e.g. `<door exists="False" x="-1" y="3" />`
|
|
11
|
+
____exports.ROOM_SHAPE_TO_DOOR_SLOT_COORDINATES = {
|
|
12
|
+
[RoomShape.SHAPE_1x1] = __TS__New(Map, {{DoorSlot.LEFT_0, {-1, 3}}, {DoorSlot.UP_0, {6, -1}}, {DoorSlot.RIGHT_0, {13, 3}}, {DoorSlot.DOWN_0, {6, 7}}}),
|
|
13
|
+
[RoomShape.IH] = __TS__New(Map, {{DoorSlot.LEFT_0, {-1, 3}}, {DoorSlot.RIGHT_0, {13, 3}}}),
|
|
14
|
+
[RoomShape.IV] = __TS__New(Map, {{DoorSlot.UP_0, {6, -1}}, {DoorSlot.DOWN_0, {6, 7}}}),
|
|
15
|
+
[RoomShape.SHAPE_1x2] = __TS__New(Map, {
|
|
16
|
+
{DoorSlot.LEFT_0, {-1, 3}},
|
|
17
|
+
{DoorSlot.UP_0, {6, -1}},
|
|
18
|
+
{DoorSlot.RIGHT_0, {13, 3}},
|
|
19
|
+
{DoorSlot.DOWN_0, {6, 14}},
|
|
20
|
+
{DoorSlot.LEFT_1, {-1, 10}},
|
|
21
|
+
{DoorSlot.RIGHT_1, {13, 10}}
|
|
22
|
+
}),
|
|
23
|
+
[RoomShape.IIV] = __TS__New(Map, {{DoorSlot.UP_0, {6, -1}}, {DoorSlot.DOWN_0, {6, 14}}}),
|
|
24
|
+
[RoomShape.SHAPE_2x1] = __TS__New(Map, {
|
|
25
|
+
{DoorSlot.LEFT_0, {-1, 3}},
|
|
26
|
+
{DoorSlot.UP_0, {6, -1}},
|
|
27
|
+
{DoorSlot.RIGHT_0, {26, 3}},
|
|
28
|
+
{DoorSlot.DOWN_0, {6, 7}},
|
|
29
|
+
{DoorSlot.UP_1, {19, -1}},
|
|
30
|
+
{DoorSlot.DOWN_1, {19, 7}}
|
|
31
|
+
}),
|
|
32
|
+
[RoomShape.IIH] = __TS__New(Map, {{DoorSlot.LEFT_0, {-1, 3}}, {DoorSlot.RIGHT_0, {26, 3}}}),
|
|
33
|
+
[RoomShape.SHAPE_2x2] = __TS__New(Map, {
|
|
34
|
+
{DoorSlot.LEFT_0, {-1, 3}},
|
|
35
|
+
{DoorSlot.UP_0, {6, -1}},
|
|
36
|
+
{DoorSlot.RIGHT_0, {26, 3}},
|
|
37
|
+
{DoorSlot.DOWN_0, {6, 14}},
|
|
38
|
+
{DoorSlot.LEFT_1, {-1, 10}},
|
|
39
|
+
{DoorSlot.UP_1, {19, -1}},
|
|
40
|
+
{DoorSlot.RIGHT_1, {26, 10}},
|
|
41
|
+
{DoorSlot.DOWN_1, {19, 14}}
|
|
42
|
+
}),
|
|
43
|
+
[RoomShape.LTL] = __TS__New(Map, {
|
|
44
|
+
{DoorSlot.LEFT_0, {12, 3}},
|
|
45
|
+
{DoorSlot.UP_0, {6, 6}},
|
|
46
|
+
{DoorSlot.RIGHT_0, {26, 3}},
|
|
47
|
+
{DoorSlot.DOWN_0, {6, 14}},
|
|
48
|
+
{DoorSlot.LEFT_1, {-1, 10}},
|
|
49
|
+
{DoorSlot.UP_1, {19, -1}},
|
|
50
|
+
{DoorSlot.RIGHT_1, {26, 10}},
|
|
51
|
+
{DoorSlot.DOWN_1, {19, 14}}
|
|
52
|
+
}),
|
|
53
|
+
[RoomShape.LTR] = __TS__New(Map, {
|
|
54
|
+
{DoorSlot.LEFT_0, {-1, 3}},
|
|
55
|
+
{DoorSlot.UP_0, {6, -1}},
|
|
56
|
+
{DoorSlot.RIGHT_0, {13, 3}},
|
|
57
|
+
{DoorSlot.DOWN_0, {6, 14}},
|
|
58
|
+
{DoorSlot.LEFT_1, {-1, 10}},
|
|
59
|
+
{DoorSlot.UP_1, {19, 6}},
|
|
60
|
+
{DoorSlot.RIGHT_1, {26, 10}},
|
|
61
|
+
{DoorSlot.DOWN_1, {19, 14}}
|
|
62
|
+
}),
|
|
63
|
+
[RoomShape.LBL] = __TS__New(Map, {
|
|
64
|
+
{DoorSlot.LEFT_0, {-1, 3}},
|
|
65
|
+
{DoorSlot.UP_0, {6, -1}},
|
|
66
|
+
{DoorSlot.RIGHT_0, {26, 3}},
|
|
67
|
+
{DoorSlot.DOWN_0, {6, 7}},
|
|
68
|
+
{DoorSlot.LEFT_1, {12, 10}},
|
|
69
|
+
{DoorSlot.UP_1, {19, -1}},
|
|
70
|
+
{DoorSlot.RIGHT_1, {26, 10}},
|
|
71
|
+
{DoorSlot.DOWN_1, {19, 14}}
|
|
72
|
+
}),
|
|
73
|
+
[RoomShape.LBR] = __TS__New(Map, {
|
|
74
|
+
{DoorSlot.LEFT_0, {-1, 3}},
|
|
75
|
+
{DoorSlot.UP_0, {6, -1}},
|
|
76
|
+
{DoorSlot.RIGHT_0, {26, 3}},
|
|
77
|
+
{DoorSlot.DOWN_0, {6, 14}},
|
|
78
|
+
{DoorSlot.LEFT_1, {-1, 10}},
|
|
79
|
+
{DoorSlot.UP_1, {19, -1}},
|
|
80
|
+
{DoorSlot.RIGHT_1, {13, 10}},
|
|
81
|
+
{DoorSlot.DOWN_1, {19, 7}}
|
|
82
|
+
})
|
|
83
|
+
}
|
|
84
|
+
return ____exports
|