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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
--[[
|
|
2
2
|
|
|
3
|
-
isaacscript-common 80.2.
|
|
3
|
+
isaacscript-common 80.2.5
|
|
4
4
|
|
|
5
5
|
This is the "isaacscript-common" library, which was created with the IsaacScript tool.
|
|
6
6
|
|
|
@@ -27717,7 +27717,8 @@ end
|
|
|
27717
27717
|
-- to an `InitCharge` value of -1. However, in some cases, this may be different. For example,
|
|
27718
27718
|
-- Eden's Soul starts without any charges, so it has an `InitCharge` value of 0.
|
|
27719
27719
|
--
|
|
27720
|
-
-- This function returns 0 if the provided collectible type was not valid.
|
|
27720
|
+
-- This function returns 0 if the provided collectible type was not valid. This function returns -1
|
|
27721
|
+
-- if the provided collectible type was not an active collectible.
|
|
27721
27722
|
function ____exports.getCollectibleInitCharge(self, collectibleOrCollectibleType)
|
|
27722
27723
|
local collectibleType = getCollectibleTypeFromArg(nil, collectibleOrCollectibleType, "getCollectibleInitCharge")
|
|
27723
27724
|
local itemConfigItem = itemConfig:GetCollectible(collectibleType)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isaacscript-common",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "81.0.0",
|
|
4
4
|
"description": "Helper functions and features for IsaacScript mods.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"isaac",
|
|
@@ -37,6 +37,6 @@
|
|
|
37
37
|
"lint": "tsx --tsconfig ./scripts/tsconfig.json ./scripts/lint.mts"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"isaac-typescript-definitions": "^39.0.
|
|
40
|
+
"isaac-typescript-definitions": "^39.0.5"
|
|
41
41
|
}
|
|
42
42
|
}
|
|
@@ -412,7 +412,7 @@ export class ModUpgraded implements Mod {
|
|
|
412
412
|
* called from the "upgradeMod" function, but we want to mark it as private so that end-users
|
|
413
413
|
* don't have access to it.
|
|
414
414
|
*/
|
|
415
|
-
private initOptionalFeature(feature: ISCFeature): FunctionTuple[] {
|
|
415
|
+
private initOptionalFeature(feature: ISCFeature): readonly FunctionTuple[] {
|
|
416
416
|
const featureClass = this.features[feature];
|
|
417
417
|
this.initFeature(featureClass);
|
|
418
418
|
|
|
@@ -427,7 +427,9 @@ export class ModUpgraded implements Mod {
|
|
|
427
427
|
* Exported methods are stored in an internal static array on the class that is created by the
|
|
428
428
|
* decorator.
|
|
429
429
|
*/
|
|
430
|
-
function getExportedMethodsFromFeature(
|
|
430
|
+
function getExportedMethodsFromFeature(
|
|
431
|
+
featureClass: unknown,
|
|
432
|
+
): readonly FunctionTuple[] {
|
|
431
433
|
const constructor = getTSTLClassConstructor(featureClass) as Record<
|
|
432
434
|
string,
|
|
433
435
|
unknown
|
package/src/functions/array.ts
CHANGED
|
@@ -34,6 +34,7 @@ export function arrayEquals<T>(
|
|
|
34
34
|
* matching element. If you want to remove all of the elements, use the `arrayRemoveAll` function
|
|
35
35
|
* instead.
|
|
36
36
|
*/
|
|
37
|
+
// eslint-disable-next-line isaacscript/no-mutable-array-return
|
|
37
38
|
export function arrayRemove<T>(
|
|
38
39
|
originalArray: T[] | readonly T[],
|
|
39
40
|
...elementsToRemove: T[]
|
|
@@ -61,6 +62,7 @@ export function arrayRemove<T>(
|
|
|
61
62
|
* element. If you want to only remove the first matching element, use the `arrayRemove` function
|
|
62
63
|
* instead.
|
|
63
64
|
*/
|
|
65
|
+
// eslint-disable-next-line isaacscript/no-mutable-array-return
|
|
64
66
|
export function arrayRemoveAll<T>(
|
|
65
67
|
originalArray: T[] | readonly T[],
|
|
66
68
|
...elementsToRemove: T[]
|
|
@@ -113,6 +115,7 @@ export function arrayRemoveAllInPlace<T>(
|
|
|
113
115
|
*
|
|
114
116
|
* @returns The removed elements. This will be an empty array if no elements were removed.
|
|
115
117
|
*/
|
|
118
|
+
// eslint-disable-next-line isaacscript/no-mutable-array-return
|
|
116
119
|
export function arrayRemoveInPlace<T>(
|
|
117
120
|
array: T[],
|
|
118
121
|
...elementsToRemove: T[]
|
|
@@ -137,6 +140,7 @@ export function arrayRemoveInPlace<T>(
|
|
|
137
140
|
*
|
|
138
141
|
* This function is variadic, meaning that you can specify N arguments to remove N elements.
|
|
139
142
|
*/
|
|
143
|
+
// eslint-disable-next-line isaacscript/no-mutable-array-return
|
|
140
144
|
export function arrayRemoveIndex<T>(
|
|
141
145
|
originalArray: T[] | readonly T[],
|
|
142
146
|
...indexesToRemove: int[]
|
|
@@ -161,6 +165,7 @@ export function arrayRemoveIndex<T>(
|
|
|
161
165
|
*
|
|
162
166
|
* @returns The removed elements. This will be an empty array if no elements were removed.
|
|
163
167
|
*/
|
|
168
|
+
// eslint-disable-next-line isaacscript/no-mutable-array-return
|
|
164
169
|
export function arrayRemoveIndexInPlace<T>(
|
|
165
170
|
array: T[],
|
|
166
171
|
...indexesToRemove: int[]
|
|
@@ -203,6 +208,7 @@ export function arrayToString(array: unknown[]): string {
|
|
|
203
208
|
* This function is variadic, meaning that you can specify N arguments to combine N arrays. Note
|
|
204
209
|
* that this will only perform a shallow copy of the array elements.
|
|
205
210
|
*/
|
|
211
|
+
// eslint-disable-next-line isaacscript/no-mutable-array-return
|
|
206
212
|
export function combineArrays<T>(...arrays: Array<T[] | readonly T[]>): T[] {
|
|
207
213
|
const elements: T[] = [];
|
|
208
214
|
for (const array of arrays) {
|
|
@@ -221,6 +227,7 @@ export function combineArrays<T>(...arrays: Array<T[] | readonly T[]>): T[] {
|
|
|
221
227
|
* @param numElements Optional. If specified, will only copy the first N elements. By default, the
|
|
222
228
|
* entire array will be copied.
|
|
223
229
|
*/
|
|
230
|
+
// eslint-disable-next-line isaacscript/no-mutable-array-return
|
|
224
231
|
export function copyArray<T>(
|
|
225
232
|
oldArray: T[] | readonly T[],
|
|
226
233
|
numElements?: int,
|
|
@@ -256,6 +263,7 @@ export function emptyArray<T>(array: T[]): void {
|
|
|
256
263
|
* This is named `filterMap` after the Rust function:
|
|
257
264
|
* https://doc.rust-lang.org/std/iter/struct.FilterMap.html
|
|
258
265
|
*/
|
|
266
|
+
// eslint-disable-next-line isaacscript/no-mutable-array-return
|
|
259
267
|
export function filterMap<OldT, NewT>(
|
|
260
268
|
array: OldT[] | readonly OldT[],
|
|
261
269
|
func: (element: OldT) => NewT | undefined,
|
|
@@ -353,7 +361,7 @@ function addCombinations<T>(
|
|
|
353
361
|
* due to implementation details of TypeScriptToLua, this results in an array of 1 through N
|
|
354
362
|
* (instead of an array of 0 through N -1).
|
|
355
363
|
*/
|
|
356
|
-
export function getArrayIndexes<T>(array: T[] | readonly T[]): int[] {
|
|
364
|
+
export function getArrayIndexes<T>(array: T[] | readonly T[]): readonly int[] {
|
|
357
365
|
return eRange(array.length);
|
|
358
366
|
}
|
|
359
367
|
|
|
@@ -599,6 +607,7 @@ export function setAllArrayElements<T>(array: T[], value: T): void {
|
|
|
599
607
|
* `RNG.Next` method will be called. If `undefined` is provided, it will default to
|
|
600
608
|
* a random seed.
|
|
601
609
|
*/
|
|
610
|
+
// eslint-disable-next-line isaacscript/no-mutable-array-return
|
|
602
611
|
export function shuffleArray<T>(
|
|
603
612
|
originalArray: T[] | readonly T[],
|
|
604
613
|
seedOrRNG: Seed | RNG | undefined,
|
|
@@ -30,7 +30,7 @@ export function every<T>(
|
|
|
30
30
|
export function filter<T>(
|
|
31
31
|
array: T[],
|
|
32
32
|
func: (value: T, index: number, array: T[]) => boolean,
|
|
33
|
-
): T[] {
|
|
33
|
+
): readonly T[] {
|
|
34
34
|
return array.filter(func);
|
|
35
35
|
}
|
|
36
36
|
|
|
@@ -79,7 +79,7 @@ export function join<T>(array: T[], separator: string): string {
|
|
|
79
79
|
export function map<T, U>(
|
|
80
80
|
array: T[],
|
|
81
81
|
func: (value: T, index: number, array: T[]) => U,
|
|
82
|
-
): U[] {
|
|
82
|
+
): readonly U[] {
|
|
83
83
|
return array.map(func);
|
|
84
84
|
}
|
|
85
85
|
|
|
@@ -16,7 +16,7 @@ import { log } from "./log";
|
|
|
16
16
|
export function benchmark(
|
|
17
17
|
numTrials: int,
|
|
18
18
|
...functions: Array<() => void>
|
|
19
|
-
): int[] {
|
|
19
|
+
): readonly int[] {
|
|
20
20
|
log(`Benchmarking ${functions.length} function(s) with ${numTrials} trials.`);
|
|
21
21
|
|
|
22
22
|
const averages: int[] = [];
|
package/src/functions/bitwise.ts
CHANGED
|
@@ -28,7 +28,10 @@ export function convertBinaryToDecimal(bits: int[]): number {
|
|
|
28
28
|
* side until the minimum length is met. Default is undefined (which will not cause
|
|
29
29
|
* any padding).
|
|
30
30
|
*/
|
|
31
|
-
export function convertDecimalToBinary(
|
|
31
|
+
export function convertDecimalToBinary(
|
|
32
|
+
num: number,
|
|
33
|
+
minLength?: int,
|
|
34
|
+
): readonly int[] {
|
|
32
35
|
const bits: int[] = [];
|
|
33
36
|
|
|
34
37
|
const bitsString = num.toString(2);
|
package/src/functions/bosses.ts
CHANGED
|
@@ -55,7 +55,7 @@ export function getAliveBosses(
|
|
|
55
55
|
variant = -1,
|
|
56
56
|
subType = -1,
|
|
57
57
|
ignoreFriendly = false,
|
|
58
|
-
): EntityNPC[] {
|
|
58
|
+
): readonly EntityNPC[] {
|
|
59
59
|
const aliveNPCs = getAliveNPCs(entityType, variant, subType, ignoreFriendly);
|
|
60
60
|
return aliveNPCs.filter((aliveNPC) => aliveNPC.IsBoss());
|
|
61
61
|
}
|
|
@@ -175,7 +175,7 @@ export function getBosses(
|
|
|
175
175
|
variant?: int,
|
|
176
176
|
subType?: int,
|
|
177
177
|
ignoreFriendly = false,
|
|
178
|
-
): EntityNPC[] {
|
|
178
|
+
): readonly EntityNPC[] {
|
|
179
179
|
const npcs = getNPCs(entityType, variant, subType, ignoreFriendly);
|
|
180
180
|
return npcs.filter((npc) => npc.IsBoss());
|
|
181
181
|
}
|
package/src/functions/charge.ts
CHANGED
|
@@ -247,7 +247,7 @@ export function getTotalCharge(
|
|
|
247
247
|
export function getUsableActiveItemSlots(
|
|
248
248
|
player: EntityPlayer,
|
|
249
249
|
collectibleType: CollectibleType,
|
|
250
|
-
): ActiveSlot[] {
|
|
250
|
+
): readonly ActiveSlot[] {
|
|
251
251
|
const maxCharges = getCollectibleMaxCharges(collectibleType);
|
|
252
252
|
const activeSlots = getActiveItemSlots(player, collectibleType);
|
|
253
253
|
return activeSlots.filter((activeSlot) => {
|
|
@@ -283,7 +283,8 @@ export function getCollectibleGfxFilename(
|
|
|
283
283
|
* to an `InitCharge` value of -1. However, in some cases, this may be different. For example,
|
|
284
284
|
* Eden's Soul starts without any charges, so it has an `InitCharge` value of 0.
|
|
285
285
|
*
|
|
286
|
-
* This function returns 0 if the provided collectible type was not valid.
|
|
286
|
+
* This function returns 0 if the provided collectible type was not valid. This function returns -1
|
|
287
|
+
* if the provided collectible type was not an active collectible.
|
|
287
288
|
*/
|
|
288
289
|
export function getCollectibleInitCharge(
|
|
289
290
|
collectibleOrCollectibleType: EntityPickup | CollectibleType,
|
package/src/functions/doors.ts
CHANGED
|
@@ -58,7 +58,7 @@ export function doorSlotFlagToDoorSlot(doorSlotFlag: DoorSlotFlag): DoorSlot {
|
|
|
58
58
|
|
|
59
59
|
export function doorSlotFlagsToDoorSlots(
|
|
60
60
|
doorSlotFlags: BitFlags<DoorSlotFlag>,
|
|
61
|
-
): DoorSlot[] {
|
|
61
|
+
): readonly DoorSlot[] {
|
|
62
62
|
const doorSlots: DoorSlot[] = [];
|
|
63
63
|
|
|
64
64
|
for (const doorSlotFlag of DOOR_SLOT_FLAG_VALUES) {
|
|
@@ -204,7 +204,7 @@ export function getDoorSlotsForRoomShape(
|
|
|
204
204
|
*
|
|
205
205
|
* @allowEmptyVariadic
|
|
206
206
|
*/
|
|
207
|
-
export function getDoors(...roomTypes: RoomType[]): GridEntityDoor[] {
|
|
207
|
+
export function getDoors(...roomTypes: RoomType[]): readonly GridEntityDoor[] {
|
|
208
208
|
const room = game.GetRoom();
|
|
209
209
|
const roomShape = room.GetRoomShape();
|
|
210
210
|
const roomTypesSet = new ReadonlySet(roomTypes);
|
|
@@ -240,7 +240,9 @@ export function getDoors(...roomTypes: RoomType[]): GridEntityDoor[] {
|
|
|
240
240
|
* This function is variadic, meaning that you can specify N arguments to return all of the doors
|
|
241
241
|
* that match any of the N room grid indexes.
|
|
242
242
|
*/
|
|
243
|
-
export function getDoorsToRoomIndex(
|
|
243
|
+
export function getDoorsToRoomIndex(
|
|
244
|
+
...roomGridIndex: int[]
|
|
245
|
+
): readonly GridEntityDoor[] {
|
|
244
246
|
const roomGridIndexesSet = new ReadonlySet(roomGridIndex);
|
|
245
247
|
const doors = getDoors();
|
|
246
248
|
return doors.filter((door) => roomGridIndexesSet.has(door.TargetRoomIndex));
|
|
@@ -320,7 +322,7 @@ export function getRoomShapeDoorSlotCoordinates(
|
|
|
320
322
|
* Helper function to find unused door slots in the current room that can be used to make custom
|
|
321
323
|
* doors.
|
|
322
324
|
*/
|
|
323
|
-
export function getUnusedDoorSlots(): DoorSlot[] {
|
|
325
|
+
export function getUnusedDoorSlots(): readonly DoorSlot[] {
|
|
324
326
|
const room = game.GetRoom();
|
|
325
327
|
|
|
326
328
|
return DOOR_SLOT_VALUES.filter(
|
|
@@ -241,7 +241,7 @@ export function getEntities(
|
|
|
241
241
|
variant = -1,
|
|
242
242
|
subType = -1,
|
|
243
243
|
ignoreFriendly = false,
|
|
244
|
-
): Entity[] {
|
|
244
|
+
): readonly Entity[] {
|
|
245
245
|
if (entityType === -1) {
|
|
246
246
|
return Isaac.GetRoomEntities();
|
|
247
247
|
}
|
|
@@ -345,9 +345,9 @@ export function getEntityIDFromConstituents(
|
|
|
345
345
|
* second array but not in the first array.
|
|
346
346
|
*/
|
|
347
347
|
export function getFilteredNewEntities<T extends AnyEntity>(
|
|
348
|
-
oldEntities: T[],
|
|
349
|
-
newEntities: T[],
|
|
350
|
-
): T[] {
|
|
348
|
+
oldEntities: T[] | readonly T[],
|
|
349
|
+
newEntities: T[] | readonly T[],
|
|
350
|
+
): readonly T[] {
|
|
351
351
|
const oldEntitiesSet = new Set<PtrHash>();
|
|
352
352
|
for (const entity of oldEntities) {
|
|
353
353
|
const ptrHash = GetPtrHash(entity);
|
|
@@ -549,7 +549,7 @@ export function removeAllMatchingEntities(
|
|
|
549
549
|
entityVariant = -1,
|
|
550
550
|
entitySubType = -1,
|
|
551
551
|
cap: int | undefined = undefined,
|
|
552
|
-
): Entity[] {
|
|
552
|
+
): readonly Entity[] {
|
|
553
553
|
const entities = getEntities(entityType, entityVariant, entitySubType);
|
|
554
554
|
return removeEntities(entities, cap);
|
|
555
555
|
}
|
|
@@ -562,9 +562,9 @@ export function removeAllMatchingEntities(
|
|
|
562
562
|
* @returns An array of the entities that were removed.
|
|
563
563
|
*/
|
|
564
564
|
export function removeEntities<T extends AnyEntity>(
|
|
565
|
-
entities: T[],
|
|
565
|
+
entities: T[] | readonly T[],
|
|
566
566
|
cap?: int,
|
|
567
|
-
): T[] {
|
|
567
|
+
): readonly T[] {
|
|
568
568
|
if (entities.length === 0) {
|
|
569
569
|
return [];
|
|
570
570
|
}
|
|
@@ -35,7 +35,7 @@ import { assertDefined } from "./utils";
|
|
|
35
35
|
export function getBombs(
|
|
36
36
|
bombVariant: BombVariant | -1 = -1,
|
|
37
37
|
subType = -1,
|
|
38
|
-
): EntityBomb[] {
|
|
38
|
+
): readonly EntityBomb[] {
|
|
39
39
|
const entities = getEntities(EntityType.BOMB, bombVariant, subType);
|
|
40
40
|
|
|
41
41
|
const bombs: EntityBomb[] = [];
|
|
@@ -69,7 +69,7 @@ export function getBombs(
|
|
|
69
69
|
export function getEffects(
|
|
70
70
|
effectVariant: EffectVariant | -1 = -1,
|
|
71
71
|
subType = -1,
|
|
72
|
-
): EntityEffect[] {
|
|
72
|
+
): readonly EntityEffect[] {
|
|
73
73
|
const entities = getEntities(EntityType.EFFECT, effectVariant, subType);
|
|
74
74
|
|
|
75
75
|
const effects: EntityEffect[] = [];
|
|
@@ -103,7 +103,7 @@ export function getEffects(
|
|
|
103
103
|
export function getFamiliars(
|
|
104
104
|
familiarVariant: FamiliarVariant | -1 = -1,
|
|
105
105
|
subType = -1,
|
|
106
|
-
): EntityFamiliar[] {
|
|
106
|
+
): readonly EntityFamiliar[] {
|
|
107
107
|
const entities = getEntities(EntityType.FAMILIAR, familiarVariant, subType);
|
|
108
108
|
|
|
109
109
|
const familiars: EntityFamiliar[] = [];
|
|
@@ -137,7 +137,7 @@ export function getFamiliars(
|
|
|
137
137
|
export function getKnives(
|
|
138
138
|
knifeVariant: KnifeVariant | -1 = -1,
|
|
139
139
|
subType = -1,
|
|
140
|
-
): EntityKnife[] {
|
|
140
|
+
): readonly EntityKnife[] {
|
|
141
141
|
const entities = getEntities(EntityType.KNIFE, knifeVariant, subType);
|
|
142
142
|
|
|
143
143
|
const knives: EntityKnife[] = [];
|
|
@@ -171,7 +171,7 @@ export function getKnives(
|
|
|
171
171
|
export function getLasers(
|
|
172
172
|
laserVariant: LaserVariant | -1 = -1,
|
|
173
173
|
subType = -1,
|
|
174
|
-
): EntityLaser[] {
|
|
174
|
+
): readonly EntityLaser[] {
|
|
175
175
|
const entities = getEntities(EntityType.LASER, laserVariant, subType);
|
|
176
176
|
|
|
177
177
|
const lasers: EntityLaser[] = [];
|
|
@@ -203,7 +203,7 @@ export function getNPCs(
|
|
|
203
203
|
variant = -1,
|
|
204
204
|
subType = -1,
|
|
205
205
|
ignoreFriendly = false,
|
|
206
|
-
): EntityNPC[] {
|
|
206
|
+
): readonly EntityNPC[] {
|
|
207
207
|
const entities = getEntities(entityType, variant, subType, ignoreFriendly);
|
|
208
208
|
|
|
209
209
|
const npcs: EntityNPC[] = [];
|
|
@@ -237,7 +237,7 @@ export function getNPCs(
|
|
|
237
237
|
export function getPickups(
|
|
238
238
|
pickupVariant: PickupVariant | -1 = -1,
|
|
239
239
|
subType = -1,
|
|
240
|
-
): EntityPickup[] {
|
|
240
|
+
): readonly EntityPickup[] {
|
|
241
241
|
const entities = getEntities(EntityType.PICKUP, pickupVariant, subType);
|
|
242
242
|
|
|
243
243
|
const pickups: EntityPickup[] = [];
|
|
@@ -271,7 +271,7 @@ export function getPickups(
|
|
|
271
271
|
export function getProjectiles(
|
|
272
272
|
projectileVariant: ProjectileVariant | -1 = -1,
|
|
273
273
|
subType = -1,
|
|
274
|
-
): EntityProjectile[] {
|
|
274
|
+
): readonly EntityProjectile[] {
|
|
275
275
|
const entities = getEntities(
|
|
276
276
|
EntityType.PROJECTILE,
|
|
277
277
|
projectileVariant,
|
|
@@ -309,7 +309,7 @@ export function getProjectiles(
|
|
|
309
309
|
export function getSlots(
|
|
310
310
|
slotVariant: SlotVariant | -1 = -1,
|
|
311
311
|
subType = -1,
|
|
312
|
-
): EntitySlot[] {
|
|
312
|
+
): readonly EntitySlot[] {
|
|
313
313
|
const slots = getEntities(EntityType.SLOT, slotVariant, subType);
|
|
314
314
|
|
|
315
315
|
return slots as EntitySlot[];
|
|
@@ -335,7 +335,7 @@ export function getSlots(
|
|
|
335
335
|
export function getTears(
|
|
336
336
|
tearVariant: TearVariant | -1 = -1,
|
|
337
337
|
subType = -1,
|
|
338
|
-
): EntityTear[] {
|
|
338
|
+
): readonly EntityTear[] {
|
|
339
339
|
const entities = getEntities(EntityType.TEAR, tearVariant, subType);
|
|
340
340
|
|
|
341
341
|
const tears: EntityTear[] = [];
|
|
@@ -364,7 +364,7 @@ export function removeAllBombs(
|
|
|
364
364
|
bombVariant: BombVariant | -1 = -1,
|
|
365
365
|
subType = -1,
|
|
366
366
|
cap?: int,
|
|
367
|
-
): EntityBomb[] {
|
|
367
|
+
): readonly EntityBomb[] {
|
|
368
368
|
const bombs = getBombs(bombVariant, subType);
|
|
369
369
|
return removeEntities(bombs, cap);
|
|
370
370
|
}
|
|
@@ -383,7 +383,7 @@ export function removeAllEffects(
|
|
|
383
383
|
effectVariant: EffectVariant | -1 = -1,
|
|
384
384
|
subType = -1,
|
|
385
385
|
cap?: int,
|
|
386
|
-
): EntityEffect[] {
|
|
386
|
+
): readonly EntityEffect[] {
|
|
387
387
|
const effects = getEffects(effectVariant, subType);
|
|
388
388
|
return removeEntities(effects, cap);
|
|
389
389
|
}
|
|
@@ -402,7 +402,7 @@ export function removeAllFamiliars(
|
|
|
402
402
|
familiarVariant: FamiliarVariant | -1 = -1,
|
|
403
403
|
subType = -1,
|
|
404
404
|
cap?: int,
|
|
405
|
-
): EntityFamiliar[] {
|
|
405
|
+
): readonly EntityFamiliar[] {
|
|
406
406
|
const familiars = getFamiliars(familiarVariant, subType);
|
|
407
407
|
return removeEntities(familiars, cap);
|
|
408
408
|
}
|
|
@@ -421,7 +421,7 @@ export function removeAllKnives(
|
|
|
421
421
|
knifeVariant: KnifeVariant | -1 = -1,
|
|
422
422
|
subType = -1,
|
|
423
423
|
cap?: int,
|
|
424
|
-
): EntityKnife[] {
|
|
424
|
+
): readonly EntityKnife[] {
|
|
425
425
|
const knives = getKnives(knifeVariant, subType);
|
|
426
426
|
return removeEntities(knives, cap);
|
|
427
427
|
}
|
|
@@ -440,7 +440,7 @@ export function removeAllLasers(
|
|
|
440
440
|
laserVariant: LaserVariant | -1 = -1,
|
|
441
441
|
subType = -1,
|
|
442
442
|
cap?: int,
|
|
443
|
-
): EntityLaser[] {
|
|
443
|
+
): readonly EntityLaser[] {
|
|
444
444
|
const lasers = getLasers(laserVariant, subType);
|
|
445
445
|
return removeEntities(lasers, cap);
|
|
446
446
|
}
|
|
@@ -462,7 +462,7 @@ export function removeAllNPCs(
|
|
|
462
462
|
variant = -1,
|
|
463
463
|
subType = -1,
|
|
464
464
|
cap?: int,
|
|
465
|
-
): EntityNPC[] {
|
|
465
|
+
): readonly EntityNPC[] {
|
|
466
466
|
const npcs = getNPCs(entityType, variant, subType);
|
|
467
467
|
return removeEntities(npcs, cap);
|
|
468
468
|
}
|
|
@@ -481,7 +481,7 @@ export function removeAllPickups(
|
|
|
481
481
|
pickupVariant: PickupVariant | -1 = -1,
|
|
482
482
|
subType = -1,
|
|
483
483
|
cap?: int,
|
|
484
|
-
): EntityPickup[] {
|
|
484
|
+
): readonly EntityPickup[] {
|
|
485
485
|
const pickups = getPickups(pickupVariant, subType);
|
|
486
486
|
return removeEntities(pickups, cap);
|
|
487
487
|
}
|
|
@@ -500,7 +500,7 @@ export function removeAllProjectiles(
|
|
|
500
500
|
projectileVariant: ProjectileVariant | -1 = -1,
|
|
501
501
|
subType = -1,
|
|
502
502
|
cap?: int,
|
|
503
|
-
): EntityProjectile[] {
|
|
503
|
+
): readonly EntityProjectile[] {
|
|
504
504
|
const projectiles = getProjectiles(projectileVariant, subType);
|
|
505
505
|
return removeEntities(projectiles, cap);
|
|
506
506
|
}
|
|
@@ -519,7 +519,7 @@ export function removeAllSlots(
|
|
|
519
519
|
slotVariant: SlotVariant | -1 = -1,
|
|
520
520
|
subType = -1,
|
|
521
521
|
cap?: int,
|
|
522
|
-
): Entity[] {
|
|
522
|
+
): readonly Entity[] {
|
|
523
523
|
const slots = getSlots(slotVariant, subType);
|
|
524
524
|
return removeEntities(slots, cap);
|
|
525
525
|
}
|
|
@@ -538,7 +538,7 @@ export function removeAllTears(
|
|
|
538
538
|
tearVariant: TearVariant | -1 = -1,
|
|
539
539
|
subType = -1,
|
|
540
540
|
cap?: int,
|
|
541
|
-
): EntityTear[] {
|
|
541
|
+
): readonly EntityTear[] {
|
|
542
542
|
const tears = getTears(tearVariant, subType);
|
|
543
543
|
return removeEntities(tears, cap);
|
|
544
544
|
}
|
package/src/functions/enums.ts
CHANGED
|
@@ -32,7 +32,7 @@ export type TranspiledEnum = Record<
|
|
|
32
32
|
*/
|
|
33
33
|
export function getEnumEntries<T extends TranspiledEnum>(
|
|
34
34
|
transpiledEnum: T,
|
|
35
|
-
):
|
|
35
|
+
): ReadonlyArray<[key: string, value: T[keyof T]]> {
|
|
36
36
|
// The values cannot simply be type `T` due to the special construction of bit flag enums.
|
|
37
37
|
const enumEntries: Array<[key: string, value: T[keyof T]]> = [];
|
|
38
38
|
for (const [key, value] of pairs(transpiledEnum)) {
|
|
@@ -70,7 +70,7 @@ export function getEnumEntries<T extends TranspiledEnum>(
|
|
|
70
70
|
* For a more in depth explanation, see:
|
|
71
71
|
* https://isaacscript.github.io/main/gotchas#iterating-over-enums
|
|
72
72
|
*/
|
|
73
|
-
export function getEnumKeys(transpiledEnum: TranspiledEnum): string[] {
|
|
73
|
+
export function getEnumKeys(transpiledEnum: TranspiledEnum): readonly string[] {
|
|
74
74
|
const enumEntries = getEnumEntries(transpiledEnum);
|
|
75
75
|
return enumEntries.map(([key, _value]) => key);
|
|
76
76
|
}
|
|
@@ -98,7 +98,9 @@ export function getEnumLength(transpiledEnum: TranspiledEnum): int {
|
|
|
98
98
|
* For a more in depth explanation, see:
|
|
99
99
|
* https://isaacscript.github.io/main/gotchas#iterating-over-enums
|
|
100
100
|
*/
|
|
101
|
-
export function getEnumNames(
|
|
101
|
+
export function getEnumNames(
|
|
102
|
+
transpiledEnum: TranspiledEnum,
|
|
103
|
+
): readonly string[] {
|
|
102
104
|
const enumNames: string[] = [];
|
|
103
105
|
|
|
104
106
|
for (const [key, _value] of pairs(transpiledEnum)) {
|
|
@@ -132,7 +134,7 @@ export function getEnumNames(transpiledEnum: TranspiledEnum): string[] {
|
|
|
132
134
|
*/
|
|
133
135
|
export function getEnumValues<T extends TranspiledEnum>(
|
|
134
136
|
transpiledEnum: T,
|
|
135
|
-
):
|
|
137
|
+
): ReadonlyArray<T[keyof T]> {
|
|
136
138
|
const enumEntries = getEnumEntries(transpiledEnum);
|
|
137
139
|
return enumEntries.map(([_key, value]) => value);
|
|
138
140
|
}
|
|
@@ -118,7 +118,9 @@ export function checkFamiliarFromCollectibles(
|
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
/** Helper function to get only the familiars that belong to a specific player. */
|
|
121
|
-
export function getPlayerFamiliars(
|
|
121
|
+
export function getPlayerFamiliars(
|
|
122
|
+
player: EntityPlayer,
|
|
123
|
+
): readonly EntityFamiliar[] {
|
|
122
124
|
const playerPtrHash = GetPtrHash(player);
|
|
123
125
|
const familiars = getFamiliars();
|
|
124
126
|
return familiars.filter((familiar) => {
|
|
@@ -121,7 +121,7 @@ export function doesGridEntityExist(
|
|
|
121
121
|
*
|
|
122
122
|
* Under the hood, this uses the `Room.GetGridSize` method.
|
|
123
123
|
*/
|
|
124
|
-
export function getAllGridIndexes(): int[] {
|
|
124
|
+
export function getAllGridIndexes(): readonly int[] {
|
|
125
125
|
const room = game.GetRoom();
|
|
126
126
|
const gridSize = room.GetGridSize();
|
|
127
127
|
|
|
@@ -140,7 +140,7 @@ export function getAllGridIndexes(): int[] {
|
|
|
140
140
|
*/
|
|
141
141
|
export function getCollidingEntitiesWithGridEntity(
|
|
142
142
|
gridEntity: GridEntity,
|
|
143
|
-
): Entity[] {
|
|
143
|
+
): readonly Entity[] {
|
|
144
144
|
const { topLeft, bottomRight } = getGridEntityCollisionPoints(gridEntity);
|
|
145
145
|
|
|
146
146
|
const closeEntities = Isaac.FindInRadius(
|
|
@@ -228,7 +228,7 @@ export function getConstituentsFromGridEntityID(
|
|
|
228
228
|
*/
|
|
229
229
|
export function getGridEntities(
|
|
230
230
|
...gridEntityTypes: GridEntityType[]
|
|
231
|
-
): GridEntity[] {
|
|
231
|
+
): readonly GridEntity[] {
|
|
232
232
|
const gridEntities = getAllGridEntities();
|
|
233
233
|
|
|
234
234
|
if (gridEntityTypes.length === 0) {
|
|
@@ -250,7 +250,7 @@ export function getGridEntities(
|
|
|
250
250
|
*/
|
|
251
251
|
export function getGridEntitiesExcept(
|
|
252
252
|
...gridEntityTypes: GridEntityType[]
|
|
253
|
-
): GridEntity[] {
|
|
253
|
+
): readonly GridEntity[] {
|
|
254
254
|
const gridEntities = getAllGridEntities();
|
|
255
255
|
|
|
256
256
|
if (gridEntityTypes.length === 0) {
|
|
@@ -264,7 +264,7 @@ export function getGridEntitiesExcept(
|
|
|
264
264
|
});
|
|
265
265
|
}
|
|
266
266
|
|
|
267
|
-
function getAllGridEntities(): GridEntity[] {
|
|
267
|
+
function getAllGridEntities(): readonly GridEntity[] {
|
|
268
268
|
const room = game.GetRoom();
|
|
269
269
|
|
|
270
270
|
const gridEntities: GridEntity[] = [];
|
|
@@ -282,7 +282,7 @@ function getAllGridEntities(): GridEntity[] {
|
|
|
282
282
|
export function getGridEntitiesInRadius(
|
|
283
283
|
targetPosition: Vector,
|
|
284
284
|
radius: number,
|
|
285
|
-
): GridEntity[] {
|
|
285
|
+
): readonly GridEntity[] {
|
|
286
286
|
radius = Math.abs(radius);
|
|
287
287
|
const topLeftOffset = VectorOne.mul(-radius);
|
|
288
288
|
const mostTopLeftPosition = targetPosition.add(topLeftOffset);
|
|
@@ -528,7 +528,7 @@ export function getGridEntityIDFromConstituents(
|
|
|
528
528
|
export function getMatchingGridEntities(
|
|
529
529
|
gridEntityType: GridEntityType,
|
|
530
530
|
variant: int,
|
|
531
|
-
): GridEntity[] {
|
|
531
|
+
): readonly GridEntity[] {
|
|
532
532
|
const gridEntities = getGridEntities(gridEntityType);
|
|
533
533
|
return gridEntities.filter(
|
|
534
534
|
(gridEntity) => gridEntity.GetVariant() === variant,
|
|
@@ -698,7 +698,7 @@ function getRockPNGName(): string {
|
|
|
698
698
|
*/
|
|
699
699
|
export function getSurroundingGridEntities(
|
|
700
700
|
gridEntity: GridEntity,
|
|
701
|
-
): GridEntity[] {
|
|
701
|
+
): readonly GridEntity[] {
|
|
702
702
|
const room = game.GetRoom();
|
|
703
703
|
const gridIndex = gridEntity.GetGridIndex();
|
|
704
704
|
|
|
@@ -886,7 +886,7 @@ export function isPostBossVoidPortal(gridEntity: GridEntity): boolean {
|
|
|
886
886
|
*/
|
|
887
887
|
export function removeAllGridEntitiesExcept(
|
|
888
888
|
...gridEntityTypes: GridEntityType[]
|
|
889
|
-
): GridEntity[] {
|
|
889
|
+
): readonly GridEntity[] {
|
|
890
890
|
const gridEntityTypeExceptions = new ReadonlySet(gridEntityTypes);
|
|
891
891
|
const gridEntities = getGridEntities();
|
|
892
892
|
const removedGridEntities: GridEntity[] = [];
|
|
@@ -926,7 +926,7 @@ export function removeAllGridEntitiesExcept(
|
|
|
926
926
|
*/
|
|
927
927
|
export function removeAllMatchingGridEntities(
|
|
928
928
|
...gridEntityType: GridEntityType[]
|
|
929
|
-
): GridEntity[] {
|
|
929
|
+
): readonly GridEntity[] {
|
|
930
930
|
const gridEntities = getGridEntities(...gridEntityType);
|
|
931
931
|
if (gridEntities.length === 0) {
|
|
932
932
|
return [];
|
|
@@ -948,7 +948,7 @@ export function removeAllMatchingGridEntities(
|
|
|
948
948
|
* You must specify an array of entities to look through.
|
|
949
949
|
*/
|
|
950
950
|
export function removeEntitiesSpawnedFromGridEntity(
|
|
951
|
-
entities: Entity[],
|
|
951
|
+
entities: Entity[] | readonly Entity[],
|
|
952
952
|
gridEntity: GridEntity,
|
|
953
953
|
): void {
|
|
954
954
|
const entitiesFromGridEntity = entities.filter(
|
|
@@ -972,10 +972,10 @@ export function removeEntitiesSpawnedFromGridEntity(
|
|
|
972
972
|
* @returns An array of the entities that were removed.
|
|
973
973
|
*/
|
|
974
974
|
export function removeGridEntities<T extends AnyGridEntity>(
|
|
975
|
-
gridEntities: T[],
|
|
975
|
+
gridEntities: T[] | readonly T[],
|
|
976
976
|
updateRoom: boolean,
|
|
977
977
|
cap?: int,
|
|
978
|
-
): T[] {
|
|
978
|
+
): readonly T[] {
|
|
979
979
|
if (gridEntities.length === 0) {
|
|
980
980
|
return [];
|
|
981
981
|
}
|