isaacscript-common 4.6.0 → 4.6.1
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 +30 -1
- package/functions/array.lua +84 -5
- package/functions/bitwise.d.ts +17 -0
- package/functions/bitwise.lua +41 -0
- package/functions/color.d.ts +1 -1
- package/functions/doors.d.ts +6 -0
- package/functions/doors.lua +23 -2
- package/functions/kColor.d.ts +1 -1
- package/functions/log.d.ts +2 -2
- package/functions/rng.d.ts +1 -1
- package/functions/roomShape.d.ts +2 -2
- package/functions/set.d.ts +17 -0
- package/functions/set.lua +24 -0
- package/functions/vector.d.ts +1 -1
- package/objects/doorSlotToDoorSlotFlag.d.ts +4 -0
- package/objects/doorSlotToDoorSlotFlag.lua +17 -0
- package/objects/roomShapeBounds.d.ts +1 -1
- package/objects/roomShapeBounds.lua +8 -8
- package/objects/roomShapeLayoutSizes.d.ts +1 -1
- package/objects/roomShapeLayoutSizes.lua +4 -4
- package/package.json +2 -2
- package/types/CollectibleIndex.d.ts +1 -1
- package/types/PlayerIndex.d.ts +1 -1
- package/types/private/IsaacAPIClass.d.ts +1 -1
- package/types/private/SerializedIsaacAPIClass.d.ts +1 -1
- package/types/private/TSTLClass.d.ts +1 -1
package/functions/array.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export declare function arrayRemoveIndex<T>(originalArray: T[] | readonly T[], .
|
|
|
37
37
|
* This function is variadic, meaning that you can specify N arguments to remove N elements.
|
|
38
38
|
*/
|
|
39
39
|
export declare function arrayRemoveIndexInPlace<T>(array: T[], ...indexesToRemove: int[]): boolean;
|
|
40
|
-
export declare function arrayToString<T>(array: T[]): string;
|
|
40
|
+
export declare function arrayToString<T>(array: T[] | readonly T[]): string;
|
|
41
41
|
/**
|
|
42
42
|
* Helper function to combine two or more arrays. Returns a new array that is the composition of all
|
|
43
43
|
* of the specified arrays.
|
|
@@ -56,6 +56,30 @@ export declare function combineArrays<T>(...arrays: Array<T[] | readonly T[]>):
|
|
|
56
56
|
export declare function copyArray<T>(oldArray: T[] | readonly T[], numElements?: int): T[];
|
|
57
57
|
/** Helper function to remove all of the elements in an array in-place. */
|
|
58
58
|
export declare function emptyArray<T>(array: T[]): void;
|
|
59
|
+
/**
|
|
60
|
+
* Helper function to get all possible combinations of the given array. This includes the
|
|
61
|
+
* combination of an empty array.
|
|
62
|
+
*
|
|
63
|
+
* For example, if this function is provided an array containing 1, 2, and 3, then it will return an
|
|
64
|
+
* array containing the following arrays:
|
|
65
|
+
*
|
|
66
|
+
* - []
|
|
67
|
+
* - [1]
|
|
68
|
+
* - [2]
|
|
69
|
+
* - [3]
|
|
70
|
+
* - [1, 2]
|
|
71
|
+
* - [1, 3]
|
|
72
|
+
* - [2, 3]
|
|
73
|
+
* - [1, 2, 3]
|
|
74
|
+
*
|
|
75
|
+
* From: https://github.com/firstandthird/combinations/blob/master/index.js
|
|
76
|
+
*
|
|
77
|
+
* @param array The array to get the combinations of.
|
|
78
|
+
* @param min Optional. The minimum number of elements to include in each combination. Default is 1.
|
|
79
|
+
* @param max Optional. The maximum number of elements to include in each combination. Default is
|
|
80
|
+
* the length of the array.
|
|
81
|
+
*/
|
|
82
|
+
export declare function getArrayCombinations<T>(array: T[] | readonly T[], min?: int, max?: int): ReadonlyArray<readonly T[]>;
|
|
59
83
|
/**
|
|
60
84
|
* Helper function to get an array containing the indexes of an array.
|
|
61
85
|
*
|
|
@@ -141,4 +165,9 @@ export declare function shuffleArray<T>(originalArray: T[] | readonly T[], seedO
|
|
|
141
165
|
* `RNG.Next` method will be called. Default is `getRandomSeed()`.
|
|
142
166
|
*/
|
|
143
167
|
export declare function shuffleArrayInPlace<T>(array: T[], seedOrRNG?: Seed | RNG): void;
|
|
168
|
+
/** Helper function to sum every value in an array together. */
|
|
144
169
|
export declare function sumArray(array: number[] | readonly number[]): number;
|
|
170
|
+
/**
|
|
171
|
+
* Helper function to swap two different array elements. (The elements will be swapped in-place.)
|
|
172
|
+
*/
|
|
173
|
+
export declare function swapArrayElements<T>(array: T[], i: number, j: number): void;
|
package/functions/array.lua
CHANGED
|
@@ -8,6 +8,9 @@ local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
|
|
|
8
8
|
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
|
|
9
9
|
local __TS__ArraySort = ____lualib.__TS__ArraySort
|
|
10
10
|
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
|
|
11
|
+
local __TS__ArraySlice = ____lualib.__TS__ArraySlice
|
|
12
|
+
local __TS__ArrayConcat = ____lualib.__TS__ArrayConcat
|
|
13
|
+
local __TS__ArrayUnshift = ____lualib.__TS__ArrayUnshift
|
|
11
14
|
local __TS__ObjectKeys = ____lualib.__TS__ObjectKeys
|
|
12
15
|
local __TS__ArraySome = ____lualib.__TS__ArraySome
|
|
13
16
|
local __TS__ArrayReduce = ____lualib.__TS__ArrayReduce
|
|
@@ -50,16 +53,20 @@ function ____exports.shuffleArrayInPlace(self, array, seedOrRNG)
|
|
|
50
53
|
seedOrRNG = getRandomSeed(nil)
|
|
51
54
|
end
|
|
52
55
|
local currentIndex = #array
|
|
53
|
-
local randomIndex
|
|
54
56
|
local rng = isRNG(nil, seedOrRNG) and seedOrRNG or newRNG(nil, seedOrRNG)
|
|
55
57
|
while currentIndex > 0 do
|
|
56
58
|
currentIndex = currentIndex - 1
|
|
57
|
-
randomIndex = ____exports.getRandomArrayIndex(nil, array, rng)
|
|
58
|
-
|
|
59
|
-
array[currentIndex + 1] = ____temp_0[1]
|
|
60
|
-
array[randomIndex + 1] = ____temp_0[2]
|
|
59
|
+
local randomIndex = ____exports.getRandomArrayIndex(nil, array, rng)
|
|
60
|
+
____exports.swapArrayElements(nil, array, currentIndex, randomIndex)
|
|
61
61
|
end
|
|
62
62
|
end
|
|
63
|
+
--- Helper function to swap two different array elements. (The elements will be swapped in-place.)
|
|
64
|
+
function ____exports.swapArrayElements(self, array, i, j)
|
|
65
|
+
local value1 = array[i + 1]
|
|
66
|
+
local value2 = array[j + 1]
|
|
67
|
+
array[i + 1] = value2
|
|
68
|
+
array[j + 1] = value1
|
|
69
|
+
end
|
|
63
70
|
--- Helper function for determining if two arrays contain the exact same elements. Note that this
|
|
64
71
|
-- only performs a shallow comparison.
|
|
65
72
|
function ____exports.arrayEquals(self, array1, array2)
|
|
@@ -201,6 +208,77 @@ end
|
|
|
201
208
|
function ____exports.emptyArray(self, array)
|
|
202
209
|
__TS__ArraySplice(array, 0, #array)
|
|
203
210
|
end
|
|
211
|
+
--- Helper function to get all possible combinations of the given array. This includes the
|
|
212
|
+
-- combination of an empty array.
|
|
213
|
+
--
|
|
214
|
+
-- For example, if this function is provided an array containing 1, 2, and 3, then it will return an
|
|
215
|
+
-- array containing the following arrays:
|
|
216
|
+
--
|
|
217
|
+
-- - []
|
|
218
|
+
-- - [1]
|
|
219
|
+
-- - [2]
|
|
220
|
+
-- - [3]
|
|
221
|
+
-- - [1, 2]
|
|
222
|
+
-- - [1, 3]
|
|
223
|
+
-- - [2, 3]
|
|
224
|
+
-- - [1, 2, 3]
|
|
225
|
+
--
|
|
226
|
+
-- From: https://github.com/firstandthird/combinations/blob/master/index.js
|
|
227
|
+
--
|
|
228
|
+
-- @param array The array to get the combinations of.
|
|
229
|
+
-- @param min Optional. The minimum number of elements to include in each combination. Default is 1.
|
|
230
|
+
-- @param max Optional. The maximum number of elements to include in each combination. Default is
|
|
231
|
+
-- the length of the array.
|
|
232
|
+
function ____exports.getArrayCombinations(self, array, min, max)
|
|
233
|
+
if min == nil or min <= 0 then
|
|
234
|
+
min = 1
|
|
235
|
+
end
|
|
236
|
+
if max == nil or max <= 0 then
|
|
237
|
+
max = #array
|
|
238
|
+
end
|
|
239
|
+
local addCombinations
|
|
240
|
+
addCombinations = function(____, n, src, got, all)
|
|
241
|
+
if n == 0 then
|
|
242
|
+
if #got > 0 then
|
|
243
|
+
all[#all + 1] = got
|
|
244
|
+
end
|
|
245
|
+
return
|
|
246
|
+
end
|
|
247
|
+
do
|
|
248
|
+
local j = 0
|
|
249
|
+
while j < #src do
|
|
250
|
+
local value = src[j + 1]
|
|
251
|
+
addCombinations(
|
|
252
|
+
nil,
|
|
253
|
+
n - 1,
|
|
254
|
+
__TS__ArraySlice(src, j + 1),
|
|
255
|
+
__TS__ArrayConcat(got, {value}),
|
|
256
|
+
all
|
|
257
|
+
)
|
|
258
|
+
j = j + 1
|
|
259
|
+
end
|
|
260
|
+
end
|
|
261
|
+
end
|
|
262
|
+
local all = {}
|
|
263
|
+
do
|
|
264
|
+
local i = min
|
|
265
|
+
while i < #array do
|
|
266
|
+
addCombinations(
|
|
267
|
+
nil,
|
|
268
|
+
i,
|
|
269
|
+
array,
|
|
270
|
+
{},
|
|
271
|
+
all
|
|
272
|
+
)
|
|
273
|
+
i = i + 1
|
|
274
|
+
end
|
|
275
|
+
end
|
|
276
|
+
if #array == max then
|
|
277
|
+
all[#all + 1] = array
|
|
278
|
+
end
|
|
279
|
+
__TS__ArrayUnshift(all, {})
|
|
280
|
+
return all
|
|
281
|
+
end
|
|
204
282
|
--- Helper function to get an array containing the indexes of an array.
|
|
205
283
|
--
|
|
206
284
|
-- For example, an array of `["Apple", "Banana"]` would return an array of `[0, 1]`.
|
|
@@ -351,6 +429,7 @@ function ____exports.shuffleArray(self, originalArray, seedOrRNG)
|
|
|
351
429
|
____exports.shuffleArrayInPlace(nil, array, seedOrRNG)
|
|
352
430
|
return array
|
|
353
431
|
end
|
|
432
|
+
--- Helper function to sum every value in an array together.
|
|
354
433
|
function ____exports.sumArray(self, array)
|
|
355
434
|
return __TS__ArrayReduce(
|
|
356
435
|
array,
|
package/functions/bitwise.d.ts
CHANGED
|
@@ -1,4 +1,21 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
3
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
4
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
5
|
+
/** Helper function to convert a set of flags to a single `BitFlags` object. */
|
|
6
|
+
export declare function arrayToBitFlags<T extends BitFlag | BitFlag128>(array: T[] | readonly T[]): BitFlags<T>;
|
|
7
|
+
/** Helper function to convert an array of bits to the resulting decimal number. */
|
|
8
|
+
export declare function convertBinaryToDecimal(bits: int[]): number;
|
|
9
|
+
/** Helper function to convert a number to an array of bits. */
|
|
10
|
+
export declare function convertDecimalToBinary(number: number): int[];
|
|
11
|
+
/**
|
|
12
|
+
* Helper function to count the number of bits that are set to 1 in a binary representation of a
|
|
13
|
+
* number.
|
|
14
|
+
*/
|
|
2
15
|
export declare function countSetBits(n: int): int;
|
|
16
|
+
/** Helper function to get the value of a specific but in a binary representation of a number. */
|
|
3
17
|
export declare function getKBitOfN(k: int, n: int): int;
|
|
18
|
+
/** Helper function to get the number of bits in a binary representation of a number. */
|
|
4
19
|
export declare function getNumBitsOfN(n: int): int;
|
|
20
|
+
/** Helper function to convert a set of flags to a single `BitFlags` object. */
|
|
21
|
+
export declare function setToBitFlags<T extends BitFlag | BitFlag128>(set: Set<T> | ReadonlySet<T>): BitFlags<T>;
|
package/functions/bitwise.lua
CHANGED
|
@@ -1,4 +1,35 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__ParseInt = ____lualib.__TS__ParseInt
|
|
3
|
+
local __TS__Iterator = ____lualib.__TS__Iterator
|
|
1
4
|
local ____exports = {}
|
|
5
|
+
local ____flag = require("functions.flag")
|
|
6
|
+
local addFlag = ____flag.addFlag
|
|
7
|
+
--- Helper function to convert a set of flags to a single `BitFlags` object.
|
|
8
|
+
function ____exports.arrayToBitFlags(self, array)
|
|
9
|
+
local flags = 0
|
|
10
|
+
for ____, flag in ipairs(array) do
|
|
11
|
+
flags = addFlag(nil, flags, flag)
|
|
12
|
+
end
|
|
13
|
+
return flags
|
|
14
|
+
end
|
|
15
|
+
--- Helper function to convert an array of bits to the resulting decimal number.
|
|
16
|
+
function ____exports.convertBinaryToDecimal(self, bits)
|
|
17
|
+
local bitsString = table.concat(bits, "")
|
|
18
|
+
return __TS__ParseInt(bitsString, 2)
|
|
19
|
+
end
|
|
20
|
+
--- Helper function to convert a number to an array of bits.
|
|
21
|
+
function ____exports.convertDecimalToBinary(self, number)
|
|
22
|
+
local bits = {}
|
|
23
|
+
local i = 0
|
|
24
|
+
while number > 0 do
|
|
25
|
+
bits[i + 1] = number % 2
|
|
26
|
+
number = math.floor(number / 2)
|
|
27
|
+
i = i + 1
|
|
28
|
+
end
|
|
29
|
+
return bits
|
|
30
|
+
end
|
|
31
|
+
--- Helper function to count the number of bits that are set to 1 in a binary representation of a
|
|
32
|
+
-- number.
|
|
2
33
|
function ____exports.countSetBits(self, n)
|
|
3
34
|
local count = 0
|
|
4
35
|
while n > 0 do
|
|
@@ -7,9 +38,11 @@ function ____exports.countSetBits(self, n)
|
|
|
7
38
|
end
|
|
8
39
|
return count
|
|
9
40
|
end
|
|
41
|
+
--- Helper function to get the value of a specific but in a binary representation of a number.
|
|
10
42
|
function ____exports.getKBitOfN(self, k, n)
|
|
11
43
|
return n >> k & 1
|
|
12
44
|
end
|
|
45
|
+
--- Helper function to get the number of bits in a binary representation of a number.
|
|
13
46
|
function ____exports.getNumBitsOfN(self, n)
|
|
14
47
|
local numBits = 0
|
|
15
48
|
while n > 0 do
|
|
@@ -18,4 +51,12 @@ function ____exports.getNumBitsOfN(self, n)
|
|
|
18
51
|
end
|
|
19
52
|
return numBits
|
|
20
53
|
end
|
|
54
|
+
--- Helper function to convert a set of flags to a single `BitFlags` object.
|
|
55
|
+
function ____exports.setToBitFlags(self, set)
|
|
56
|
+
local flags = 0
|
|
57
|
+
for ____, flag in __TS__Iterator(set:values()) do
|
|
58
|
+
flags = addFlag(nil, flags, flag)
|
|
59
|
+
end
|
|
60
|
+
return flags
|
|
61
|
+
end
|
|
21
62
|
return ____exports
|
package/functions/color.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// <reference types="typescript-to-lua/language-extensions" />
|
|
3
3
|
import { SerializationType } from "../enums/SerializationType";
|
|
4
4
|
declare type SerializedColor = LuaTable<string, unknown> & {
|
|
5
|
-
readonly __serializedColorBrand:
|
|
5
|
+
readonly __serializedColorBrand: symbol;
|
|
6
6
|
};
|
|
7
7
|
interface CopyColorReturn {
|
|
8
8
|
[SerializationType.NONE]: Color;
|
package/functions/doors.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export declare function closeAllDoors(): void;
|
|
|
7
7
|
export declare function closeDoorFast(door: GridEntityDoor): void;
|
|
8
8
|
export declare function doorSlotFlagToDoorSlot(doorSlotFlag: DoorSlotFlag): DoorSlot;
|
|
9
9
|
export declare function doorSlotToDirection(doorSlot: DoorSlot): Direction;
|
|
10
|
+
export declare function doorSlotToDoorSlotFlag(doorSlot: DoorSlot): DoorSlotFlag;
|
|
10
11
|
export declare function getAngelRoomDoor(): GridEntityDoor | undefined;
|
|
11
12
|
export declare function getDevilRoomDoor(): GridEntityDoor | undefined;
|
|
12
13
|
/**
|
|
@@ -30,6 +31,11 @@ export declare function getDoorEnterPosition(door: GridEntityDoor): Vector;
|
|
|
30
31
|
* amount of units.
|
|
31
32
|
*/
|
|
32
33
|
export declare function getDoorEnterPositionOffset(doorSlot: DoorSlot): Vector;
|
|
34
|
+
/**
|
|
35
|
+
* Helper function to convert an array of door slots or a set of door slots to the resulting bit
|
|
36
|
+
* flag number.
|
|
37
|
+
*/
|
|
38
|
+
export declare function getDoorSlotFlags(doorSlots: DoorSlot[] | readonly DoorSlot[] | Set<DoorSlot> | ReadonlySet<DoorSlot>): BitFlags<DoorSlotFlag>;
|
|
33
39
|
/** Helper function to get the possible door slots that can exist for a given room shape. */
|
|
34
40
|
export declare function getDoorSlotsForRoomShape(roomShape: RoomShape): ReadonlySet<DoorSlot>;
|
|
35
41
|
/**
|
package/functions/doors.lua
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
2
|
local Set = ____lualib.Set
|
|
3
|
+
local __TS__Spread = ____lualib.__TS__Spread
|
|
4
|
+
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
|
|
3
5
|
local __TS__New = ____lualib.__TS__New
|
|
4
6
|
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
|
|
5
7
|
local __TS__ArrayFind = ____lualib.__TS__ArrayFind
|
|
@@ -18,14 +20,20 @@ local DEFAULT_DOOR_SLOT = ____doorSlotFlagToDoorSlot.DEFAULT_DOOR_SLOT
|
|
|
18
20
|
local DOOR_SLOT_FLAG_TO_DOOR_SLOT = ____doorSlotFlagToDoorSlot.DOOR_SLOT_FLAG_TO_DOOR_SLOT
|
|
19
21
|
local ____doorSlotToDirection = require("objects.doorSlotToDirection")
|
|
20
22
|
local DOOR_SLOT_TO_DIRECTION = ____doorSlotToDirection.DOOR_SLOT_TO_DIRECTION
|
|
23
|
+
local ____doorSlotToDoorSlotFlag = require("objects.doorSlotToDoorSlotFlag")
|
|
24
|
+
local DOOR_SLOT_TO_DOOR_SLOT_FLAG = ____doorSlotToDoorSlotFlag.DOOR_SLOT_TO_DOOR_SLOT_FLAG
|
|
21
25
|
local ____oppositeDoorSlots = require("objects.oppositeDoorSlots")
|
|
22
26
|
local OPPOSITE_DOOR_SLOTS = ____oppositeDoorSlots.OPPOSITE_DOOR_SLOTS
|
|
23
27
|
local ____roomShapeToDoorSlots = require("objects.roomShapeToDoorSlots")
|
|
24
28
|
local ROOM_SHAPE_TO_DOOR_SLOTS = ____roomShapeToDoorSlots.ROOM_SHAPE_TO_DOOR_SLOTS
|
|
29
|
+
local ____bitwise = require("functions.bitwise")
|
|
30
|
+
local arrayToBitFlags = ____bitwise.arrayToBitFlags
|
|
25
31
|
local ____direction = require("functions.direction")
|
|
26
32
|
local directionToVector = ____direction.directionToVector
|
|
27
33
|
local ____enums = require("functions.enums")
|
|
28
34
|
local getEnumValues = ____enums.getEnumValues
|
|
35
|
+
local ____tstlClass = require("functions.tstlClass")
|
|
36
|
+
local isTSTLSet = ____tstlClass.isTSTLSet
|
|
29
37
|
function ____exports.doorSlotToDirection(self, doorSlot)
|
|
30
38
|
return DOOR_SLOT_TO_DIRECTION[doorSlot]
|
|
31
39
|
end
|
|
@@ -52,13 +60,13 @@ function ____exports.getDoors(self, ...)
|
|
|
52
60
|
do
|
|
53
61
|
local door = room:GetDoor(doorSlot)
|
|
54
62
|
if door == nil then
|
|
55
|
-
goto
|
|
63
|
+
goto __continue18
|
|
56
64
|
end
|
|
57
65
|
if roomTypesSet.size == 0 or roomTypesSet:has(door.TargetRoomType) then
|
|
58
66
|
doors[#doors + 1] = door
|
|
59
67
|
end
|
|
60
68
|
end
|
|
61
|
-
::
|
|
69
|
+
::__continue18::
|
|
62
70
|
end
|
|
63
71
|
return doors
|
|
64
72
|
end
|
|
@@ -101,6 +109,9 @@ function ____exports.doorSlotFlagToDoorSlot(self, doorSlotFlag)
|
|
|
101
109
|
local doorSlot = DOOR_SLOT_FLAG_TO_DOOR_SLOT[doorSlotFlag]
|
|
102
110
|
return doorSlot == nil and DEFAULT_DOOR_SLOT or doorSlot
|
|
103
111
|
end
|
|
112
|
+
function ____exports.doorSlotToDoorSlotFlag(self, doorSlot)
|
|
113
|
+
return DOOR_SLOT_TO_DOOR_SLOT_FLAG[doorSlot]
|
|
114
|
+
end
|
|
104
115
|
function ____exports.getAngelRoomDoor(self)
|
|
105
116
|
local angelRoomDoors = ____exports.getDoors(nil, RoomType.ANGEL)
|
|
106
117
|
local ____temp_0
|
|
@@ -142,6 +153,16 @@ function ____exports.getDoorEnterPosition(self, door)
|
|
|
142
153
|
local offset = ____exports.getDoorEnterPositionOffset(nil, door.Slot)
|
|
143
154
|
return door.Position + offset
|
|
144
155
|
end
|
|
156
|
+
--- Helper function to convert an array of door slots or a set of door slots to the resulting bit
|
|
157
|
+
-- flag number.
|
|
158
|
+
function ____exports.getDoorSlotFlags(self, doorSlots)
|
|
159
|
+
local doorSlotArray = isTSTLSet(nil, doorSlots) and ({__TS__Spread(doorSlots:values())}) or doorSlots
|
|
160
|
+
local doorSlotFlagArray = __TS__ArrayMap(
|
|
161
|
+
doorSlotArray,
|
|
162
|
+
function(____, doorSlot) return ____exports.doorSlotToDoorSlotFlag(nil, doorSlot) end
|
|
163
|
+
)
|
|
164
|
+
return arrayToBitFlags(nil, doorSlotFlagArray)
|
|
165
|
+
end
|
|
145
166
|
--- Helper function to get the possible door slots that can exist for a given room shape.
|
|
146
167
|
function ____exports.getDoorSlotsForRoomShape(self, roomShape)
|
|
147
168
|
return ROOM_SHAPE_TO_DOOR_SLOTS[roomShape]
|
package/functions/kColor.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// <reference types="typescript-to-lua/language-extensions" />
|
|
3
3
|
import { SerializationType } from "../enums/SerializationType";
|
|
4
4
|
declare type SerializedKColor = LuaTable<string, unknown> & {
|
|
5
|
-
readonly __serializedKColorBrand:
|
|
5
|
+
readonly __serializedKColorBrand: symbol;
|
|
6
6
|
};
|
|
7
7
|
interface CopyKColorReturn {
|
|
8
8
|
[SerializationType.NONE]: KColor;
|
package/functions/log.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export declare function getDebugPrependString(msg: string, numParentFunctions?:
|
|
|
11
11
|
* function will also prepend the function name and the line number before the string.
|
|
12
12
|
*/
|
|
13
13
|
export declare function log(this: void, msg: string): void;
|
|
14
|
-
export declare function logArray<T>(this: void, array: T[]): void;
|
|
14
|
+
export declare function logArray<T>(this: void, array: T[] | readonly T[]): void;
|
|
15
15
|
export declare function logColor(this: void, color: Color): void;
|
|
16
16
|
/** Helper function for printing out every damage flag that is turned on. Useful when debugging. */
|
|
17
17
|
export declare function logDamageFlags(this: void, flags: DamageFlag | BitFlags<DamageFlag>): void;
|
|
@@ -56,7 +56,7 @@ export declare function logRoom(this: void): void;
|
|
|
56
56
|
* particular run.
|
|
57
57
|
*/
|
|
58
58
|
export declare function logSeedEffects(this: void): void;
|
|
59
|
-
export declare function logSet(this: void, set: Set<AnyNotNil>): void;
|
|
59
|
+
export declare function logSet(this: void, set: Set<AnyNotNil> | ReadonlySet<AnyNotNil>): void;
|
|
60
60
|
/** Helper function for logging every sound effect that is currently playing. */
|
|
61
61
|
export declare function logSounds(this: void): void;
|
|
62
62
|
/**
|
package/functions/rng.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
/// <reference types="typescript-to-lua/language-extensions" />
|
|
4
4
|
import { SerializationType } from "../enums/SerializationType";
|
|
5
5
|
declare type SerializedRNG = LuaTable<string, unknown> & {
|
|
6
|
-
readonly __serializedRNGBrand:
|
|
6
|
+
readonly __serializedRNGBrand: symbol;
|
|
7
7
|
};
|
|
8
8
|
interface CopyRNGReturn {
|
|
9
9
|
[SerializationType.NONE]: RNG;
|
package/functions/roomShape.d.ts
CHANGED
|
@@ -17,14 +17,14 @@ export declare function getRoomShapeBottomRightPosition(roomShape: RoomShape): V
|
|
|
17
17
|
* Helper function to get the bounds of a room shape, which are a box representing its contents.
|
|
18
18
|
* This does not include the tiles that the walls are on. L rooms use the same bounds as a 2x2 room.
|
|
19
19
|
*/
|
|
20
|
-
export declare function getRoomShapeBounds(roomShape: RoomShape):
|
|
20
|
+
export declare function getRoomShapeBounds(roomShape: RoomShape): readonly [width: int, height: int];
|
|
21
21
|
/**
|
|
22
22
|
* Helper function to get the dimensions of a room shape's layout. This is NOT the size of the
|
|
23
23
|
* room's actual contents! For that, use the `getRoomShapeBounds` function.
|
|
24
24
|
*
|
|
25
25
|
* For example, a horizontal narrow room has a layout size of equal to that of a 1x1 room.
|
|
26
26
|
*/
|
|
27
|
-
export declare function getRoomShapeLayoutSize(roomShape: RoomShape):
|
|
27
|
+
export declare function getRoomShapeLayoutSize(roomShape: RoomShape): readonly [width: int, height: int];
|
|
28
28
|
/**
|
|
29
29
|
* Helper function to get the grid position of the top-left tile of a given room shape.
|
|
30
30
|
*
|
package/functions/set.d.ts
CHANGED
|
@@ -31,6 +31,23 @@ export declare function deleteSetsFromSet<T>(mainSet: Set<T>, ...setsToRemove: A
|
|
|
31
31
|
* @param exceptions Optional. An array of elements to skip over if selected.
|
|
32
32
|
*/
|
|
33
33
|
export declare function getRandomSetElement<T>(set: Set<T> | ReadonlySet<T>, seedOrRNG?: Seed | RNG, exceptions?: T[] | readonly T[]): T;
|
|
34
|
+
/**
|
|
35
|
+
* Helper function to get all possible combinations of the given set. This includes the combination
|
|
36
|
+
* of an empty set.
|
|
37
|
+
*
|
|
38
|
+
* For example, if this function is provided a set containing 1, 2, and 3, then it will return an
|
|
39
|
+
* array containing the following sets:
|
|
40
|
+
*
|
|
41
|
+
* - []
|
|
42
|
+
* - [1]
|
|
43
|
+
* - [2]
|
|
44
|
+
* - [3]
|
|
45
|
+
* - [1, 2]
|
|
46
|
+
* - [1, 3]
|
|
47
|
+
* - [2, 3]
|
|
48
|
+
* - [1, 2, 3]
|
|
49
|
+
*/
|
|
50
|
+
export declare function getSetCombinations<T>(set: Set<T> | ReadonlySet<T>): ReadonlyArray<ReadonlySet<T>>;
|
|
34
51
|
/**
|
|
35
52
|
* Helper function to get a sorted array based on the contents of a set.
|
|
36
53
|
*
|
package/functions/set.lua
CHANGED
|
@@ -2,10 +2,12 @@ local ____lualib = require("lualib_bundle")
|
|
|
2
2
|
local Set = ____lualib.Set
|
|
3
3
|
local __TS__Iterator = ____lualib.__TS__Iterator
|
|
4
4
|
local __TS__New = ____lualib.__TS__New
|
|
5
|
+
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
|
|
5
6
|
local __TS__Spread = ____lualib.__TS__Spread
|
|
6
7
|
local __TS__ArraySort = ____lualib.__TS__ArraySort
|
|
7
8
|
local ____exports = {}
|
|
8
9
|
local ____array = require("functions.array")
|
|
10
|
+
local getArrayCombinations = ____array.getArrayCombinations
|
|
9
11
|
local getRandomArrayElement = ____array.getRandomArrayElement
|
|
10
12
|
local ____rng = require("functions.rng")
|
|
11
13
|
local getRandomSeed = ____rng.getRandomSeed
|
|
@@ -80,4 +82,26 @@ function ____exports.getRandomSetElement(self, set, seedOrRNG, exceptions)
|
|
|
80
82
|
local array = ____exports.getSortedSetValues(nil, set)
|
|
81
83
|
return getRandomArrayElement(nil, array, seedOrRNG, exceptions)
|
|
82
84
|
end
|
|
85
|
+
--- Helper function to get all possible combinations of the given set. This includes the combination
|
|
86
|
+
-- of an empty set.
|
|
87
|
+
--
|
|
88
|
+
-- For example, if this function is provided a set containing 1, 2, and 3, then it will return an
|
|
89
|
+
-- array containing the following sets:
|
|
90
|
+
--
|
|
91
|
+
-- - []
|
|
92
|
+
-- - [1]
|
|
93
|
+
-- - [2]
|
|
94
|
+
-- - [3]
|
|
95
|
+
-- - [1, 2]
|
|
96
|
+
-- - [1, 3]
|
|
97
|
+
-- - [2, 3]
|
|
98
|
+
-- - [1, 2, 3]
|
|
99
|
+
function ____exports.getSetCombinations(self, set)
|
|
100
|
+
local values = ____exports.getSortedSetValues(nil, set)
|
|
101
|
+
local combinations = getArrayCombinations(nil, values)
|
|
102
|
+
return __TS__ArrayMap(
|
|
103
|
+
combinations,
|
|
104
|
+
function(____, array) return __TS__New(Set, array) end
|
|
105
|
+
)
|
|
106
|
+
end
|
|
83
107
|
return ____exports
|
package/functions/vector.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { Direction } from "isaac-typescript-definitions";
|
|
3
3
|
import { SerializationType } from "../enums/SerializationType";
|
|
4
4
|
declare type SerializedVector = LuaTable<string, unknown> & {
|
|
5
|
-
readonly __serializedVectorBrand:
|
|
5
|
+
readonly __serializedVectorBrand: symbol;
|
|
6
6
|
};
|
|
7
7
|
interface CopyVectorReturn {
|
|
8
8
|
[SerializationType.NONE]: Vector;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
local ____exports = {}
|
|
2
|
+
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
|
|
3
|
+
local DoorSlot = ____isaac_2Dtypescript_2Ddefinitions.DoorSlot
|
|
4
|
+
local DoorSlotFlag = ____isaac_2Dtypescript_2Ddefinitions.DoorSlotFlag
|
|
5
|
+
local DoorSlotFlagZero = ____isaac_2Dtypescript_2Ddefinitions.DoorSlotFlagZero
|
|
6
|
+
____exports.DOOR_SLOT_TO_DOOR_SLOT_FLAG = {
|
|
7
|
+
[DoorSlot.NO_DOOR_SLOT] = DoorSlotFlagZero,
|
|
8
|
+
[DoorSlot.LEFT_0] = DoorSlotFlag.LEFT_0,
|
|
9
|
+
[DoorSlot.UP_0] = DoorSlotFlag.UP_0,
|
|
10
|
+
[DoorSlot.RIGHT_0] = DoorSlotFlag.RIGHT_0,
|
|
11
|
+
[DoorSlot.DOWN_0] = DoorSlotFlag.DOWN_0,
|
|
12
|
+
[DoorSlot.LEFT_1] = DoorSlotFlag.LEFT_1,
|
|
13
|
+
[DoorSlot.UP_1] = DoorSlotFlag.UP_1,
|
|
14
|
+
[DoorSlot.RIGHT_1] = DoorSlotFlag.RIGHT_1,
|
|
15
|
+
[DoorSlot.DOWN_1] = DoorSlotFlag.DOWN_1
|
|
16
|
+
}
|
|
17
|
+
return ____exports
|
|
@@ -6,17 +6,17 @@ local NARROW_CONTENTS_HEIGHT = ____roomShapeVolumes.NARROW_CONTENTS_HEIGHT
|
|
|
6
6
|
local NARROW_CONTENTS_WIDTH = ____roomShapeVolumes.NARROW_CONTENTS_WIDTH
|
|
7
7
|
local ONE_BY_ONE_CONTENTS_HEIGHT = ____roomShapeVolumes.ONE_BY_ONE_CONTENTS_HEIGHT
|
|
8
8
|
local ONE_BY_ONE_CONTENTS_WIDTH = ____roomShapeVolumes.ONE_BY_ONE_CONTENTS_WIDTH
|
|
9
|
-
local TWO_BY_TWO_BOUNDS =
|
|
9
|
+
local TWO_BY_TWO_BOUNDS = {ONE_BY_ONE_CONTENTS_WIDTH * 2, ONE_BY_ONE_CONTENTS_HEIGHT * 2}
|
|
10
10
|
--- The size of a room shape's contents. This does not include the tiles that the walls are on. L
|
|
11
11
|
-- rooms use the same bounds as a 2x2 room.
|
|
12
12
|
____exports.ROOM_SHAPE_BOUNDS = {
|
|
13
|
-
[RoomShape.SHAPE_1x1] =
|
|
14
|
-
[RoomShape.IH] =
|
|
15
|
-
[RoomShape.IV] =
|
|
16
|
-
[RoomShape.SHAPE_1x2] =
|
|
17
|
-
[RoomShape.IIV] =
|
|
18
|
-
[RoomShape.SHAPE_2x1] =
|
|
19
|
-
[RoomShape.IIH] =
|
|
13
|
+
[RoomShape.SHAPE_1x1] = {ONE_BY_ONE_CONTENTS_WIDTH, ONE_BY_ONE_CONTENTS_HEIGHT},
|
|
14
|
+
[RoomShape.IH] = {ONE_BY_ONE_CONTENTS_WIDTH, NARROW_CONTENTS_HEIGHT},
|
|
15
|
+
[RoomShape.IV] = {NARROW_CONTENTS_WIDTH, ONE_BY_ONE_CONTENTS_HEIGHT},
|
|
16
|
+
[RoomShape.SHAPE_1x2] = {ONE_BY_ONE_CONTENTS_WIDTH, ONE_BY_ONE_CONTENTS_HEIGHT * 2},
|
|
17
|
+
[RoomShape.IIV] = {NARROW_CONTENTS_WIDTH, ONE_BY_ONE_CONTENTS_HEIGHT * 2},
|
|
18
|
+
[RoomShape.SHAPE_2x1] = {ONE_BY_ONE_CONTENTS_WIDTH * 2, ONE_BY_ONE_CONTENTS_HEIGHT},
|
|
19
|
+
[RoomShape.IIH] = {ONE_BY_ONE_CONTENTS_WIDTH * 2, NARROW_CONTENTS_HEIGHT},
|
|
20
20
|
[RoomShape.SHAPE_2x2] = TWO_BY_TWO_BOUNDS,
|
|
21
21
|
[RoomShape.LTL] = TWO_BY_TWO_BOUNDS,
|
|
22
22
|
[RoomShape.LTR] = TWO_BY_TWO_BOUNDS,
|
|
@@ -6,5 +6,5 @@ import { RoomShape } from "isaac-typescript-definitions";
|
|
|
6
6
|
* For example, a horizontal narrow room has a layout size of equal to that of a 1x1 room.
|
|
7
7
|
*/
|
|
8
8
|
export declare const ROOM_SHAPE_LAYOUT_SIZES: {
|
|
9
|
-
readonly [key in RoomShape]:
|
|
9
|
+
readonly [key in RoomShape]: readonly [width: int, height: int];
|
|
10
10
|
};
|
|
@@ -4,10 +4,10 @@ local RoomShape = ____isaac_2Dtypescript_2Ddefinitions.RoomShape
|
|
|
4
4
|
local ____roomShapeVolumes = require("objects.roomShapeVolumes")
|
|
5
5
|
local ONE_BY_ONE_CONTENTS_HEIGHT = ____roomShapeVolumes.ONE_BY_ONE_CONTENTS_HEIGHT
|
|
6
6
|
local ONE_BY_ONE_CONTENTS_WIDTH = ____roomShapeVolumes.ONE_BY_ONE_CONTENTS_WIDTH
|
|
7
|
-
local ONE_BY_ONE_LAYOUT_SIZE =
|
|
8
|
-
local TWO_BY_ONE_VERTICAL_LAYOUT_SIZE =
|
|
9
|
-
local TWO_BY_ONE_HORIZONTAL_LAYOUT_SIZE =
|
|
10
|
-
local TWO_BY_TWO_LAYOUT_SIZE =
|
|
7
|
+
local ONE_BY_ONE_LAYOUT_SIZE = {ONE_BY_ONE_CONTENTS_WIDTH, ONE_BY_ONE_CONTENTS_HEIGHT}
|
|
8
|
+
local TWO_BY_ONE_VERTICAL_LAYOUT_SIZE = {ONE_BY_ONE_CONTENTS_WIDTH, ONE_BY_ONE_CONTENTS_HEIGHT * 2}
|
|
9
|
+
local TWO_BY_ONE_HORIZONTAL_LAYOUT_SIZE = {ONE_BY_ONE_CONTENTS_WIDTH * 2, ONE_BY_ONE_CONTENTS_HEIGHT}
|
|
10
|
+
local TWO_BY_TWO_LAYOUT_SIZE = {ONE_BY_ONE_CONTENTS_WIDTH * 2, ONE_BY_ONE_CONTENTS_HEIGHT * 2}
|
|
11
11
|
--- The dimensions of a room shape's layout. This is NOT the size of the room's actual contents! For
|
|
12
12
|
-- that, use `ROOM_SHAPE_BOUNDS`.
|
|
13
13
|
--
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isaacscript-common",
|
|
3
|
-
"version": "4.6.
|
|
3
|
+
"version": "4.6.1",
|
|
4
4
|
"description": "Helper functions and features for IsaacScript mods.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"isaac",
|
|
@@ -22,6 +22,6 @@
|
|
|
22
22
|
"main": "index",
|
|
23
23
|
"types": "index.d.ts",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"isaac-typescript-definitions": "^3.0.
|
|
25
|
+
"isaac-typescript-definitions": "^3.0.15"
|
|
26
26
|
}
|
|
27
27
|
}
|
package/types/PlayerIndex.d.ts
CHANGED