isaacscript-common 26.2.0 → 26.3.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 +82 -8
- package/dist/isaacscript-common.lua +106 -57
- package/dist/src/classes/features/other/ModdedElementSets.d.ts.map +1 -1
- package/dist/src/classes/features/other/ModdedElementSets.lua +4 -2
- package/dist/src/classes/features/other/Pause.d.ts.map +1 -1
- package/dist/src/classes/features/other/Pause.lua +3 -2
- package/dist/src/functions/array.d.ts.map +1 -1
- package/dist/src/functions/array.lua +3 -2
- package/dist/src/functions/doors.d.ts.map +1 -1
- package/dist/src/functions/doors.lua +4 -2
- package/dist/src/functions/enums.d.ts.map +1 -1
- package/dist/src/functions/enums.lua +3 -2
- package/dist/src/functions/gridEntities.lua +3 -3
- package/dist/src/functions/logMisc.d.ts +51 -8
- package/dist/src/functions/logMisc.d.ts.map +1 -1
- package/dist/src/functions/logMisc.lua +69 -21
- package/dist/src/functions/players.d.ts.map +1 -1
- package/dist/src/functions/players.lua +6 -5
- package/dist/src/functions/random.d.ts.map +1 -1
- package/dist/src/functions/random.lua +3 -2
- package/dist/src/functions/roomShapeWalls.d.ts.map +1 -1
- package/dist/src/functions/roomShapeWalls.lua +12 -11
- package/dist/src/functions/rooms.d.ts.map +1 -1
- package/dist/src/functions/rooms.lua +3 -2
- package/dist/src/functions/set.d.ts.map +1 -1
- package/dist/src/functions/set.lua +3 -1
- package/dist/src/functions/utils.d.ts.map +1 -1
- package/dist/src/functions/utils.lua +3 -2
- package/dist/src/functions/vector.d.ts +7 -0
- package/dist/src/functions/vector.d.ts.map +1 -1
- package/dist/src/functions/vector.lua +5 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.lua +8 -0
- package/package.json +1 -1
- package/src/classes/features/other/ModdedElementSets.ts +3 -2
- package/src/classes/features/other/Pause.ts +2 -1
- package/src/functions/array.ts +2 -1
- package/src/functions/doors.ts +3 -2
- package/src/functions/enums.ts +2 -1
- package/src/functions/gridEntities.ts +3 -3
- package/src/functions/logMisc.ts +99 -20
- package/src/functions/players.ts +5 -4
- package/src/functions/random.ts +2 -1
- package/src/functions/roomShapeWalls.ts +6 -5
- package/src/functions/rooms.ts +2 -1
- package/src/functions/set.ts +2 -1
- package/src/functions/utils.ts +2 -1
- package/src/functions/vector.ts +7 -0
- package/src/index.ts +1 -0
package/src/functions/players.ts
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
TRINKET_SLOT_VALUES,
|
|
14
14
|
} from "../arrays/cachedEnumValues";
|
|
15
15
|
import { game, itemConfig } from "../core/cachedClasses";
|
|
16
|
+
import { ReadonlySet } from "../types/ReadonlySet";
|
|
16
17
|
import { getLastElement, sumArray } from "./array";
|
|
17
18
|
import { getCharacterName, isVanillaCharacter } from "./characters";
|
|
18
19
|
import { getCollectibleMaxCharges } from "./collectibles";
|
|
@@ -82,7 +83,7 @@ export function anyPlayerHasTrinket(trinketType: TrinketType): boolean {
|
|
|
82
83
|
* for. Returns true if any of the characters supplied are present.
|
|
83
84
|
*/
|
|
84
85
|
export function anyPlayerIs(...matchingCharacters: PlayerType[]): boolean {
|
|
85
|
-
const matchingCharacterSet = new
|
|
86
|
+
const matchingCharacterSet = new ReadonlySet(matchingCharacters);
|
|
86
87
|
const characters = getCharacters();
|
|
87
88
|
return characters.some((character) => matchingCharacterSet.has(character));
|
|
88
89
|
}
|
|
@@ -365,7 +366,7 @@ export function getPlayerNumHitsRemaining(player: EntityPlayer): int {
|
|
|
365
366
|
* for. Returns true if any of the characters supplied are present.
|
|
366
367
|
*/
|
|
367
368
|
export function getPlayersOfType(...characters: PlayerType[]): EntityPlayer[] {
|
|
368
|
-
const charactersSet = new
|
|
369
|
+
const charactersSet = new ReadonlySet(characters);
|
|
369
370
|
const players = getPlayers();
|
|
370
371
|
return players.filter((player) => {
|
|
371
372
|
const character = player.GetPlayerType();
|
|
@@ -481,7 +482,7 @@ export function hasCollectibleInActiveSlot(
|
|
|
481
482
|
collectibleType: CollectibleType,
|
|
482
483
|
...activeSlots: ActiveSlot[]
|
|
483
484
|
): boolean {
|
|
484
|
-
const matchingActiveSlotsSet = new
|
|
485
|
+
const matchingActiveSlotsSet = new ReadonlySet(activeSlots);
|
|
485
486
|
const activeItemSlots = getActiveItemSlots(player, collectibleType);
|
|
486
487
|
return activeItemSlots.some((activeSlot) =>
|
|
487
488
|
matchingActiveSlotsSet.has(activeSlot),
|
|
@@ -568,7 +569,7 @@ export function isCharacter(
|
|
|
568
569
|
player: EntityPlayer,
|
|
569
570
|
...characters: PlayerType[]
|
|
570
571
|
): boolean {
|
|
571
|
-
const characterSet = new
|
|
572
|
+
const characterSet = new ReadonlySet(characters);
|
|
572
573
|
const character = player.GetPlayerType();
|
|
573
574
|
return characterSet.has(character);
|
|
574
575
|
}
|
package/src/functions/random.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ReadonlySet } from "../types/ReadonlySet";
|
|
1
2
|
import { getRandomSeed, isRNG, newRNG } from "./rng";
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -81,7 +82,7 @@ export function getRandomInt(
|
|
|
81
82
|
max = oldMin;
|
|
82
83
|
}
|
|
83
84
|
|
|
84
|
-
const exceptionsSet = new
|
|
85
|
+
const exceptionsSet = new ReadonlySet(exceptions);
|
|
85
86
|
|
|
86
87
|
let randomInt: int;
|
|
87
88
|
do {
|
|
@@ -3,6 +3,7 @@ import { ROOM_SHAPE_VALUES } from "../arrays/cachedEnumValues";
|
|
|
3
3
|
import { game } from "../core/cachedClasses";
|
|
4
4
|
import { CornerType } from "../enums/CornerType";
|
|
5
5
|
import { Corner } from "../interfaces/Corner";
|
|
6
|
+
import { ReadonlySet } from "../types/ReadonlySet";
|
|
6
7
|
import { getGridIndexesBetween } from "./gridIndex";
|
|
7
8
|
import { inBossRoomOf, inHomeCloset } from "./rooms";
|
|
8
9
|
import { getRoomShapeCorners, isLRoom } from "./roomShape";
|
|
@@ -38,7 +39,7 @@ function getVanillaWallGridIndexSetForRoomShape(
|
|
|
38
39
|
case RoomShape.LTL: {
|
|
39
40
|
const [topMiddle, topRight, middleLeft, middle, bottomLeft, bottomRight] =
|
|
40
41
|
corners as [Corner, Corner, Corner, Corner, Corner, Corner];
|
|
41
|
-
return new
|
|
42
|
+
return new ReadonlySet([
|
|
42
43
|
// Horizontal
|
|
43
44
|
...getGridIndexesBetween(
|
|
44
45
|
topMiddle.gridIndex,
|
|
@@ -79,7 +80,7 @@ function getVanillaWallGridIndexSetForRoomShape(
|
|
|
79
80
|
case RoomShape.LTR: {
|
|
80
81
|
const [topLeft, topMiddle, middle, middleRight, bottomLeft, bottomRight] =
|
|
81
82
|
corners as [Corner, Corner, Corner, Corner, Corner, Corner];
|
|
82
|
-
return new
|
|
83
|
+
return new ReadonlySet([
|
|
83
84
|
// Horizontal
|
|
84
85
|
...getGridIndexesBetween(
|
|
85
86
|
topLeft.gridIndex,
|
|
@@ -120,7 +121,7 @@ function getVanillaWallGridIndexSetForRoomShape(
|
|
|
120
121
|
case RoomShape.LBL: {
|
|
121
122
|
const [topLeft, topRight, middleLeft, middle, bottomMiddle, bottomRight] =
|
|
122
123
|
corners as [Corner, Corner, Corner, Corner, Corner, Corner];
|
|
123
|
-
return new
|
|
124
|
+
return new ReadonlySet([
|
|
124
125
|
// Horizontal
|
|
125
126
|
...getGridIndexesBetween(
|
|
126
127
|
topLeft.gridIndex,
|
|
@@ -161,7 +162,7 @@ function getVanillaWallGridIndexSetForRoomShape(
|
|
|
161
162
|
case RoomShape.LBR: {
|
|
162
163
|
const [topLeft, topRight, middle, middleRight, bottomLeft, bottomMiddle] =
|
|
163
164
|
corners as [Corner, Corner, Corner, Corner, Corner, Corner];
|
|
164
|
-
return new
|
|
165
|
+
return new ReadonlySet([
|
|
165
166
|
// Horizontal
|
|
166
167
|
...getGridIndexesBetween(
|
|
167
168
|
topLeft.gridIndex,
|
|
@@ -225,7 +226,7 @@ function getWallGridIndexSetForRectangleRoomShape(
|
|
|
225
226
|
Corner,
|
|
226
227
|
];
|
|
227
228
|
|
|
228
|
-
return new
|
|
229
|
+
return new ReadonlySet([
|
|
229
230
|
// Horizontal
|
|
230
231
|
...getGridIndexesBetween(topLeft.gridIndex, topRight.gridIndex, roomShape),
|
|
231
232
|
...getGridIndexesBetween(
|
package/src/functions/rooms.ts
CHANGED
|
@@ -21,6 +21,7 @@ import { game, sfxManager } from "../core/cachedClasses";
|
|
|
21
21
|
import { MAX_LEVEL_GRID_INDEX } from "../core/constants";
|
|
22
22
|
import { ROOM_TYPE_NAMES } from "../objects/roomTypeNames";
|
|
23
23
|
import { MINE_SHAFT_ROOM_SUB_TYPE_SET } from "../sets/mineShaftRoomSubTypesSet";
|
|
24
|
+
import { ReadonlySet } from "../types/ReadonlySet";
|
|
24
25
|
import { getAllDimensions, inDimension } from "./dimensions";
|
|
25
26
|
import {
|
|
26
27
|
closeAllDoors,
|
|
@@ -535,7 +536,7 @@ export function isAllRoomsClear(onlyCheckRoomTypes?: RoomType[]): boolean {
|
|
|
535
536
|
if (onlyCheckRoomTypes === undefined) {
|
|
536
537
|
matchingRooms = rooms;
|
|
537
538
|
} else {
|
|
538
|
-
const roomTypeWhitelist = new
|
|
539
|
+
const roomTypeWhitelist = new ReadonlySet(onlyCheckRoomTypes);
|
|
539
540
|
matchingRooms = rooms.filter(
|
|
540
541
|
(roomDescriptor) =>
|
|
541
542
|
roomDescriptor.Data !== undefined &&
|
package/src/functions/set.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ReadonlySet } from "../types/ReadonlySet";
|
|
1
2
|
import { getArrayCombinations, getRandomArrayElement, sumArray } from "./array";
|
|
2
3
|
import { getRandomSeed } from "./rng";
|
|
3
4
|
import { isPrimitive } from "./types";
|
|
@@ -107,7 +108,7 @@ export function getSetCombinations<T>(
|
|
|
107
108
|
const values = getSortedSetValues(set);
|
|
108
109
|
const combinations = getArrayCombinations(values, includeEmptyArray);
|
|
109
110
|
|
|
110
|
-
return combinations.map((array) => new
|
|
111
|
+
return combinations.map((array) => new ReadonlySet(array));
|
|
111
112
|
}
|
|
112
113
|
|
|
113
114
|
/**
|
package/src/functions/utils.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { RenderMode } from "isaac-typescript-definitions";
|
|
2
2
|
import { game } from "../core/cachedClasses";
|
|
3
|
+
import { ReadonlySet } from "../types/ReadonlySet";
|
|
3
4
|
import { getAllPlayers } from "./playerIndex";
|
|
4
5
|
import { isFunction } from "./types";
|
|
5
6
|
|
|
@@ -88,7 +89,7 @@ export function inRange(num: int, start: int, end: int): boolean {
|
|
|
88
89
|
export function isMultiplayer(): boolean {
|
|
89
90
|
const players = getAllPlayers();
|
|
90
91
|
const controllerIndexes = players.map((player) => player.ControllerIndex);
|
|
91
|
-
const controllerIndexesSet = new
|
|
92
|
+
const controllerIndexesSet = new ReadonlySet(controllerIndexes);
|
|
92
93
|
|
|
93
94
|
return controllerIndexesSet.size > 1;
|
|
94
95
|
}
|
package/src/functions/vector.ts
CHANGED
|
@@ -151,6 +151,13 @@ export function vectorToDirection(vector: Vector): Direction {
|
|
|
151
151
|
return angleToDirection(angleDegrees);
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
+
/**
|
|
155
|
+
* Helper function to convert a vector to a string.
|
|
156
|
+
*
|
|
157
|
+
* @param vector The vector to convert.
|
|
158
|
+
* @param round Optional. If true, will round the vector values to the nearest integer. Default is
|
|
159
|
+
* false.
|
|
160
|
+
*/
|
|
154
161
|
export function vectorToString(vector: Vector, round = false): string {
|
|
155
162
|
const x = round ? Math.round(vector.X) : vector.X;
|
|
156
163
|
const y = round ? Math.round(vector.Y) : vector.Y;
|
package/src/index.ts
CHANGED
|
@@ -93,6 +93,7 @@ export * from "./functions/positionVelocity";
|
|
|
93
93
|
export * from "./functions/pressurePlate";
|
|
94
94
|
export * from "./functions/projectiles";
|
|
95
95
|
export * from "./functions/random";
|
|
96
|
+
export * from "./functions/readOnly";
|
|
96
97
|
export * from "./functions/revive";
|
|
97
98
|
export * from "./functions/rng";
|
|
98
99
|
export * from "./functions/rockAlt";
|