isaacscript-common 29.11.0 → 30.1.0
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/index.rollup.d.ts +12 -3
- package/dist/isaacscript-common.lua +15 -3
- package/dist/src/functions/levelGrid.d.ts +3 -3
- package/dist/src/functions/levelGrid.d.ts.map +1 -1
- package/dist/src/functions/levelGrid.lua +4 -4
- package/dist/src/functions/vector.d.ts +8 -0
- package/dist/src/functions/vector.d.ts.map +1 -1
- package/dist/src/functions/vector.lua +17 -0
- package/package.json +1 -1
- package/src/functions/levelGrid.ts +4 -4
- package/src/functions/vector.ts +25 -0
package/dist/index.rollup.d.ts
CHANGED
|
@@ -4618,6 +4618,15 @@ export declare function getClosestEntityTo<T extends AnyEntity>(referenceEntity:
|
|
|
4618
4618
|
|
|
4619
4619
|
export declare function getClosestPlayer(position: Vector): EntityPlayer;
|
|
4620
4620
|
|
|
4621
|
+
/**
|
|
4622
|
+
* Given an array of vectors, this helper function returns the closest one to a provided reference
|
|
4623
|
+
* vector.
|
|
4624
|
+
*
|
|
4625
|
+
* @param referenceVector The vector to compare against.
|
|
4626
|
+
* @param vectors The array of vectors to look through.
|
|
4627
|
+
*/
|
|
4628
|
+
export declare function getClosestVectorTo(referenceVector: Vector, vectors: Vector[]): Vector | undefined;
|
|
4629
|
+
|
|
4621
4630
|
/**
|
|
4622
4631
|
* Helper function to get all of the coin pickup entities in the room.
|
|
4623
4632
|
*
|
|
@@ -14455,8 +14464,8 @@ export declare interface RoomDescription {
|
|
|
14455
14464
|
export declare function roomExists(roomGridIndex: int): boolean;
|
|
14456
14465
|
|
|
14457
14466
|
/**
|
|
14458
|
-
* Helper function to get the coordinates of a given grid index. The floor is represented by a
|
|
14459
|
-
* grid.
|
|
14467
|
+
* Helper function to get the coordinates of a given room grid index. The floor is represented by a
|
|
14468
|
+
* 13x13 grid.
|
|
14460
14469
|
*
|
|
14461
14470
|
* - Since the starting room is in the center, the starting room grid index of 84 is equal to
|
|
14462
14471
|
* coordinates of (6, 6).
|
|
@@ -14465,7 +14474,7 @@ export declare function roomExists(roomGridIndex: int): boolean;
|
|
|
14465
14474
|
* - The bottom-left grid index of 156 is equal to coordinates of: (0, 12)
|
|
14466
14475
|
* - The bottom-right grid index of 168 is equal to coordinates of: (12, 12)
|
|
14467
14476
|
*/
|
|
14468
|
-
export declare function
|
|
14477
|
+
export declare function roomGridIndexToVector(roomGridIndex: int): Vector;
|
|
14469
14478
|
|
|
14470
14479
|
declare class RoomHistory extends Feature {
|
|
14471
14480
|
private postNewRoomEarly;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
--[[
|
|
2
2
|
|
|
3
|
-
isaacscript-common
|
|
3
|
+
isaacscript-common 30.1.0
|
|
4
4
|
|
|
5
5
|
This is the "isaacscript-common" library, which was created with the IsaacScript tool.
|
|
6
6
|
|
|
@@ -17838,6 +17838,18 @@ function ____exports.doesVectorHaveLength(self, vector, threshold)
|
|
|
17838
17838
|
end
|
|
17839
17839
|
return vector:Length() >= threshold
|
|
17840
17840
|
end
|
|
17841
|
+
function ____exports.getClosestVectorTo(self, referenceVector, vectors)
|
|
17842
|
+
local closestVector
|
|
17843
|
+
local closestDistance = math.huge
|
|
17844
|
+
for ____, vector in ipairs(vectors) do
|
|
17845
|
+
local distance = referenceVector:Distance(vector)
|
|
17846
|
+
if distance < closestDistance then
|
|
17847
|
+
closestVector = vector
|
|
17848
|
+
closestDistance = distance
|
|
17849
|
+
end
|
|
17850
|
+
end
|
|
17851
|
+
return closestVector
|
|
17852
|
+
end
|
|
17841
17853
|
function ____exports.getRandomVector(self, seedOrRNG)
|
|
17842
17854
|
if seedOrRNG == nil then
|
|
17843
17855
|
seedOrRNG = getRandomSeed(nil)
|
|
@@ -47417,10 +47429,10 @@ function ____exports.newRoom(self, seedOrRNG)
|
|
|
47417
47429
|
end
|
|
47418
47430
|
return newRoomGridIndex
|
|
47419
47431
|
end
|
|
47420
|
-
function ____exports.
|
|
47432
|
+
function ____exports.roomGridIndexToVector(self, roomGridIndex)
|
|
47421
47433
|
local x = roomGridIndex % LEVEL_GRID_ROW_WIDTH
|
|
47422
47434
|
local y = math.floor(roomGridIndex / LEVEL_GRID_ROW_WIDTH)
|
|
47423
|
-
return
|
|
47435
|
+
return Vector(x, y)
|
|
47424
47436
|
end
|
|
47425
47437
|
return ____exports
|
|
47426
47438
|
end,
|
|
@@ -189,8 +189,8 @@ export declare function newRoom(seedOrRNG?: Seed | RNG): int | undefined;
|
|
|
189
189
|
*/
|
|
190
190
|
export declare function roomExists(roomGridIndex: int): boolean;
|
|
191
191
|
/**
|
|
192
|
-
* Helper function to get the coordinates of a given grid index. The floor is represented by a
|
|
193
|
-
* grid.
|
|
192
|
+
* Helper function to get the coordinates of a given room grid index. The floor is represented by a
|
|
193
|
+
* 13x13 grid.
|
|
194
194
|
*
|
|
195
195
|
* - Since the starting room is in the center, the starting room grid index of 84 is equal to
|
|
196
196
|
* coordinates of (6, 6).
|
|
@@ -199,5 +199,5 @@ export declare function roomExists(roomGridIndex: int): boolean;
|
|
|
199
199
|
* - The bottom-left grid index of 156 is equal to coordinates of: (0, 12)
|
|
200
200
|
* - The bottom-right grid index of 168 is equal to coordinates of: (12, 12)
|
|
201
201
|
*/
|
|
202
|
-
export declare function
|
|
202
|
+
export declare function roomGridIndexToVector(roomGridIndex: int): Vector;
|
|
203
203
|
//# sourceMappingURL=levelGrid.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"levelGrid.d.ts","sourceRoot":"","sources":["../../../src/functions/levelGrid.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAEL,QAAQ,EAKR,SAAS,EACT,QAAQ,EACT,MAAM,8BAA8B,CAAC;AA+BtC;;;;;GAKG;AACH,wBAAgB,kCAAkC,CAAC,aAAa,CAAC,EAAE,GAAG,GAAG,GAAG,EAAE,CAK7E;AAED;;;;;;GAMG;AACH,wBAAgB,qCAAqC,CACn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oom(self, seedOrRNG)
|
|
|
406
406
|
end
|
|
407
407
|
return newRoomGridIndex
|
|
408
408
|
end
|
|
409
|
-
--- Helper function to get the coordinates of a given grid index. The floor is represented by a
|
|
410
|
-
-- grid.
|
|
409
|
+
--- Helper function to get the coordinates of a given room grid index. The floor is represented by a
|
|
410
|
+
-- 13x13 grid.
|
|
411
411
|
--
|
|
412
412
|
-- - Since the starting room is in the center, the starting room grid index of 84 is equal to
|
|
413
413
|
-- coordinates of (6, 6).
|
|
@@ -415,9 +415,9 @@ end
|
|
|
415
415
|
-- - The top-right grid index of 12 is equal to coordinates of: (0, 0)
|
|
416
416
|
-- - The bottom-left grid index of 156 is equal to coordinates of: (0, 12)
|
|
417
417
|
-- - The bottom-right grid index of 168 is equal to coordinates of: (12, 12)
|
|
418
|
-
function ____exports.
|
|
418
|
+
function ____exports.roomGridIndexToVector(self, roomGridIndex)
|
|
419
419
|
local x = roomGridIndex % LEVEL_GRID_ROW_WIDTH
|
|
420
420
|
local y = math.floor(roomGridIndex / LEVEL_GRID_ROW_WIDTH)
|
|
421
|
-
return
|
|
421
|
+
return Vector(x, y)
|
|
422
422
|
end
|
|
423
423
|
return ____exports
|
|
@@ -23,6 +23,14 @@ export declare function deserializeVector(vector: SerializedVector): Vector;
|
|
|
23
23
|
* 0.01.
|
|
24
24
|
*/
|
|
25
25
|
export declare function doesVectorHaveLength(vector: Vector, threshold?: number): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Given an array of vectors, this helper function returns the closest one to a provided reference
|
|
28
|
+
* vector.
|
|
29
|
+
*
|
|
30
|
+
* @param referenceVector The vector to compare against.
|
|
31
|
+
* @param vectors The array of vectors to look through.
|
|
32
|
+
*/
|
|
33
|
+
export declare function getClosestVectorTo(referenceVector: Vector, vectors: Vector[]): Vector | undefined;
|
|
26
34
|
/**
|
|
27
35
|
* Helper function to get a random vector between (-1, -1) and (1, 1).
|
|
28
36
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file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AC,MAAM,EAAE,MAAM,GAAG,SAAS,CAG3D;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,UAAQ,GAAG,MAAM,CAIpE"}
|
|
@@ -67,6 +67,23 @@ function ____exports.doesVectorHaveLength(self, vector, threshold)
|
|
|
67
67
|
end
|
|
68
68
|
return vector:Length() >= threshold
|
|
69
69
|
end
|
|
70
|
+
--- Given an array of vectors, this helper function returns the closest one to a provided reference
|
|
71
|
+
-- vector.
|
|
72
|
+
--
|
|
73
|
+
-- @param referenceVector The vector to compare against.
|
|
74
|
+
-- @param vectors The array of vectors to look through.
|
|
75
|
+
function ____exports.getClosestVectorTo(self, referenceVector, vectors)
|
|
76
|
+
local closestVector
|
|
77
|
+
local closestDistance = math.huge
|
|
78
|
+
for ____, vector in ipairs(vectors) do
|
|
79
|
+
local distance = referenceVector:Distance(vector)
|
|
80
|
+
if distance < closestDistance then
|
|
81
|
+
closestVector = vector
|
|
82
|
+
closestDistance = distance
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
return closestVector
|
|
86
|
+
end
|
|
70
87
|
--- Helper function to get a random vector between (-1, -1) and (1, 1).
|
|
71
88
|
--
|
|
72
89
|
-- To get random vectors with a bigger length, multiply this with a number.
|
package/package.json
CHANGED
|
@@ -542,8 +542,8 @@ export function roomExists(roomGridIndex: int): boolean {
|
|
|
542
542
|
}
|
|
543
543
|
|
|
544
544
|
/**
|
|
545
|
-
* Helper function to get the coordinates of a given grid index. The floor is represented by a
|
|
546
|
-
* grid.
|
|
545
|
+
* Helper function to get the coordinates of a given room grid index. The floor is represented by a
|
|
546
|
+
* 13x13 grid.
|
|
547
547
|
*
|
|
548
548
|
* - Since the starting room is in the center, the starting room grid index of 84 is equal to
|
|
549
549
|
* coordinates of (6, 6).
|
|
@@ -552,9 +552,9 @@ export function roomExists(roomGridIndex: int): boolean {
|
|
|
552
552
|
* - The bottom-left grid index of 156 is equal to coordinates of: (0, 12)
|
|
553
553
|
* - The bottom-right grid index of 168 is equal to coordinates of: (12, 12)
|
|
554
554
|
*/
|
|
555
|
-
export function
|
|
555
|
+
export function roomGridIndexToVector(roomGridIndex: int): Vector {
|
|
556
556
|
const x = roomGridIndex % LEVEL_GRID_ROW_WIDTH;
|
|
557
557
|
const y = Math.floor(roomGridIndex / LEVEL_GRID_ROW_WIDTH);
|
|
558
558
|
|
|
559
|
-
return
|
|
559
|
+
return Vector(x, y);
|
|
560
560
|
}
|
package/src/functions/vector.ts
CHANGED
|
@@ -78,6 +78,31 @@ export function doesVectorHaveLength(
|
|
|
78
78
|
return vector.Length() >= threshold;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
/**
|
|
82
|
+
* Given an array of vectors, this helper function returns the closest one to a provided reference
|
|
83
|
+
* vector.
|
|
84
|
+
*
|
|
85
|
+
* @param referenceVector The vector to compare against.
|
|
86
|
+
* @param vectors The array of vectors to look through.
|
|
87
|
+
*/
|
|
88
|
+
export function getClosestVectorTo(
|
|
89
|
+
referenceVector: Vector,
|
|
90
|
+
vectors: Vector[],
|
|
91
|
+
): Vector | undefined {
|
|
92
|
+
let closestVector: Vector | undefined;
|
|
93
|
+
let closestDistance = math.huge;
|
|
94
|
+
for (const vector of vectors) {
|
|
95
|
+
const distance = referenceVector.Distance(vector);
|
|
96
|
+
|
|
97
|
+
if (distance < closestDistance) {
|
|
98
|
+
closestVector = vector;
|
|
99
|
+
closestDistance = distance;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return closestVector;
|
|
104
|
+
}
|
|
105
|
+
|
|
81
106
|
/**
|
|
82
107
|
* Helper function to get a random vector between (-1, -1) and (1, 1).
|
|
83
108
|
*
|