isaacscript-common 21.8.4 → 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 +30 -30
- package/dist/isaacscript-common.lua +111 -145
- 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/minimap.d.ts +9 -9
- package/dist/src/functions/minimap.d.ts.map +1 -1
- package/dist/src/functions/minimap.lua +15 -13
- 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/minimap.ts +23 -15
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vector.d.ts","sourceRoot":"","sources":["../../../src/functions/vector.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,yBAAyB,EACzB,SAAS,EACV,MAAM,8BAA8B,CAAC;AAatC,MAAM,MAAM,gBAAgB,GAAG,MAAM,CA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AgB,kBAAkB,CAChC,MAAM,EAAE,OAAO,GACd,MAAM,IAAI,gBAAgB,CAM5B;AAED,gFAAgF;AAChF,wBAAgB,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,MAAM,CAE1D;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,CAWhE;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAEtE;AAED,sEAAsE;AACtE,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAG3D;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,UAAQ,GAAG,MAAM,CAIpE"}
|
package/package.json
CHANGED
package/src/functions/color.ts
CHANGED
|
@@ -87,7 +87,7 @@ export function deserializeColor(color: SerializedColor): Color {
|
|
|
87
87
|
export function getRandomColor(
|
|
88
88
|
seedOrRNG: Seed | RNG = getRandomSeed(),
|
|
89
89
|
alpha = 1,
|
|
90
|
-
): Color {
|
|
90
|
+
): Readonly<Color> {
|
|
91
91
|
const rng = isRNG(seedOrRNG) ? seedOrRNG : newRNG(seedOrRNG);
|
|
92
92
|
|
|
93
93
|
const r = getRandom(rng);
|
package/src/functions/hex.ts
CHANGED
|
@@ -8,7 +8,7 @@ const HEX_STRING_LENGTH = 6;
|
|
|
8
8
|
* @param hexString A hex string like "#ffffff" or "ffffff". (The "#" character is optional.)
|
|
9
9
|
* @param alpha Optional. Range is from 0 to 1. Default is 1. (The same as the `Color` constructor.)
|
|
10
10
|
*/
|
|
11
|
-
export function hexToColor(hexString: string, alpha = 1.0): Color {
|
|
11
|
+
export function hexToColor(hexString: string, alpha = 1.0): Readonly<Color> {
|
|
12
12
|
const [r, g, b] = hexToRGB(hexString);
|
|
13
13
|
|
|
14
14
|
// Color values should be between 0 and 1.
|
|
@@ -22,7 +22,7 @@ export function hexToColor(hexString: string, alpha = 1.0): Color {
|
|
|
22
22
|
* @param hexString A hex string like "#ffffff" or "ffffff". (The "#" character is optional.)
|
|
23
23
|
* @param alpha Range is from 0 to 1. Default is 1.
|
|
24
24
|
*/
|
|
25
|
-
export function hexToKColor(hexString: string, alpha = 1.0): KColor {
|
|
25
|
+
export function hexToKColor(hexString: string, alpha = 1.0): Readonly<KColor> {
|
|
26
26
|
const [r, g, b] = hexToRGB(hexString);
|
|
27
27
|
|
|
28
28
|
// KColor values should be between 0 and 1.
|
package/src/functions/kColor.ts
CHANGED
|
@@ -76,7 +76,7 @@ export function deserializeKColor(kColor: SerializedKColor): KColor {
|
|
|
76
76
|
export function getRandomKColor(
|
|
77
77
|
seedOrRNG: Seed | RNG = getRandomSeed(),
|
|
78
78
|
alpha = 1,
|
|
79
|
-
): KColor {
|
|
79
|
+
): Readonly<KColor> {
|
|
80
80
|
const rng = isRNG(seedOrRNG) ? seedOrRNG : newRNG(seedOrRNG);
|
|
81
81
|
|
|
82
82
|
const r = getRandom(rng);
|
package/src/functions/log.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { isNumber } from "./types";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Helper function to get the name and the line number of the current calling function.
|
|
3
5
|
*
|
|
@@ -53,9 +55,13 @@ export function getParentFunctionDescription(
|
|
|
53
55
|
*/
|
|
54
56
|
export function log(
|
|
55
57
|
this: void,
|
|
56
|
-
msg: string,
|
|
58
|
+
msg: string | number,
|
|
57
59
|
includeParentFunction = true,
|
|
58
60
|
): void {
|
|
61
|
+
if (isNumber(msg)) {
|
|
62
|
+
msg = msg.toString();
|
|
63
|
+
}
|
|
64
|
+
|
|
59
65
|
const parentFunctionDescription = includeParentFunction
|
|
60
66
|
? getParentFunctionDescription()
|
|
61
67
|
: undefined;
|
package/src/functions/minimap.ts
CHANGED
|
@@ -37,6 +37,18 @@ export function clearFloorDisplayFlags(): void {
|
|
|
37
37
|
setAllDisplayFlags(DisplayFlagZero);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Helper function to set the value of `DisplayFlag` for a room 0.
|
|
42
|
+
*
|
|
43
|
+
* This function automatically accounts for whether or not MinimapAPI is being used.
|
|
44
|
+
*
|
|
45
|
+
* This function automatically calls the `Level.UpdateVisibility` after setting the flags so that
|
|
46
|
+
* the changes will be immediately visible.
|
|
47
|
+
*/
|
|
48
|
+
export function clearRoomDisplayFlags(roomGridIndex: int): void {
|
|
49
|
+
setRoomDisplayFlags(roomGridIndex, DisplayFlagZero);
|
|
50
|
+
}
|
|
51
|
+
|
|
40
52
|
/**
|
|
41
53
|
* Helper function to get the minimap `DisplayFlag` value for every room on the floor. Returns a map
|
|
42
54
|
* that is indexed by the room's safe grid index.
|
|
@@ -163,25 +175,21 @@ export function setRoomDisplayFlags(
|
|
|
163
175
|
} else {
|
|
164
176
|
const minimapAPIRoomDescriptor = MinimapAPI.GetRoomByIdx(roomGridIndex);
|
|
165
177
|
if (minimapAPIRoomDescriptor === undefined) {
|
|
178
|
+
// The room might have already been removed previously.
|
|
179
|
+
if (displayFlags === DisplayFlagZero) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
|
|
166
183
|
error(
|
|
167
184
|
`Failed to get the MinimapAPI room descriptor for the room at index: ${roomGridIndex}`,
|
|
168
185
|
);
|
|
169
186
|
}
|
|
170
187
|
minimapAPIRoomDescriptor.SetDisplayFlags(displayFlags);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
188
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
* make the changes immediately visible. Default is true.
|
|
181
|
-
*/
|
|
182
|
-
export function setRoomVisible(
|
|
183
|
-
roomGridIndex: int | undefined,
|
|
184
|
-
updateVisibility = true,
|
|
185
|
-
): void {
|
|
186
|
-
addRoomDisplayFlag(roomGridIndex, DisplayFlag.SHOW_ICON, updateVisibility);
|
|
189
|
+
// MinimapAPI is bugged such that setting the display flags to 0 does not make the room
|
|
190
|
+
// invisible. We delete the room to work around this.
|
|
191
|
+
if (displayFlags === DisplayFlagZero) {
|
|
192
|
+
minimapAPIRoomDescriptor.Remove();
|
|
193
|
+
}
|
|
194
|
+
}
|
|
187
195
|
}
|
|
@@ -54,7 +54,7 @@ export function findFreePosition(
|
|
|
54
54
|
startingPosition: Vector,
|
|
55
55
|
avoidActiveEntities = false,
|
|
56
56
|
minimumDistance?: float,
|
|
57
|
-
): Vector {
|
|
57
|
+
): Readonly<Vector> {
|
|
58
58
|
const room = game.GetRoom();
|
|
59
59
|
const heavenDoors = getEffects(
|
|
60
60
|
EffectVariant.HEAVEN_LIGHT_DOOR,
|
|
@@ -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);
|