isaacscript-common 80.2.4 → 81.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/functions/array.d.ts +1 -1
- package/dist/functions/array.d.ts.map +1 -1
- package/dist/functions/arrayLua.d.ts +2 -2
- package/dist/functions/arrayLua.d.ts.map +1 -1
- package/dist/functions/benchmark.d.ts +1 -1
- package/dist/functions/benchmark.d.ts.map +1 -1
- package/dist/functions/bitwise.d.ts +1 -1
- package/dist/functions/bitwise.d.ts.map +1 -1
- package/dist/functions/bosses.d.ts +2 -2
- package/dist/functions/bosses.d.ts.map +1 -1
- package/dist/functions/charge.d.ts +1 -1
- package/dist/functions/charge.d.ts.map +1 -1
- package/dist/functions/collectibles.d.ts +2 -1
- package/dist/functions/collectibles.d.ts.map +1 -1
- package/dist/functions/collectibles.lua +2 -1
- package/dist/functions/doors.d.ts +4 -4
- package/dist/functions/doors.d.ts.map +1 -1
- package/dist/functions/entities.d.ts +4 -4
- package/dist/functions/entities.d.ts.map +1 -1
- package/dist/functions/entitiesSpecific.d.ts +20 -20
- package/dist/functions/entitiesSpecific.d.ts.map +1 -1
- package/dist/functions/enums.d.ts +4 -4
- package/dist/functions/enums.d.ts.map +1 -1
- package/dist/functions/familiars.d.ts +1 -1
- package/dist/functions/familiars.d.ts.map +1 -1
- package/dist/functions/gridEntities.d.ts +11 -11
- package/dist/functions/gridEntities.d.ts.map +1 -1
- package/dist/functions/gridEntitiesSpecific.d.ts +18 -18
- package/dist/functions/gridEntitiesSpecific.d.ts.map +1 -1
- package/dist/functions/gridIndex.d.ts +1 -1
- package/dist/functions/gridIndex.d.ts.map +1 -1
- package/dist/functions/input.d.ts +2 -2
- package/dist/functions/input.d.ts.map +1 -1
- package/dist/functions/itemPool.d.ts +1 -1
- package/dist/functions/itemPool.d.ts.map +1 -1
- package/dist/functions/jsonRoom.d.ts +1 -1
- package/dist/functions/jsonRoom.d.ts.map +1 -1
- package/dist/functions/level.d.ts +1 -1
- package/dist/functions/level.d.ts.map +1 -1
- package/dist/functions/levelGrid.d.ts +1 -1
- package/dist/functions/levelGrid.d.ts.map +1 -1
- package/dist/functions/math.d.ts +2 -2
- package/dist/functions/math.d.ts.map +1 -1
- package/dist/functions/newArray.d.ts.map +1 -1
- package/dist/functions/npcs.d.ts +1 -1
- package/dist/functions/npcs.d.ts.map +1 -1
- package/dist/functions/pickups.d.ts +2 -2
- package/dist/functions/pickups.d.ts.map +1 -1
- package/dist/functions/pickupsSpecific.d.ts +22 -22
- package/dist/functions/pickupsSpecific.d.ts.map +1 -1
- package/dist/functions/playerCollectibles.d.ts +2 -2
- package/dist/functions/playerCollectibles.d.ts.map +1 -1
- package/dist/functions/playerEffects.d.ts +1 -1
- package/dist/functions/playerEffects.d.ts.map +1 -1
- package/dist/functions/playerIndex.d.ts +3 -3
- package/dist/functions/playerIndex.d.ts.map +1 -1
- package/dist/functions/playerTrinkets.d.ts +1 -1
- package/dist/functions/playerTrinkets.d.ts.map +1 -1
- package/dist/functions/players.d.ts +4 -4
- package/dist/functions/players.d.ts.map +1 -1
- package/dist/functions/pocketItems.d.ts +2 -2
- package/dist/functions/pocketItems.d.ts.map +1 -1
- package/dist/functions/positionVelocity.d.ts +5 -5
- package/dist/functions/positionVelocity.d.ts.map +1 -1
- package/dist/functions/projectiles.d.ts +2 -2
- package/dist/functions/projectiles.d.ts.map +1 -1
- package/dist/functions/rooms.d.ts +5 -5
- package/dist/functions/rooms.d.ts.map +1 -1
- package/dist/functions/run.d.ts +1 -1
- package/dist/functions/run.d.ts.map +1 -1
- package/dist/functions/set.d.ts.map +1 -1
- package/dist/functions/sort.d.ts.map +1 -1
- package/dist/functions/sprites.d.ts +1 -1
- package/dist/functions/sprites.d.ts.map +1 -1
- package/dist/functions/table.d.ts +3 -3
- package/dist/functions/table.d.ts.map +1 -1
- package/dist/functions/utils.d.ts +2 -2
- package/dist/functions/utils.d.ts.map +1 -1
- package/dist/index.rollup.d.ts +138 -137
- package/dist/isaacscript-common.lua +3 -2
- package/package.json +2 -2
- package/src/classes/ModUpgraded.ts +4 -2
- package/src/functions/array.ts +10 -1
- package/src/functions/arrayLua.ts +2 -2
- package/src/functions/benchmark.ts +1 -1
- package/src/functions/bitwise.ts +4 -1
- package/src/functions/bosses.ts +2 -2
- package/src/functions/charge.ts +1 -1
- package/src/functions/collectibles.ts +2 -1
- package/src/functions/deepCopy.ts +1 -1
- package/src/functions/doors.ts +6 -4
- package/src/functions/entities.ts +7 -7
- package/src/functions/entitiesSpecific.ts +20 -20
- package/src/functions/enums.ts +6 -4
- package/src/functions/familiars.ts +3 -1
- package/src/functions/gridEntities.ts +13 -13
- package/src/functions/gridEntitiesSpecific.ts +20 -18
- package/src/functions/gridIndex.ts +1 -1
- package/src/functions/input.ts +2 -2
- package/src/functions/itemPool.ts +1 -1
- package/src/functions/jsonRoom.ts +1 -1
- package/src/functions/level.ts +1 -1
- package/src/functions/levelGrid.ts +1 -1
- package/src/functions/math.ts +2 -2
- package/src/functions/newArray.ts +1 -0
- package/src/functions/npcs.ts +1 -1
- package/src/functions/pickups.ts +2 -2
- package/src/functions/pickupsSpecific.ts +31 -22
- package/src/functions/playerCollectibles.ts +2 -2
- package/src/functions/playerEffects.ts +3 -1
- package/src/functions/playerIndex.ts +5 -3
- package/src/functions/playerTrinkets.ts +1 -1
- package/src/functions/players.ts +6 -4
- package/src/functions/pocketItems.ts +5 -3
- package/src/functions/positionVelocity.ts +9 -5
- package/src/functions/projectiles.ts +2 -2
- package/src/functions/rooms.ts +8 -6
- package/src/functions/run.ts +1 -1
- package/src/functions/set.ts +1 -0
- package/src/functions/sort.ts +1 -0
- package/src/functions/sprites.ts +1 -1
- package/src/functions/table.ts +3 -3
- package/src/functions/utils.ts +2 -2
|
@@ -25,7 +25,7 @@ import { assertDefined } from "./utils";
|
|
|
25
25
|
*/
|
|
26
26
|
export function getCrawlSpaces(
|
|
27
27
|
crawlSpaceVariant: CrawlSpaceVariant | -1 = -1,
|
|
28
|
-
): GridEntity[] {
|
|
28
|
+
): readonly GridEntity[] {
|
|
29
29
|
if (crawlSpaceVariant === -1) {
|
|
30
30
|
return getGridEntities(GridEntityType.CRAWL_SPACE);
|
|
31
31
|
}
|
|
@@ -42,7 +42,9 @@ export function getCrawlSpaces(
|
|
|
42
42
|
* @param pitVariant Optional. If specified, will only get the pits that match the variant. Default
|
|
43
43
|
* is -1, which matches every variant.
|
|
44
44
|
*/
|
|
45
|
-
export function getPits(
|
|
45
|
+
export function getPits(
|
|
46
|
+
pitVariant: PitVariant | -1 = -1,
|
|
47
|
+
): readonly GridEntityPit[] {
|
|
46
48
|
const pits: GridEntityPit[] = [];
|
|
47
49
|
for (const gridEntity of getGridEntities()) {
|
|
48
50
|
const pit = gridEntity.ToPit();
|
|
@@ -65,7 +67,7 @@ export function getPits(pitVariant: PitVariant | -1 = -1): GridEntityPit[] {
|
|
|
65
67
|
*/
|
|
66
68
|
export function getPoops(
|
|
67
69
|
poopVariant: PoopGridEntityVariant | -1 = -1,
|
|
68
|
-
): GridEntityPoop[] {
|
|
70
|
+
): readonly GridEntityPoop[] {
|
|
69
71
|
const poops: GridEntityPoop[] = [];
|
|
70
72
|
for (const gridEntity of getGridEntities()) {
|
|
71
73
|
const poop = gridEntity.ToPoop();
|
|
@@ -88,7 +90,7 @@ export function getPoops(
|
|
|
88
90
|
*/
|
|
89
91
|
export function getPressurePlates(
|
|
90
92
|
pressurePlateVariant: PressurePlateVariant | -1 = -1,
|
|
91
|
-
): GridEntityPressurePlate[] {
|
|
93
|
+
): readonly GridEntityPressurePlate[] {
|
|
92
94
|
const pressurePlates: GridEntityPressurePlate[] = [];
|
|
93
95
|
for (const gridEntity of getGridEntities()) {
|
|
94
96
|
const pressurePlate = gridEntity.ToPressurePlate();
|
|
@@ -114,7 +116,7 @@ export function getPressurePlates(
|
|
|
114
116
|
* `RockVariant` enum, since that only applies to `GridEntityType.ROCK`, and other
|
|
115
117
|
* types of grid entities can be the `GridEntityRock` class.
|
|
116
118
|
*/
|
|
117
|
-
export function getRocks(variant = -1): GridEntityRock[] {
|
|
119
|
+
export function getRocks(variant = -1): readonly GridEntityRock[] {
|
|
118
120
|
const rocks: GridEntityRock[] = [];
|
|
119
121
|
for (const gridEntity of getGridEntities()) {
|
|
120
122
|
const rock = gridEntity.ToRock();
|
|
@@ -130,7 +132,7 @@ export function getRocks(variant = -1): GridEntityRock[] {
|
|
|
130
132
|
}
|
|
131
133
|
|
|
132
134
|
/** Helper function to get all of the `GridEntitySpikes` in the room. */
|
|
133
|
-
export function getSpikes(variant = -1): GridEntitySpikes[] {
|
|
135
|
+
export function getSpikes(variant = -1): readonly GridEntitySpikes[] {
|
|
134
136
|
const spikes: GridEntitySpikes[] = [];
|
|
135
137
|
for (const gridEntity of getGridEntities()) {
|
|
136
138
|
const spike = gridEntity.ToSpikes();
|
|
@@ -146,7 +148,7 @@ export function getSpikes(variant = -1): GridEntitySpikes[] {
|
|
|
146
148
|
}
|
|
147
149
|
|
|
148
150
|
/** Helper function to get all of the `GridEntityTNT` in the room. */
|
|
149
|
-
export function getTNT(variant = -1): GridEntityTNT[] {
|
|
151
|
+
export function getTNT(variant = -1): readonly GridEntityTNT[] {
|
|
150
152
|
const tntArray: GridEntityTNT[] = [];
|
|
151
153
|
for (const gridEntity of getGridEntities()) {
|
|
152
154
|
const tnt = gridEntity.ToTNT();
|
|
@@ -168,7 +170,7 @@ export function getTNT(variant = -1): GridEntityTNT[] {
|
|
|
168
170
|
* @param variant Optional. If specified, will only get the teleporters that match the variant.
|
|
169
171
|
* Default is -1, which matches every variant.
|
|
170
172
|
*/
|
|
171
|
-
export function getTeleporters(variant = -1): GridEntity[] {
|
|
173
|
+
export function getTeleporters(variant = -1): readonly GridEntity[] {
|
|
172
174
|
if (variant === -1) {
|
|
173
175
|
return getGridEntities(GridEntityType.TELEPORTER);
|
|
174
176
|
}
|
|
@@ -185,7 +187,7 @@ export function getTeleporters(variant = -1): GridEntity[] {
|
|
|
185
187
|
*/
|
|
186
188
|
export function getTrapdoors(
|
|
187
189
|
trapdoorVariant: TrapdoorVariant | -1 = -1,
|
|
188
|
-
): GridEntity[] {
|
|
190
|
+
): readonly GridEntity[] {
|
|
189
191
|
if (trapdoorVariant === -1) {
|
|
190
192
|
return getGridEntities(GridEntityType.TRAPDOOR);
|
|
191
193
|
}
|
|
@@ -208,7 +210,7 @@ export function removeAllCrawlSpaces(
|
|
|
208
210
|
crawlSpaceVariant: CrawlSpaceVariant | -1 = -1,
|
|
209
211
|
updateRoom = false,
|
|
210
212
|
cap?: int,
|
|
211
|
-
): GridEntity[] {
|
|
213
|
+
): readonly GridEntity[] {
|
|
212
214
|
const crawlSpaces = getCrawlSpaces(crawlSpaceVariant);
|
|
213
215
|
return removeGridEntities(crawlSpaces, updateRoom, cap);
|
|
214
216
|
}
|
|
@@ -231,7 +233,7 @@ export function removeAllPits(
|
|
|
231
233
|
pitVariant: PitVariant | -1 = -1,
|
|
232
234
|
updateRoom = false,
|
|
233
235
|
cap?: int,
|
|
234
|
-
): GridEntityPit[] {
|
|
236
|
+
): readonly GridEntityPit[] {
|
|
235
237
|
const pits = getPits(pitVariant);
|
|
236
238
|
return removeGridEntities(pits, updateRoom, cap);
|
|
237
239
|
}
|
|
@@ -254,7 +256,7 @@ export function removeAllPoops(
|
|
|
254
256
|
poopVariant: PoopGridEntityVariant | -1 = -1,
|
|
255
257
|
updateRoom = false,
|
|
256
258
|
cap?: int,
|
|
257
|
-
): GridEntityPoop[] {
|
|
259
|
+
): readonly GridEntityPoop[] {
|
|
258
260
|
const poops = getPoops(poopVariant);
|
|
259
261
|
return removeGridEntities(poops, updateRoom, cap);
|
|
260
262
|
}
|
|
@@ -274,7 +276,7 @@ export function removeAllPressurePlates(
|
|
|
274
276
|
pressurePlateVariant: PressurePlateVariant | -1 = -1,
|
|
275
277
|
updateRoom = false,
|
|
276
278
|
cap?: int,
|
|
277
|
-
): GridEntityPressurePlate[] {
|
|
279
|
+
): readonly GridEntityPressurePlate[] {
|
|
278
280
|
const pressurePlates = getPressurePlates(pressurePlateVariant);
|
|
279
281
|
return removeGridEntities(pressurePlates, updateRoom, cap);
|
|
280
282
|
}
|
|
@@ -296,7 +298,7 @@ export function removeAllRocks(
|
|
|
296
298
|
variant = -1,
|
|
297
299
|
updateRoom = false,
|
|
298
300
|
cap?: int,
|
|
299
|
-
): GridEntityRock[] {
|
|
301
|
+
): readonly GridEntityRock[] {
|
|
300
302
|
const rocks = getRocks(variant);
|
|
301
303
|
return removeGridEntities(rocks, updateRoom, cap);
|
|
302
304
|
}
|
|
@@ -316,7 +318,7 @@ export function removeAllSpikes(
|
|
|
316
318
|
variant = -1,
|
|
317
319
|
updateRoom = false,
|
|
318
320
|
cap?: int,
|
|
319
|
-
): GridEntitySpikes[] {
|
|
321
|
+
): readonly GridEntitySpikes[] {
|
|
320
322
|
const spikes = getSpikes(variant);
|
|
321
323
|
return removeGridEntities(spikes, updateRoom, cap);
|
|
322
324
|
}
|
|
@@ -336,7 +338,7 @@ export function removeAllTNT(
|
|
|
336
338
|
variant = -1,
|
|
337
339
|
updateRoom = false,
|
|
338
340
|
cap?: int,
|
|
339
|
-
): GridEntityTNT[] {
|
|
341
|
+
): readonly GridEntityTNT[] {
|
|
340
342
|
const tnt = getTNT(variant);
|
|
341
343
|
return removeGridEntities(tnt, updateRoom, cap);
|
|
342
344
|
}
|
|
@@ -356,7 +358,7 @@ export function removeAllTeleporters(
|
|
|
356
358
|
variant = -1,
|
|
357
359
|
updateRoom = false,
|
|
358
360
|
cap?: int,
|
|
359
|
-
): GridEntity[] {
|
|
361
|
+
): readonly GridEntity[] {
|
|
360
362
|
const teleporters = getTeleporters(variant);
|
|
361
363
|
return removeGridEntities(teleporters, updateRoom, cap);
|
|
362
364
|
}
|
|
@@ -376,7 +378,7 @@ export function removeAllTrapdoors(
|
|
|
376
378
|
trapdoorVariant: TrapdoorVariant | -1 = -1,
|
|
377
379
|
updateRoom = false,
|
|
378
380
|
cap?: int,
|
|
379
|
-
): GridEntity[] {
|
|
381
|
+
): readonly GridEntity[] {
|
|
380
382
|
const trapdoors = getTrapdoors(trapdoorVariant);
|
|
381
383
|
return removeGridEntities(trapdoors, updateRoom, cap);
|
|
382
384
|
}
|
package/src/functions/input.ts
CHANGED
|
@@ -65,7 +65,7 @@ export function controllerToString(controller: Controller): string | undefined {
|
|
|
65
65
|
*/
|
|
66
66
|
export function getMoveButtonActions(
|
|
67
67
|
controllerIndex: ControllerIndex,
|
|
68
|
-
): ButtonAction[] {
|
|
68
|
+
): readonly ButtonAction[] {
|
|
69
69
|
return MOVEMENT_BUTTON_ACTIONS.filter((buttonAction) =>
|
|
70
70
|
Input.IsActionPressed(buttonAction, controllerIndex),
|
|
71
71
|
);
|
|
@@ -78,7 +78,7 @@ export function getMoveButtonActions(
|
|
|
78
78
|
*/
|
|
79
79
|
export function getShootButtonActions(
|
|
80
80
|
controllerIndex: ControllerIndex,
|
|
81
|
-
): ButtonAction[] {
|
|
81
|
+
): readonly ButtonAction[] {
|
|
82
82
|
return SHOOTING_BUTTON_ACTIONS.filter((buttonAction) =>
|
|
83
83
|
Input.IsActionPressed(buttonAction, controllerIndex),
|
|
84
84
|
);
|
|
@@ -62,7 +62,7 @@ export function getDefaultCollectibleTypesInItemPool(
|
|
|
62
62
|
*/
|
|
63
63
|
export function getDefaultItemPoolsForCollectibleType(
|
|
64
64
|
collectibleType: CollectibleType,
|
|
65
|
-
): ItemPoolType[] {
|
|
65
|
+
): readonly ItemPoolType[] {
|
|
66
66
|
const collectibleItemPoolTypes: ItemPoolType[] = [];
|
|
67
67
|
|
|
68
68
|
const itemPoolTypes = game.IsGreedMode()
|
|
@@ -129,7 +129,7 @@ export function getJSONRoomOfVariant(
|
|
|
129
129
|
export function getJSONRoomsOfSubType(
|
|
130
130
|
jsonRooms: JSONRoom[] | readonly JSONRoom[],
|
|
131
131
|
subType: int,
|
|
132
|
-
): JSONRoom[] {
|
|
132
|
+
): readonly JSONRoom[] {
|
|
133
133
|
return jsonRooms.filter((jsonRoom) => {
|
|
134
134
|
const roomSubTypeString = jsonRoom.$.subtype;
|
|
135
135
|
const roomSubType = parseIntSafe(roomSubTypeString);
|
package/src/functions/level.ts
CHANGED
|
@@ -40,7 +40,7 @@ export function fillLevelWithRedRooms(): void {
|
|
|
40
40
|
* Note that this will only look at Boss Rooms inside of the grid, so e.g. Reverse Emperor card
|
|
41
41
|
* rooms will not count.
|
|
42
42
|
*/
|
|
43
|
-
export function getLevelBossIDs(): BossID[] {
|
|
43
|
+
export function getLevelBossIDs(): readonly BossID[] {
|
|
44
44
|
const roomsInsideGrid = getRoomsInsideGrid();
|
|
45
45
|
|
|
46
46
|
return filterMap(roomsInsideGrid, (roomDescriptor) =>
|
|
@@ -319,7 +319,7 @@ export function getRoomAdjacentGridIndexes(
|
|
|
319
319
|
*/
|
|
320
320
|
export function getRoomDescriptorsForType(
|
|
321
321
|
...roomTypes: RoomType[]
|
|
322
|
-
): RoomDescriptor[] {
|
|
322
|
+
): readonly RoomDescriptor[] {
|
|
323
323
|
const roomTypesSet = new Set<RoomType>(roomTypes);
|
|
324
324
|
|
|
325
325
|
const roomsInsideGrid = getRoomsInsideGrid();
|
package/src/functions/math.ts
CHANGED
|
@@ -35,7 +35,7 @@ export function getCircleDiscretizedPoints(
|
|
|
35
35
|
xMultiplier = 1,
|
|
36
36
|
yMultiplier = 1,
|
|
37
37
|
initialDirection = Direction.UP,
|
|
38
|
-
): Vector
|
|
38
|
+
): ReadonlyArray<Readonly<Vector>> {
|
|
39
39
|
const vector = directionToVector(initialDirection);
|
|
40
40
|
const initialPosition = vector.mul(radius);
|
|
41
41
|
const positions: Vector[] = [];
|
|
@@ -163,7 +163,7 @@ export function splitNumber(
|
|
|
163
163
|
num: int,
|
|
164
164
|
size: int,
|
|
165
165
|
startAtZero = false,
|
|
166
|
-
):
|
|
166
|
+
): ReadonlyArray<readonly [min: int, max: int]> {
|
|
167
167
|
if (num <= 0) {
|
|
168
168
|
error(
|
|
169
169
|
`The number to split needs to be a positive number and is instead: ${num}`,
|
|
@@ -16,6 +16,7 @@ import { repeat } from "./utils";
|
|
|
16
16
|
* const arrayWithArrays = newArray([0], 20); // Has 20 elements of an array with a 0 in it.
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
|
+
// eslint-disable-next-line isaacscript/no-mutable-array-return
|
|
19
20
|
export function newArray<T>(defaultValue: T, size: int): T[] {
|
|
20
21
|
const array: T[] = [];
|
|
21
22
|
repeat(size, () => {
|
package/src/functions/npcs.ts
CHANGED
|
@@ -66,7 +66,7 @@ export function getAliveNPCs(
|
|
|
66
66
|
variant = -1,
|
|
67
67
|
subType = -1,
|
|
68
68
|
ignoreFriendly = false,
|
|
69
|
-
): EntityNPC[] {
|
|
69
|
+
): readonly EntityNPC[] {
|
|
70
70
|
const npcs = getNPCs(entityType, variant, subType, ignoreFriendly);
|
|
71
71
|
return npcs.filter((npc) => !npc.IsDead() && !isAliveExceptionNPC(npc));
|
|
72
72
|
}
|
package/src/functions/pickups.ts
CHANGED
|
@@ -119,7 +119,7 @@ export function getKeyName(keySubType: KeySubType): string {
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
/** Helper function to get all of the red heart pickup entities in the room. */
|
|
122
|
-
export function getRedHearts(): EntityPickupHeart[] {
|
|
122
|
+
export function getRedHearts(): readonly EntityPickupHeart[] {
|
|
123
123
|
const hearts = getHearts();
|
|
124
124
|
return hearts.filter((heart) => RED_HEART_SUB_TYPES_SET.has(heart.SubType));
|
|
125
125
|
}
|
|
@@ -171,7 +171,7 @@ export function isRedHeartSubType(heartSubType: HeartSubType): boolean {
|
|
|
171
171
|
* @param cap Optional. If specified, will only remove the given amount of hearts.
|
|
172
172
|
* @returns The red hearts that were removed.
|
|
173
173
|
*/
|
|
174
|
-
export function removeAllRedHearts(cap?: int): EntityPickupHeart[] {
|
|
174
|
+
export function removeAllRedHearts(cap?: int): readonly EntityPickupHeart[] {
|
|
175
175
|
const redHearts = getRedHearts();
|
|
176
176
|
return removeEntities(redHearts, cap);
|
|
177
177
|
}
|
|
@@ -23,7 +23,7 @@ import { getPickups, removeAllPickups, spawnPickup } from "./entitiesSpecific";
|
|
|
23
23
|
*/
|
|
24
24
|
export function getBatteries(
|
|
25
25
|
batterySubType: BatterySubType | -1 = -1,
|
|
26
|
-
): EntityPickupBattery[] {
|
|
26
|
+
): readonly EntityPickupBattery[] {
|
|
27
27
|
return getPickups(
|
|
28
28
|
PickupVariant.LIL_BATTERY,
|
|
29
29
|
batterySubType,
|
|
@@ -39,7 +39,7 @@ export function getBatteries(
|
|
|
39
39
|
*/
|
|
40
40
|
export function getBombPickups(
|
|
41
41
|
bombSubType: BombSubType | -1 = -1,
|
|
42
|
-
): EntityPickupBomb[] {
|
|
42
|
+
): readonly EntityPickupBomb[] {
|
|
43
43
|
return getPickups(PickupVariant.BOMB, bombSubType) as EntityPickupBomb[];
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -49,7 +49,9 @@ export function getBombPickups(
|
|
|
49
49
|
* @param cardType Optional. If specified, will only get the cards that match the sub-type. Default
|
|
50
50
|
* is -1, which matches every sub-type.
|
|
51
51
|
*/
|
|
52
|
-
export function getCards(
|
|
52
|
+
export function getCards(
|
|
53
|
+
cardType: CardType | -1 = -1,
|
|
54
|
+
): readonly EntityPickupCard[] {
|
|
53
55
|
return getPickups(PickupVariant.CARD, cardType) as EntityPickupCard[];
|
|
54
56
|
}
|
|
55
57
|
|
|
@@ -60,7 +62,7 @@ export function getCards(cardType: CardType | -1 = -1): EntityPickupCard[] {
|
|
|
60
62
|
* @param subType Optional. If specified, will only get the chests that match the sub-type. Default
|
|
61
63
|
* is -1, which matches every sub-type.
|
|
62
64
|
*/
|
|
63
|
-
export function getChests(subType = -1): EntityPickup[] {
|
|
65
|
+
export function getChests(subType = -1): readonly EntityPickup[] {
|
|
64
66
|
const chests: EntityPickup[] = [];
|
|
65
67
|
|
|
66
68
|
for (const pickupVariant of CHEST_PICKUP_VARIANTS) {
|
|
@@ -79,7 +81,7 @@ export function getChests(subType = -1): EntityPickup[] {
|
|
|
79
81
|
*/
|
|
80
82
|
export function getCoins(
|
|
81
83
|
coinSubType: CoinSubType | -1 = -1,
|
|
82
|
-
): EntityPickupCoin[] {
|
|
84
|
+
): readonly EntityPickupCoin[] {
|
|
83
85
|
return getPickups(PickupVariant.COIN, coinSubType) as EntityPickupCoin[];
|
|
84
86
|
}
|
|
85
87
|
|
|
@@ -91,7 +93,7 @@ export function getCoins(
|
|
|
91
93
|
*/
|
|
92
94
|
export function getCollectibles(
|
|
93
95
|
collectibleType: CollectibleType | -1 = -1,
|
|
94
|
-
): EntityPickupCollectible[] {
|
|
96
|
+
): readonly EntityPickupCollectible[] {
|
|
95
97
|
return getPickups(
|
|
96
98
|
PickupVariant.COLLECTIBLE,
|
|
97
99
|
collectibleType,
|
|
@@ -106,7 +108,7 @@ export function getCollectibles(
|
|
|
106
108
|
*/
|
|
107
109
|
export function getHearts(
|
|
108
110
|
heartSubType: HeartSubType | -1 = -1,
|
|
109
|
-
): EntityPickupHeart[] {
|
|
111
|
+
): readonly EntityPickupHeart[] {
|
|
110
112
|
return getPickups(PickupVariant.HEART, heartSubType) as EntityPickupHeart[];
|
|
111
113
|
}
|
|
112
114
|
|
|
@@ -116,7 +118,9 @@ export function getHearts(
|
|
|
116
118
|
* @param keySubType Optional. If specified, will only get the keys that match the sub-type. Default
|
|
117
119
|
* is -1, which matches every sub-type.
|
|
118
120
|
*/
|
|
119
|
-
export function getKeys(
|
|
121
|
+
export function getKeys(
|
|
122
|
+
keySubType: KeySubType | -1 = -1,
|
|
123
|
+
): readonly EntityPickupKey[] {
|
|
120
124
|
return getPickups(PickupVariant.KEY, keySubType) as EntityPickupKey[];
|
|
121
125
|
}
|
|
122
126
|
|
|
@@ -126,7 +130,9 @@ export function getKeys(keySubType: KeySubType | -1 = -1): EntityPickupKey[] {
|
|
|
126
130
|
* @param pillColor Optional. If specified, will only get the pills that match the sub-type. Default
|
|
127
131
|
* is -1, which matches every sub-type.
|
|
128
132
|
*/
|
|
129
|
-
export function getPills(
|
|
133
|
+
export function getPills(
|
|
134
|
+
pillColor: PillColor | -1 = -1,
|
|
135
|
+
): readonly EntityPickupPill[] {
|
|
130
136
|
return getPickups(PickupVariant.PILL, pillColor) as EntityPickupPill[];
|
|
131
137
|
}
|
|
132
138
|
|
|
@@ -138,7 +144,7 @@ export function getPills(pillColor: PillColor | -1 = -1): EntityPickupPill[] {
|
|
|
138
144
|
*/
|
|
139
145
|
export function getSacks(
|
|
140
146
|
sackSubType: SackSubType | -1 = -1,
|
|
141
|
-
): EntityPickupSack[] {
|
|
147
|
+
): readonly EntityPickupSack[] {
|
|
142
148
|
return getPickups(PickupVariant.SACK, sackSubType) as EntityPickupSack[];
|
|
143
149
|
}
|
|
144
150
|
|
|
@@ -150,7 +156,7 @@ export function getSacks(
|
|
|
150
156
|
*/
|
|
151
157
|
export function getTrinkets(
|
|
152
158
|
trinketType: TrinketType | -1 = -1,
|
|
153
|
-
): EntityPickupTrinket[] {
|
|
159
|
+
): readonly EntityPickupTrinket[] {
|
|
154
160
|
return getPickups(
|
|
155
161
|
PickupVariant.TRINKET,
|
|
156
162
|
trinketType,
|
|
@@ -168,7 +174,7 @@ export function getTrinkets(
|
|
|
168
174
|
export function removeAllBatteries(
|
|
169
175
|
batterySubType: BatterySubType | -1 = -1,
|
|
170
176
|
cap?: int,
|
|
171
|
-
): EntityPickupBattery[] {
|
|
177
|
+
): readonly EntityPickupBattery[] {
|
|
172
178
|
return removeAllPickups(
|
|
173
179
|
PickupVariant.LIL_BATTERY,
|
|
174
180
|
batterySubType,
|
|
@@ -188,7 +194,7 @@ export function removeAllBatteries(
|
|
|
188
194
|
export function removeAllBombPickups(
|
|
189
195
|
bombSubType: BombSubType | -1 = -1,
|
|
190
196
|
cap?: int,
|
|
191
|
-
): EntityPickupBomb[] {
|
|
197
|
+
): readonly EntityPickupBomb[] {
|
|
192
198
|
return removeAllPickups(
|
|
193
199
|
PickupVariant.BOMB,
|
|
194
200
|
bombSubType,
|
|
@@ -207,7 +213,7 @@ export function removeAllBombPickups(
|
|
|
207
213
|
export function removeAllCards(
|
|
208
214
|
cardType: CardType | -1 = -1,
|
|
209
215
|
cap?: int,
|
|
210
|
-
): EntityPickupCard[] {
|
|
216
|
+
): readonly EntityPickupCard[] {
|
|
211
217
|
return removeAllPickups(
|
|
212
218
|
PickupVariant.CARD,
|
|
213
219
|
cardType,
|
|
@@ -224,7 +230,10 @@ export function removeAllCards(
|
|
|
224
230
|
* @param cap Optional. If specified, will only remove the given amount of chests.
|
|
225
231
|
* @returns The chests that were removed.
|
|
226
232
|
*/
|
|
227
|
-
export function removeAllChests(
|
|
233
|
+
export function removeAllChests(
|
|
234
|
+
subType = -1,
|
|
235
|
+
cap?: int,
|
|
236
|
+
): readonly EntityPickup[] {
|
|
228
237
|
const chests = getChests(subType);
|
|
229
238
|
return removeEntities(chests, cap);
|
|
230
239
|
}
|
|
@@ -240,7 +249,7 @@ export function removeAllChests(subType = -1, cap?: int): EntityPickup[] {
|
|
|
240
249
|
export function removeAllCoins(
|
|
241
250
|
coinSubType?: CoinSubType,
|
|
242
251
|
cap?: int,
|
|
243
|
-
): EntityPickupCoin[] {
|
|
252
|
+
): readonly EntityPickupCoin[] {
|
|
244
253
|
return removeAllPickups(
|
|
245
254
|
PickupVariant.COIN,
|
|
246
255
|
coinSubType,
|
|
@@ -259,7 +268,7 @@ export function removeAllCoins(
|
|
|
259
268
|
export function removeAllCollectibles(
|
|
260
269
|
collectibleType?: CollectibleType,
|
|
261
270
|
cap?: int,
|
|
262
|
-
): EntityPickupCollectible[] {
|
|
271
|
+
): readonly EntityPickupCollectible[] {
|
|
263
272
|
return removeAllPickups(
|
|
264
273
|
PickupVariant.COLLECTIBLE,
|
|
265
274
|
collectibleType,
|
|
@@ -278,7 +287,7 @@ export function removeAllCollectibles(
|
|
|
278
287
|
export function removeAllHearts(
|
|
279
288
|
heartSubType?: HeartSubType,
|
|
280
289
|
cap?: int,
|
|
281
|
-
): EntityPickupHeart[] {
|
|
290
|
+
): readonly EntityPickupHeart[] {
|
|
282
291
|
return removeAllPickups(
|
|
283
292
|
PickupVariant.HEART,
|
|
284
293
|
heartSubType,
|
|
@@ -297,7 +306,7 @@ export function removeAllHearts(
|
|
|
297
306
|
export function removeAllKeys(
|
|
298
307
|
keySubType?: KeySubType,
|
|
299
308
|
cap?: int,
|
|
300
|
-
): EntityPickupKey[] {
|
|
309
|
+
): readonly EntityPickupKey[] {
|
|
301
310
|
return removeAllPickups(
|
|
302
311
|
PickupVariant.KEY,
|
|
303
312
|
keySubType,
|
|
@@ -316,7 +325,7 @@ export function removeAllKeys(
|
|
|
316
325
|
export function removeAllPills(
|
|
317
326
|
pillColor?: PillColor,
|
|
318
327
|
cap?: int,
|
|
319
|
-
): EntityPickupPill[] {
|
|
328
|
+
): readonly EntityPickupPill[] {
|
|
320
329
|
return removeAllPickups(
|
|
321
330
|
PickupVariant.PILL,
|
|
322
331
|
pillColor,
|
|
@@ -335,7 +344,7 @@ export function removeAllPills(
|
|
|
335
344
|
export function removeAllSacks(
|
|
336
345
|
sackSubType?: SackSubType,
|
|
337
346
|
cap?: int,
|
|
338
|
-
): EntityPickupSack[] {
|
|
347
|
+
): readonly EntityPickupSack[] {
|
|
339
348
|
return removeAllPickups(
|
|
340
349
|
PickupVariant.SACK,
|
|
341
350
|
sackSubType,
|
|
@@ -354,7 +363,7 @@ export function removeAllSacks(
|
|
|
354
363
|
export function removeAllTrinkets(
|
|
355
364
|
trinketType?: TrinketType,
|
|
356
365
|
cap?: int,
|
|
357
|
-
): EntityPickupTrinket[] {
|
|
366
|
+
): readonly EntityPickupTrinket[] {
|
|
358
367
|
return removeAllPickups(
|
|
359
368
|
PickupVariant.TRINKET,
|
|
360
369
|
trinketType,
|
|
@@ -64,7 +64,7 @@ export function anyPlayerHasCollectible(
|
|
|
64
64
|
export function getActiveItemSlots(
|
|
65
65
|
player: EntityPlayer,
|
|
66
66
|
collectibleType: CollectibleType,
|
|
67
|
-
): ActiveSlot[] {
|
|
67
|
+
): readonly ActiveSlot[] {
|
|
68
68
|
return ACTIVE_SLOT_VALUES.filter((activeSlot) => {
|
|
69
69
|
const activeItem = player.GetActiveItem(activeSlot);
|
|
70
70
|
return activeItem === collectibleType;
|
|
@@ -112,7 +112,7 @@ export function getPlayerCollectibleCount(
|
|
|
112
112
|
*/
|
|
113
113
|
export function getPlayersWithCollectible(
|
|
114
114
|
...collectibleTypes: CollectibleType[]
|
|
115
|
-
): EntityPlayer[] {
|
|
115
|
+
): readonly EntityPlayer[] {
|
|
116
116
|
const players = getPlayers();
|
|
117
117
|
|
|
118
118
|
return players.filter((player) =>
|
|
@@ -43,7 +43,9 @@ export function anyPlayerHasTrinketEffect(trinketType: TrinketType): boolean {
|
|
|
43
43
|
* Helper function to get an array of temporary effects for a player. This is helpful so that you
|
|
44
44
|
* don't have to manually create an array from an `EffectsList` object.
|
|
45
45
|
*/
|
|
46
|
-
export function getEffectsList(
|
|
46
|
+
export function getEffectsList(
|
|
47
|
+
player: EntityPlayer,
|
|
48
|
+
): readonly TemporaryEffect[] {
|
|
47
49
|
const effects = player.GetEffects();
|
|
48
50
|
const effectsList = effects.GetEffectsList();
|
|
49
51
|
|
|
@@ -22,7 +22,7 @@ const EXCLUDED_CHARACTERS = new ReadonlySet<PlayerType>([
|
|
|
22
22
|
* This function is almost never what you want to use. For most purposes, use the `getPlayers`
|
|
23
23
|
* helper function instead to get a filtered list of players.
|
|
24
24
|
*/
|
|
25
|
-
export function getAllPlayers(): EntityPlayer[] {
|
|
25
|
+
export function getAllPlayers(): readonly EntityPlayer[] {
|
|
26
26
|
const numPlayers = game.GetNumPlayers();
|
|
27
27
|
|
|
28
28
|
const players: EntityPlayer[] = [];
|
|
@@ -38,7 +38,7 @@ export function getAllPlayers(): EntityPlayer[] {
|
|
|
38
38
|
* Helper function to get all of the other players in the room besides the one provided. (This
|
|
39
39
|
* includes "child" players.)
|
|
40
40
|
*/
|
|
41
|
-
export function getOtherPlayers(player: EntityPlayer): EntityPlayer[] {
|
|
41
|
+
export function getOtherPlayers(player: EntityPlayer): readonly EntityPlayer[] {
|
|
42
42
|
const playerPtrHash = GetPtrHash(player);
|
|
43
43
|
const players = getAllPlayers();
|
|
44
44
|
return players.filter(
|
|
@@ -170,7 +170,9 @@ export function getPlayerIndexVanilla(
|
|
|
170
170
|
* @param performCharacterExclusions Whether to exclude characters that are not directly controlled
|
|
171
171
|
* by the player (i.e. Esau & Tainted Soul). Default is false.
|
|
172
172
|
*/
|
|
173
|
-
export function getPlayers(
|
|
173
|
+
export function getPlayers(
|
|
174
|
+
performCharacterExclusions = false,
|
|
175
|
+
): readonly EntityPlayer[] {
|
|
174
176
|
const players = getAllPlayers();
|
|
175
177
|
const nonChildPlayers = players.filter((player) => !isChildPlayer(player));
|
|
176
178
|
const nonChildPlayersFiltered = nonChildPlayers.filter((player) => {
|
package/src/functions/players.ts
CHANGED
|
@@ -102,7 +102,7 @@ export function getAzazelBrimstoneDistance(
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
/** Helper function to get an array containing the characters of all of the current players. */
|
|
105
|
-
export function getCharacters(): PlayerType[] {
|
|
105
|
+
export function getCharacters(): readonly PlayerType[] {
|
|
106
106
|
const players = getPlayers();
|
|
107
107
|
return players.map((player) => player.GetPlayerType());
|
|
108
108
|
}
|
|
@@ -270,7 +270,9 @@ export function getPlayerNumHitsRemaining(player: EntityPlayer): int {
|
|
|
270
270
|
* This function is variadic, meaning that you can supply as many characters as you want to check
|
|
271
271
|
* for. Returns true if any of the characters supplied are present.
|
|
272
272
|
*/
|
|
273
|
-
export function getPlayersOfType(
|
|
273
|
+
export function getPlayersOfType(
|
|
274
|
+
...characters: PlayerType[]
|
|
275
|
+
): readonly EntityPlayer[] {
|
|
274
276
|
const charactersSet = new ReadonlySet(characters);
|
|
275
277
|
const players = getPlayers();
|
|
276
278
|
|
|
@@ -288,7 +290,7 @@ export function getPlayersOfType(...characters: PlayerType[]): EntityPlayer[] {
|
|
|
288
290
|
* Note that this function includes players with a non-undefined parent like e.g. the Strawman
|
|
289
291
|
* Keeper.
|
|
290
292
|
*/
|
|
291
|
-
export function getPlayersOnKeyboard(): EntityPlayer[] {
|
|
293
|
+
export function getPlayersOnKeyboard(): readonly EntityPlayer[] {
|
|
292
294
|
const players = getAllPlayers();
|
|
293
295
|
|
|
294
296
|
return players.filter(
|
|
@@ -306,7 +308,7 @@ export function getPlayersOnKeyboard(): EntityPlayer[] {
|
|
|
306
308
|
*/
|
|
307
309
|
export function getPlayersWithControllerIndex(
|
|
308
310
|
controllerIndex: ControllerIndex,
|
|
309
|
-
): EntityPlayer[] {
|
|
311
|
+
): readonly EntityPlayer[] {
|
|
310
312
|
const players = getAllPlayers();
|
|
311
313
|
return players.filter((player) => player.ControllerIndex === controllerIndex);
|
|
312
314
|
}
|
|
@@ -72,7 +72,9 @@ export function getFirstPill(
|
|
|
72
72
|
* cannot determine the identity of a particular slot, it will mark the type of the slot as
|
|
73
73
|
* `PocketItemType.UNDETERMINABLE`.
|
|
74
74
|
*/
|
|
75
|
-
export function getPocketItems(
|
|
75
|
+
export function getPocketItems(
|
|
76
|
+
player: EntityPlayer,
|
|
77
|
+
): readonly PocketItemDescription[] {
|
|
76
78
|
const pocketItem = player.GetActiveItem(ActiveSlot.POCKET);
|
|
77
79
|
const hasPocketItem = pocketItem !== CollectibleType.NULL;
|
|
78
80
|
|
|
@@ -171,8 +173,8 @@ export function isFirstSlotPocketActiveItem(player: EntityPlayer): boolean {
|
|
|
171
173
|
|
|
172
174
|
/** Helper function to see if two sets of pocket item descriptions are identical. */
|
|
173
175
|
export function pocketItemsEquals(
|
|
174
|
-
pocketItems1: PocketItemDescription[],
|
|
175
|
-
pocketItems2: PocketItemDescription[],
|
|
176
|
+
pocketItems1: PocketItemDescription[] | readonly PocketItemDescription[],
|
|
177
|
+
pocketItems2: PocketItemDescription[] | readonly PocketItemDescription[],
|
|
176
178
|
): boolean {
|
|
177
179
|
if (pocketItems1.length !== pocketItems2.length) {
|
|
178
180
|
return false;
|
|
@@ -12,7 +12,7 @@ import { getPlayerCloserThan } from "./players";
|
|
|
12
12
|
const MAX_FIND_FREE_POSITION_ATTEMPTS = 100;
|
|
13
13
|
|
|
14
14
|
export function anyEntityCloserThan(
|
|
15
|
-
entities: Entity[],
|
|
15
|
+
entities: Entity[] | readonly Entity[],
|
|
16
16
|
position: Vector,
|
|
17
17
|
distance: int,
|
|
18
18
|
): boolean {
|
|
@@ -109,7 +109,9 @@ export function findFreePosition(
|
|
|
109
109
|
* this with cached entities to avoid invoking the `Isaac.GetRoomEntities` method
|
|
110
110
|
* multiple times.
|
|
111
111
|
*/
|
|
112
|
-
export function getEntityPositions(
|
|
112
|
+
export function getEntityPositions(
|
|
113
|
+
entities?: Entity[] | readonly Entity[],
|
|
114
|
+
): Map<PtrHash, Vector> {
|
|
113
115
|
if (entities === undefined) {
|
|
114
116
|
entities = getEntities();
|
|
115
117
|
}
|
|
@@ -132,7 +134,9 @@ export function getEntityPositions(entities?: Entity[]): Map<PtrHash, Vector> {
|
|
|
132
134
|
* this with cached entities to avoid invoking the `Isaac.GetRoomEntities` method
|
|
133
135
|
* multiple times.
|
|
134
136
|
*/
|
|
135
|
-
export function getEntityVelocities(
|
|
137
|
+
export function getEntityVelocities(
|
|
138
|
+
entities?: Entity[] | readonly Entity[],
|
|
139
|
+
): Map<PtrHash, Vector> {
|
|
136
140
|
if (entities === undefined) {
|
|
137
141
|
entities = getEntities();
|
|
138
142
|
}
|
|
@@ -161,7 +165,7 @@ export function getEntityVelocities(entities?: Entity[]): Map<PtrHash, Vector> {
|
|
|
161
165
|
*/
|
|
162
166
|
export function setEntityPositions(
|
|
163
167
|
entityPositions: Map<PtrHash, Vector>,
|
|
164
|
-
entities?: Entity[],
|
|
168
|
+
entities?: Entity[] | readonly Entity[],
|
|
165
169
|
): void {
|
|
166
170
|
if (entities === undefined) {
|
|
167
171
|
entities = getEntities();
|
|
@@ -191,7 +195,7 @@ export function setEntityPositions(
|
|
|
191
195
|
*/
|
|
192
196
|
export function setEntityVelocities(
|
|
193
197
|
entityVelocities: Map<PtrHash, Vector>,
|
|
194
|
-
entities?: Entity[],
|
|
198
|
+
entities?: Entity[] | readonly Entity[],
|
|
195
199
|
): void {
|
|
196
200
|
if (entities === undefined) {
|
|
197
201
|
entities = getEntities();
|