isaacscript-common 21.9.0 → 22.0.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 +20 -20
- package/dist/isaacscript-common.lua +102 -138
- package/dist/lualib_bundle.lua +59 -100
- package/dist/src/functions/color.d.ts +1 -1
- package/dist/src/functions/color.d.ts.map +1 -1
- package/dist/src/functions/hex.d.ts +2 -2
- package/dist/src/functions/hex.d.ts.map +1 -1
- package/dist/src/functions/kColor.d.ts +1 -1
- package/dist/src/functions/kColor.d.ts.map +1 -1
- package/dist/src/functions/log.d.ts +1 -1
- package/dist/src/functions/log.d.ts.map +1 -1
- package/dist/src/functions/log.lua +5 -0
- package/dist/src/functions/positionVelocity.d.ts +1 -1
- package/dist/src/functions/positionVelocity.d.ts.map +1 -1
- package/dist/src/functions/roomGrid.d.ts +5 -5
- package/dist/src/functions/roomGrid.d.ts.map +1 -1
- package/dist/src/functions/ui.d.ts +8 -8
- package/dist/src/functions/ui.d.ts.map +1 -1
- package/dist/src/functions/vector.d.ts +1 -1
- package/dist/src/functions/vector.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/functions/color.ts +1 -1
- package/src/functions/hex.ts +2 -2
- package/src/functions/kColor.ts +1 -1
- package/src/functions/log.ts +7 -1
- package/src/functions/positionVelocity.ts +1 -1
- package/src/functions/roomGrid.ts +14 -5
- package/src/functions/ui.ts +8 -8
- package/src/functions/vector.ts +1 -1
|
@@ -22,7 +22,10 @@ import {
|
|
|
22
22
|
*
|
|
23
23
|
* For example, the coordinates of (0, 0) are equal to `Vector(80, 160)`.
|
|
24
24
|
*/
|
|
25
|
-
export function gridCoordinatesToWorldPosition(
|
|
25
|
+
export function gridCoordinatesToWorldPosition(
|
|
26
|
+
x: int,
|
|
27
|
+
y: int,
|
|
28
|
+
): Readonly<Vector> {
|
|
26
29
|
const gridPosition = Vector(x, y);
|
|
27
30
|
return gridPositionToWorldPosition(gridPosition);
|
|
28
31
|
}
|
|
@@ -36,7 +39,7 @@ export function gridCoordinatesToWorldPosition(x: int, y: int): Vector {
|
|
|
36
39
|
export function gridIndexToGridPosition(
|
|
37
40
|
gridIndex: int,
|
|
38
41
|
roomShape: RoomShape,
|
|
39
|
-
): Vector {
|
|
42
|
+
): Readonly<Vector> {
|
|
40
43
|
const gridWidth = getRoomShapeWidth(roomShape);
|
|
41
44
|
|
|
42
45
|
const x = (gridIndex % gridWidth) - 1;
|
|
@@ -49,7 +52,9 @@ export function gridIndexToGridPosition(
|
|
|
49
52
|
*
|
|
50
53
|
* For example, the coordinates of (0, 0) are equal to `Vector(80, 160)`.
|
|
51
54
|
*/
|
|
52
|
-
export function gridPositionToWorldPosition(
|
|
55
|
+
export function gridPositionToWorldPosition(
|
|
56
|
+
gridPosition: Vector,
|
|
57
|
+
): Readonly<Vector> {
|
|
53
58
|
const x = (gridPosition.X + 2) * 40;
|
|
54
59
|
const y = (gridPosition.Y + 4) * 40;
|
|
55
60
|
|
|
@@ -99,7 +104,9 @@ function isValidGridPositionLRoom(gridPosition: Vector, roomShape: RoomShape) {
|
|
|
99
104
|
*
|
|
100
105
|
* In this context, the grid position of the top-left wall is "Vector(-1, -1)".
|
|
101
106
|
*/
|
|
102
|
-
export function worldPositionToGridPosition(
|
|
107
|
+
export function worldPositionToGridPosition(
|
|
108
|
+
worldPos: Vector,
|
|
109
|
+
): Readonly<Vector> {
|
|
103
110
|
const x = Math.round(worldPos.X / 40 - 2);
|
|
104
111
|
const y = Math.round(worldPos.Y / 40 - 4);
|
|
105
112
|
return Vector(x, y);
|
|
@@ -112,7 +119,9 @@ export function worldPositionToGridPosition(worldPos: Vector): Vector {
|
|
|
112
119
|
*
|
|
113
120
|
* This is similar to the `worldPositionToGridPosition` function, but the values are not rounded.
|
|
114
121
|
*/
|
|
115
|
-
export function worldPositionToGridPositionFast(
|
|
122
|
+
export function worldPositionToGridPositionFast(
|
|
123
|
+
worldPos: Vector,
|
|
124
|
+
): Readonly<Vector> {
|
|
116
125
|
const x = worldPos.X / 40 - 2;
|
|
117
126
|
const y = worldPos.Y / 40 - 4;
|
|
118
127
|
return Vector(x, y);
|
package/src/functions/ui.ts
CHANGED
|
@@ -13,7 +13,7 @@ import { copyVector } from "./vector";
|
|
|
13
13
|
* - If the user does not have a HUD offset configured, this function will return `Vector(0, 0)`.
|
|
14
14
|
* - If the user has a HUD offset of 1.0 configured, this function will return `Vector(20, 12)`.
|
|
15
15
|
*/
|
|
16
|
-
export function getHUDOffsetVector(): Vector {
|
|
16
|
+
export function getHUDOffsetVector(): Readonly<Vector> {
|
|
17
17
|
// Convert e.g. 0.4 to 4.
|
|
18
18
|
const hudOffset = math.floor(Options.HUDOffset * 10);
|
|
19
19
|
|
|
@@ -89,38 +89,38 @@ export function getHeartsUIWidth(): int {
|
|
|
89
89
|
return width;
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
export function getScreenBottomCenterPos(): Vector {
|
|
92
|
+
export function getScreenBottomCenterPos(): Readonly<Vector> {
|
|
93
93
|
const bottomRight = getScreenBottomRightPos();
|
|
94
94
|
return Vector(bottomRight.X / 2, bottomRight.Y);
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
export function getScreenBottomLeftPos(): Vector {
|
|
97
|
+
export function getScreenBottomLeftPos(): Readonly<Vector> {
|
|
98
98
|
const bottomRight = getScreenBottomRightPos();
|
|
99
99
|
return Vector(0, bottomRight.Y);
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
export function getScreenBottomRightPos(): Vector {
|
|
102
|
+
export function getScreenBottomRightPos(): Readonly<Vector> {
|
|
103
103
|
const screenWidth = Isaac.GetScreenWidth();
|
|
104
104
|
const screenHeight = Isaac.GetScreenHeight();
|
|
105
105
|
|
|
106
106
|
return Vector(screenWidth, screenHeight);
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
export function getScreenCenterPos(): Vector {
|
|
109
|
+
export function getScreenCenterPos(): Readonly<Vector> {
|
|
110
110
|
const bottomRight = getScreenBottomRightPos();
|
|
111
111
|
return bottomRight.div(2);
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
export function getScreenTopCenterPos(): Vector {
|
|
114
|
+
export function getScreenTopCenterPos(): Readonly<Vector> {
|
|
115
115
|
const bottomRight = getScreenBottomRightPos();
|
|
116
116
|
return Vector(bottomRight.X / 2, 0);
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
export function getScreenTopLeftPos(): Vector {
|
|
119
|
+
export function getScreenTopLeftPos(): Readonly<Vector> {
|
|
120
120
|
return copyVector(VectorZero);
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
export function getScreenTopRightPos(): Vector {
|
|
123
|
+
export function getScreenTopRightPos(): Readonly<Vector> {
|
|
124
124
|
const bottomRight = getScreenBottomRightPos();
|
|
125
125
|
return Vector(bottomRight.X, 0);
|
|
126
126
|
}
|
package/src/functions/vector.ts
CHANGED
|
@@ -90,7 +90,7 @@ export function doesVectorHaveLength(
|
|
|
90
90
|
*/
|
|
91
91
|
export function getRandomVector(
|
|
92
92
|
seedOrRNG: Seed | RNG = getRandomSeed(),
|
|
93
|
-
): Vector {
|
|
93
|
+
): Readonly<Vector> {
|
|
94
94
|
const rng = isRNG(seedOrRNG) ? seedOrRNG : newRNG(seedOrRNG);
|
|
95
95
|
|
|
96
96
|
const x = getRandomFloat(-1, 1, rng);
|