isaacscript-common 20.3.0 → 20.3.1
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.d.ts +16 -14
- package/dist/isaacscript-common.lua +10253 -10004
- package/dist/src/classes/ModUpgradedBase.d.ts +1 -1
- package/dist/src/classes/features/callbackLogic/CustomGridEntities.lua +3 -3
- package/dist/src/classes/features/callbackLogic/GridEntityCollisionDetection.lua +1 -1
- package/dist/src/classes/features/callbackLogic/GridEntityUpdateDetection.d.ts.map +1 -1
- package/dist/src/classes/features/callbackLogic/GridEntityUpdateDetection.lua +3 -3
- package/dist/src/classes/features/callbackLogic/PlayerCollectibleDetection.lua +1 -1
- package/dist/src/classes/features/other/CustomHotkeys.d.ts.map +1 -1
- package/dist/src/classes/features/other/CustomHotkeys.lua +2 -2
- package/dist/src/classes/features/other/DeployJSONRoom.lua +1 -1
- package/dist/src/classes/features/other/ItemPoolDetection.d.ts.map +1 -1
- package/dist/src/classes/features/other/ModdedElementSets.lua +3 -3
- package/dist/src/classes/features/other/PersistentEntities.d.ts.map +1 -1
- package/dist/src/classes/features/other/PersistentEntities.lua +1 -1
- package/dist/src/classes/features/other/PickupIndexCreation.lua +1 -1
- package/dist/src/classes/features/other/customStages/streakText.d.ts.map +1 -1
- package/dist/src/classes/features/other/extraConsoleCommands/commands.lua +0 -1
- package/dist/src/core/constants.d.ts +1 -1
- package/dist/src/core/constants.d.ts.map +1 -1
- package/dist/src/functions/cards.lua +0 -2
- package/dist/src/functions/entities.lua +1 -1
- package/dist/src/functions/hex.d.ts +4 -3
- package/dist/src/functions/hex.d.ts.map +1 -1
- package/dist/src/functions/hex.lua +8 -0
- package/dist/src/functions/isaacAPIClass.d.ts +1 -1
- package/dist/src/functions/isaacAPIClass.d.ts.map +1 -1
- package/dist/src/functions/levelGrid.d.ts.map +1 -1
- package/dist/src/functions/levelGrid.lua +2 -2
- package/dist/src/functions/map.d.ts +2 -2
- package/dist/src/functions/map.lua +1 -1
- package/dist/src/functions/minimap.lua +1 -1
- package/dist/src/functions/table.d.ts +1 -1
- package/dist/src/functions/table.d.ts.map +1 -1
- package/dist/src/functions/utils.d.ts +5 -5
- package/dist/src/functions/utils.d.ts.map +1 -1
- package/dist/src/functions/utils.lua +9 -18
- package/dist/src/maps/characterNameToTypeMap.d.ts +1 -1
- package/dist/src/maps/characterNameToTypeMap.d.ts.map +1 -1
- package/dist/src/objects/roomShapeToDoorSlotCoordinates.d.ts +1 -1
- package/dist/src/objects/roomShapeToDoorSlotCoordinates.d.ts.map +1 -1
- package/dist/src/sets/bossSets.lua +5 -5
- package/dist/src/sets/entitiesWithArmorSet.d.ts +1 -1
- package/dist/src/sets/entitiesWithArmorSet.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/classes/ModUpgradedBase.ts +1 -1
- package/src/classes/callbacks/PostTrinketBreak.ts +2 -2
- package/src/classes/features/callbackLogic/CustomGridEntities.ts +3 -3
- package/src/classes/features/callbackLogic/GridEntityCollisionDetection.ts +1 -1
- package/src/classes/features/callbackLogic/GridEntityUpdateDetection.ts +4 -6
- package/src/classes/features/callbackLogic/PlayerCollectibleDetection.ts +1 -1
- package/src/classes/features/other/CustomHotkeys.ts +2 -8
- package/src/classes/features/other/DeployJSONRoom.ts +1 -1
- package/src/classes/features/other/FlyingDetection.ts +2 -2
- package/src/classes/features/other/ItemPoolDetection.ts +3 -5
- package/src/classes/features/other/ModdedElementSets.ts +4 -4
- package/src/classes/features/other/PersistentEntities.ts +1 -4
- package/src/classes/features/other/PickupIndexCreation.ts +1 -1
- package/src/classes/features/other/PonyDetection.ts +2 -2
- package/src/classes/features/other/customStages/backdrop.ts +2 -2
- package/src/classes/features/other/customStages/streakText.ts +6 -4
- package/src/classes/features/other/saveDataManager/glowingHourGlass.ts +2 -2
- package/src/core/constants.ts +7 -6
- package/src/functions/bitSet128.ts +1 -1
- package/src/functions/color.ts +1 -1
- package/src/functions/hex.ts +4 -2
- package/src/functions/input.ts +6 -6
- package/src/functions/isaacAPIClass.ts +1 -1
- package/src/functions/kColor.ts +1 -1
- package/src/functions/levelGrid.ts +3 -9
- package/src/functions/map.ts +2 -2
- package/src/functions/merge.ts +1 -1
- package/src/functions/minimap.ts +1 -1
- package/src/functions/rng.ts +1 -1
- package/src/functions/table.ts +1 -1
- package/src/functions/utils.ts +9 -15
- package/src/functions/vector.ts +1 -1
- package/src/maps/characterNameToTypeMap.ts +86 -85
- package/src/objects/roomShapeBounds.ts +2 -2
- package/src/objects/roomShapeLayoutSizes.ts +4 -4
- package/src/objects/roomShapeToDoorSlotCoordinates.ts +1 -1
- package/src/patchErrorFunctions.ts +2 -2
- package/src/sets/bossSets.ts +5 -5
- package/src/sets/entitiesWithArmorSet.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isaacscript-common",
|
|
3
|
-
"version": "20.3.
|
|
3
|
+
"version": "20.3.1",
|
|
4
4
|
"description": "Helper functions and features for IsaacScript mods.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"isaac",
|
|
@@ -22,6 +22,6 @@
|
|
|
22
22
|
"main": "dist/src/index",
|
|
23
23
|
"types": "dist/src/index.d.ts",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"isaac-typescript-definitions": "^
|
|
25
|
+
"isaac-typescript-definitions": "^11.0.0"
|
|
26
26
|
}
|
|
27
27
|
}
|
|
@@ -390,7 +390,7 @@ export class ModUpgradedBase implements Mod {
|
|
|
390
390
|
/**
|
|
391
391
|
* Returns the names of the exported class methods from the features that were added. This is
|
|
392
392
|
* called from the "upgradeMod" function, but we want to mark it as private so that end-users
|
|
393
|
-
* don't have access to it
|
|
393
|
+
* don't have access to it.
|
|
394
394
|
*/
|
|
395
395
|
private initOptionalFeature(feature: ISCFeature): FunctionTuple[] {
|
|
396
396
|
const featureClass = this.features[feature];
|
|
@@ -11,10 +11,10 @@ import { PlayerIndex } from "../../types/PlayerIndex";
|
|
|
11
11
|
import { DefaultMap } from "../DefaultMap";
|
|
12
12
|
import { CustomCallback } from "../private/CustomCallback";
|
|
13
13
|
|
|
14
|
-
const TRINKETS_THAT_CAN_BREAK
|
|
14
|
+
const TRINKETS_THAT_CAN_BREAK = [
|
|
15
15
|
TrinketType.WISH_BONE,
|
|
16
16
|
TrinketType.WALNUT,
|
|
17
|
-
];
|
|
17
|
+
] as const;
|
|
18
18
|
|
|
19
19
|
export class PostTrinketBreak extends CustomCallback<ModCallbackCustom.POST_TRINKET_BREAK> {
|
|
20
20
|
public override v = {
|
|
@@ -126,7 +126,7 @@ export class CustomGridEntities extends Feature {
|
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
const room = game.GetRoom();
|
|
129
|
-
for (const [gridIndex, data] of roomCustomGridEntities
|
|
129
|
+
for (const [gridIndex, data] of roomCustomGridEntities) {
|
|
130
130
|
const decoration = room.GetGridEntity(gridIndex);
|
|
131
131
|
if (decoration === undefined) {
|
|
132
132
|
roomCustomGridEntities.delete(gridIndex);
|
|
@@ -361,7 +361,7 @@ export class CustomGridEntities extends Feature {
|
|
|
361
361
|
|
|
362
362
|
const room = game.GetRoom();
|
|
363
363
|
const customGridEntities: Array<[GridEntity, GridEntityCustomData]> = [];
|
|
364
|
-
for (const [gridIndex, data] of roomCustomGridEntities
|
|
364
|
+
for (const [gridIndex, data] of roomCustomGridEntities) {
|
|
365
365
|
const gridEntity = room.GetGridEntity(gridIndex);
|
|
366
366
|
if (gridEntity !== undefined) {
|
|
367
367
|
customGridEntities.push([gridEntity, data]);
|
|
@@ -398,7 +398,7 @@ export class CustomGridEntities extends Feature {
|
|
|
398
398
|
return undefined;
|
|
399
399
|
}
|
|
400
400
|
|
|
401
|
-
for (const [_gridIndex, data] of roomCustomGridEntities
|
|
401
|
+
for (const [_gridIndex, data] of roomCustomGridEntities) {
|
|
402
402
|
if (data.gridIndex === gridIndex) {
|
|
403
403
|
return data.gridEntityTypeCustom;
|
|
404
404
|
}
|
|
@@ -77,7 +77,7 @@ export class GridEntityCollisionDetection extends Feature {
|
|
|
77
77
|
GetPtrHash(entity),
|
|
78
78
|
);
|
|
79
79
|
const collidingEntitiesPtrHashSet = new Set(collidingEntitiesPtrHashes);
|
|
80
|
-
for (const oldCollidingEntityPtrHash of oldCollidingEntities
|
|
80
|
+
for (const oldCollidingEntityPtrHash of oldCollidingEntities) {
|
|
81
81
|
if (!collidingEntitiesPtrHashSet.has(oldCollidingEntityPtrHash)) {
|
|
82
82
|
oldCollidingEntities.delete(oldCollidingEntityPtrHash);
|
|
83
83
|
}
|
|
@@ -91,7 +91,7 @@ export class GridEntityUpdateDetection extends Feature {
|
|
|
91
91
|
// being removed and fire the PostGridEntityRemoved callback.
|
|
92
92
|
this.checkGridEntitiesRemoved(gridEntitiesMap);
|
|
93
93
|
|
|
94
|
-
for (const [gridIndex, gridEntity] of gridEntitiesMap
|
|
94
|
+
for (const [gridIndex, gridEntity] of gridEntitiesMap) {
|
|
95
95
|
this.checkGridEntityStateChanged(gridIndex, gridEntity);
|
|
96
96
|
this.checkNewGridEntity(gridIndex, gridEntity);
|
|
97
97
|
|
|
@@ -108,10 +108,8 @@ export class GridEntityUpdateDetection extends Feature {
|
|
|
108
108
|
private checkGridEntitiesRemoved(
|
|
109
109
|
gridEntitiesMap: Map<int, GridEntity>,
|
|
110
110
|
): void {
|
|
111
|
-
for (const [
|
|
112
|
-
|
|
113
|
-
gridEntityTuple,
|
|
114
|
-
] of this.v.room.initializedGridEntities.entries()) {
|
|
111
|
+
for (const [gridIndex, gridEntityTuple] of this.v.room
|
|
112
|
+
.initializedGridEntities) {
|
|
115
113
|
const [storedGridEntityType, storedGridEntityVariant] = gridEntityTuple;
|
|
116
114
|
const gridEntity = gridEntitiesMap.get(gridIndex);
|
|
117
115
|
if (
|
|
@@ -213,7 +211,7 @@ export class GridEntityUpdateDetection extends Feature {
|
|
|
213
211
|
private postNewRoomReordered = (): void => {
|
|
214
212
|
const gridEntitiesMap = getGridEntitiesMap();
|
|
215
213
|
|
|
216
|
-
for (const [gridIndex, gridEntity] of gridEntitiesMap
|
|
214
|
+
for (const [gridIndex, gridEntity] of gridEntitiesMap) {
|
|
217
215
|
this.checkNewGridEntity(gridIndex, gridEntity);
|
|
218
216
|
}
|
|
219
217
|
};
|
|
@@ -109,7 +109,7 @@ export class PlayerCollectibleDetection extends Feature {
|
|
|
109
109
|
]);
|
|
110
110
|
|
|
111
111
|
let numFired = 0;
|
|
112
|
-
for (const collectibleType of collectibleTypesSet
|
|
112
|
+
for (const collectibleType of collectibleTypesSet) {
|
|
113
113
|
const oldNum = oldCollectibleMap.get(collectibleType) ?? 0;
|
|
114
114
|
const newNum = newCollectibleMap.get(collectibleType) ?? 0;
|
|
115
115
|
const difference = newNum - oldNum;
|
|
@@ -34,17 +34,11 @@ export class CustomHotkeys extends Feature {
|
|
|
34
34
|
|
|
35
35
|
// ModCallback.POST_RENDER (2)
|
|
36
36
|
private postRender = () => {
|
|
37
|
-
for (const [
|
|
38
|
-
keyboard,
|
|
39
|
-
triggerFunc,
|
|
40
|
-
] of this.staticHotkeyFunctionMap.entries()) {
|
|
37
|
+
for (const [keyboard, triggerFunc] of this.staticHotkeyFunctionMap) {
|
|
41
38
|
this.checkIfTriggered(keyboard, triggerFunc);
|
|
42
39
|
}
|
|
43
40
|
|
|
44
|
-
for (const [
|
|
45
|
-
keyboardFunc,
|
|
46
|
-
triggerFunc,
|
|
47
|
-
] of this.dynamicHotkeyFunctionMap.entries()) {
|
|
41
|
+
for (const [keyboardFunc, triggerFunc] of this.dynamicHotkeyFunctionMap) {
|
|
48
42
|
const keyboard = keyboardFunc();
|
|
49
43
|
if (keyboard !== undefined) {
|
|
50
44
|
this.checkIfTriggered(keyboard, triggerFunc);
|
|
@@ -304,7 +304,7 @@ function fixPitGraphics() {
|
|
|
304
304
|
const gridWidth = room.GetGridWidth();
|
|
305
305
|
const pitMap = getPitMap();
|
|
306
306
|
|
|
307
|
-
for (const [gridIndex, gridEntity] of pitMap
|
|
307
|
+
for (const [gridIndex, gridEntity] of pitMap) {
|
|
308
308
|
const gridIndexLeft = gridIndex - 1;
|
|
309
309
|
const L = pitMap.has(gridIndexLeft);
|
|
310
310
|
const gridIndexRight = gridIndex + 1;
|
|
@@ -4,11 +4,11 @@ import { ISCFeature } from "../../../enums/ISCFeature";
|
|
|
4
4
|
import { Feature } from "../../private/Feature";
|
|
5
5
|
import { ModdedElementSets } from "./ModdedElementSets";
|
|
6
6
|
|
|
7
|
-
const FLYING_NULL_ITEMS
|
|
7
|
+
const FLYING_NULL_ITEMS = [
|
|
8
8
|
NullItemID.REVERSE_SUN, // 66
|
|
9
9
|
NullItemID.SPIRIT_SHACKLES_SOUL, // 10
|
|
10
10
|
NullItemID.LOST_CURSE, // 112
|
|
11
|
-
];
|
|
11
|
+
] as const;
|
|
12
12
|
|
|
13
13
|
export class FlyingDetection extends Feature {
|
|
14
14
|
private moddedElementSets: ModdedElementSets;
|
|
@@ -25,15 +25,13 @@ import { ModdedElementSets } from "./ModdedElementSets";
|
|
|
25
25
|
|
|
26
26
|
const COLLECTIBLE_TYPE_THAT_IS_NOT_IN_ANY_POOLS = CollectibleType.KEY_PIECE_1;
|
|
27
27
|
|
|
28
|
-
const COLLECTIBLES_THAT_AFFECT_ITEM_POOLS
|
|
28
|
+
const COLLECTIBLES_THAT_AFFECT_ITEM_POOLS = [
|
|
29
29
|
CollectibleType.CHAOS, // 402
|
|
30
30
|
CollectibleType.SACRED_ORB, // 691
|
|
31
31
|
CollectibleType.TMTRAINER, // 721
|
|
32
|
-
];
|
|
32
|
+
] as const;
|
|
33
33
|
|
|
34
|
-
const TRINKETS_THAT_AFFECT_ITEM_POOLS
|
|
35
|
-
TrinketType.NO,
|
|
36
|
-
];
|
|
34
|
+
const TRINKETS_THAT_AFFECT_ITEM_POOLS = [TrinketType.NO] as const;
|
|
37
35
|
|
|
38
36
|
export class ItemPoolDetection extends Feature {
|
|
39
37
|
private moddedElementSets: ModdedElementSets;
|
|
@@ -43,12 +43,12 @@ import { repeat } from "../../../functions/utils";
|
|
|
43
43
|
import { Feature } from "../../private/Feature";
|
|
44
44
|
import { ModdedElementDetection } from "./ModdedElementDetection";
|
|
45
45
|
|
|
46
|
-
const CONDITIONAL_FLYING_COLLECTIBLE_TYPES
|
|
46
|
+
const CONDITIONAL_FLYING_COLLECTIBLE_TYPES = [
|
|
47
47
|
CollectibleType.BIBLE,
|
|
48
48
|
CollectibleType.EMPTY_VESSEL,
|
|
49
49
|
CollectibleType.ASTRAL_PROJECTION,
|
|
50
50
|
CollectibleType.RECALL,
|
|
51
|
-
];
|
|
51
|
+
] as const;
|
|
52
52
|
|
|
53
53
|
const TRANSFORMATION_TO_TAG_MAP: ReadonlyMap<PlayerForm, ItemConfigTag> =
|
|
54
54
|
new Map([
|
|
@@ -366,7 +366,7 @@ export class ModdedElementSets extends Feature {
|
|
|
366
366
|
for (const collectibleType of CONDITIONAL_FLYING_COLLECTIBLE_TYPES) {
|
|
367
367
|
permanentFlyingCollectibleTypes.delete(collectibleType);
|
|
368
368
|
}
|
|
369
|
-
for (const collectibleType of permanentFlyingCollectibleTypes
|
|
369
|
+
for (const collectibleType of permanentFlyingCollectibleTypes) {
|
|
370
370
|
this.permanentFlyingCollectibleTypesSet.add(collectibleType);
|
|
371
371
|
}
|
|
372
372
|
}
|
|
@@ -514,7 +514,7 @@ export class ModdedElementSets extends Feature {
|
|
|
514
514
|
);
|
|
515
515
|
}
|
|
516
516
|
|
|
517
|
-
for (const cardType of cardTypeSet
|
|
517
|
+
for (const cardType of cardTypeSet) {
|
|
518
518
|
matchingCardTypes.add(cardType);
|
|
519
519
|
}
|
|
520
520
|
}
|
|
@@ -170,10 +170,7 @@ export class PersistentEntities extends Feature {
|
|
|
170
170
|
): void {
|
|
171
171
|
this.v.level.persistentEntities.delete(persistentEntityIndex);
|
|
172
172
|
|
|
173
|
-
for (const [
|
|
174
|
-
ptrHash,
|
|
175
|
-
tuple,
|
|
176
|
-
] of this.v.room.spawnedPersistentEntities.entries()) {
|
|
173
|
+
for (const [ptrHash, tuple] of this.v.room.spawnedPersistentEntities) {
|
|
177
174
|
const [index, entityPtr] = tuple;
|
|
178
175
|
if (index !== persistentEntityIndex) {
|
|
179
176
|
continue;
|
|
@@ -275,7 +275,7 @@ function getStoredPickupIndex(
|
|
|
275
275
|
pickup: Entity,
|
|
276
276
|
pickupDescriptions: Map<PickupIndex, PickupDescription>,
|
|
277
277
|
): PickupIndex | undefined {
|
|
278
|
-
for (const [pickupIndex, pickupDescription] of pickupDescriptions
|
|
278
|
+
for (const [pickupIndex, pickupDescription] of pickupDescriptions) {
|
|
279
279
|
if (
|
|
280
280
|
vectorEquals(pickupDescription.position, pickup.Position) &&
|
|
281
281
|
pickupDescription.initSeed === pickup.InitSeed
|
|
@@ -11,11 +11,11 @@ import { getPlayers } from "../../../functions/playerIndex";
|
|
|
11
11
|
import { PlayerIndex } from "../../../types/PlayerIndex";
|
|
12
12
|
import { Feature } from "../../private/Feature";
|
|
13
13
|
|
|
14
|
-
const FLAGS_WHEN_PONY_IS_ACTIVE
|
|
14
|
+
const FLAGS_WHEN_PONY_IS_ACTIVE = [
|
|
15
15
|
EntityFlag.NO_KNOCKBACK, // 1 << 26
|
|
16
16
|
EntityFlag.NO_PHYSICS_KNOCKBACK, // 1 << 30
|
|
17
17
|
EntityFlag.NO_DAMAGE_BLINK, // 1 << 36
|
|
18
|
-
];
|
|
18
|
+
] as const;
|
|
19
19
|
|
|
20
20
|
export class PonyDetection extends Feature {
|
|
21
21
|
/** @internal */
|
|
@@ -72,10 +72,10 @@ const ROOM_SHAPE_WALL_EXTRA_ANM2_LAYERS: {
|
|
|
72
72
|
const WALL_OFFSET = Vector(-80, -80);
|
|
73
73
|
|
|
74
74
|
/** Corresponds to "floor-backdrop.anm2". */
|
|
75
|
-
const L_FLOOR_ANM2_LAYERS
|
|
75
|
+
const L_FLOOR_ANM2_LAYERS = [16, 17] as const;
|
|
76
76
|
|
|
77
77
|
/** Corresponds to "floor-backdrop.anm2". */
|
|
78
|
-
const N_FLOOR_ANM2_LAYERS
|
|
78
|
+
const N_FLOOR_ANM2_LAYERS = [18, 19] as const;
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
81
|
* Normally, we would make a custom entity to represent a backdrop effect, but we don't want to
|
|
@@ -49,10 +49,12 @@ const STREAK_TEXT_BOTTOM_Y_OFFSET = -9;
|
|
|
49
49
|
const NUM_RENDER_FRAMES_MAP_HELD_BEFORE_STREAK_TEXT = 11;
|
|
50
50
|
|
|
51
51
|
/** Taken from StageAPI. */
|
|
52
|
-
const TEXT_IN_ADJUSTMENTS = [-800, -639, -450, -250, -70, 10, 6, 3];
|
|
52
|
+
const TEXT_IN_ADJUSTMENTS = [-800, -639, -450, -250, -70, 10, 6, 3] as const;
|
|
53
53
|
|
|
54
54
|
/** Taken from StageAPI. */
|
|
55
|
-
const TEXT_OUT_ADJUSTMENTS = [
|
|
55
|
+
const TEXT_OUT_ADJUSTMENTS = [
|
|
56
|
+
0, -5, -10, -15, -20, 144, 308, 472, 636, 800,
|
|
57
|
+
] as const;
|
|
56
58
|
|
|
57
59
|
/** Taken from StageAPI. */
|
|
58
60
|
const TEXT_IN_SCALES = [
|
|
@@ -64,7 +66,7 @@ const TEXT_IN_SCALES = [
|
|
|
64
66
|
Vector(0.95, 1.05),
|
|
65
67
|
Vector(0.97, 1.03),
|
|
66
68
|
Vector(0.98, 1.02),
|
|
67
|
-
];
|
|
69
|
+
] as const;
|
|
68
70
|
|
|
69
71
|
/** Taken from StageAPI. */
|
|
70
72
|
const TEXT_OUT_SCALES = [
|
|
@@ -78,7 +80,7 @@ const TEXT_OUT_SCALES = [
|
|
|
78
80
|
Vector(2.18, 0.56),
|
|
79
81
|
Vector(2.59, 0.38),
|
|
80
82
|
Vector(3, 0.2),
|
|
81
|
-
];
|
|
83
|
+
] as const;
|
|
82
84
|
|
|
83
85
|
interface StreakTextVars {
|
|
84
86
|
run: {
|
|
@@ -14,10 +14,10 @@ import { SAVE_DATA_MANAGER_DEBUG } from "./constants";
|
|
|
14
14
|
* When the Glowing Hourglass is used, certain save data keys will automatically be restored to a
|
|
15
15
|
* backup.
|
|
16
16
|
*/
|
|
17
|
-
const GLOWING_HOUR_GLASS_BACKUP_KEYS
|
|
17
|
+
const GLOWING_HOUR_GLASS_BACKUP_KEYS = [
|
|
18
18
|
SaveDataKey.RUN,
|
|
19
19
|
SaveDataKey.LEVEL,
|
|
20
|
-
];
|
|
20
|
+
] as const;
|
|
21
21
|
|
|
22
22
|
const IGNORE_GLOWING_HOUR_GLASS_KEY = "__ignoreGlowingHourGlass";
|
|
23
23
|
|
package/src/core/constants.ts
CHANGED
|
@@ -79,12 +79,13 @@ export const GAME_FRAMES_PER_SECOND = 30;
|
|
|
79
79
|
export const GAME_FRAMES_PER_MINUTE = GAME_FRAMES_PER_SECOND * 60;
|
|
80
80
|
|
|
81
81
|
/** The set of all `ItemConfigCardType` values that are not a rune or special object. */
|
|
82
|
-
export const ITEM_CONFIG_CARD_TYPES_FOR_CARDS =
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
82
|
+
export const ITEM_CONFIG_CARD_TYPES_FOR_CARDS: ReadonlySet<ItemConfigCardType> =
|
|
83
|
+
new Set([
|
|
84
|
+
ItemConfigCardType.TAROT,
|
|
85
|
+
ItemConfigCardType.SUIT,
|
|
86
|
+
ItemConfigCardType.SPECIAL,
|
|
87
|
+
ItemConfigCardType.TAROT_REVERSE,
|
|
88
|
+
]);
|
|
88
89
|
|
|
89
90
|
/** Render frames are what is returned by the `Isaac.GetFrameCount` method. */
|
|
90
91
|
export const RENDER_FRAMES_PER_SECOND = 60;
|
|
@@ -14,7 +14,7 @@ export type SerializedBitSet128 = LuaMap<string, unknown> & {
|
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
const OBJECT_NAME = "BitSet128";
|
|
17
|
-
const KEYS = ["l", "h"];
|
|
17
|
+
const KEYS = ["l", "h"] as const;
|
|
18
18
|
|
|
19
19
|
/** Helper function to copy a `BitSet128` Isaac API class. */
|
|
20
20
|
export function copyBitSet128(bitSet128: BitSet128): BitSet128 {
|
package/src/functions/color.ts
CHANGED
|
@@ -16,7 +16,7 @@ export type SerializedColor = LuaMap<string, unknown> & {
|
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
const OBJECT_NAME = "Color";
|
|
19
|
-
const KEYS = ["R", "G", "B", "A", "RO", "GO", "BO"];
|
|
19
|
+
const KEYS = ["R", "G", "B", "A", "RO", "GO", "BO"] as const;
|
|
20
20
|
|
|
21
21
|
export function colorEquals(color1: Color, color2: Color): boolean {
|
|
22
22
|
return isaacAPIClassEquals(color1, color2, KEYS);
|
package/src/functions/hex.ts
CHANGED
|
@@ -6,8 +6,9 @@ const HEX_STRING_LENGTH = 6;
|
|
|
6
6
|
* Converts a hex string like "#33aa33" to a KColor object.
|
|
7
7
|
*
|
|
8
8
|
* @param hexString A hex string like "#ffffff" or "ffffff". (The "#" character is optional.)
|
|
9
|
+
* @param alpha Optional. Range is from 0 to 1. Default is 1. (The same as the `Color` constructor.)
|
|
9
10
|
*/
|
|
10
|
-
export function hexToColor(hexString: string, alpha
|
|
11
|
+
export function hexToColor(hexString: string, alpha = 1.0): Color {
|
|
11
12
|
const [r, g, b] = hexToRGB(hexString);
|
|
12
13
|
|
|
13
14
|
// Color values should be between 0 and 1.
|
|
@@ -19,8 +20,9 @@ export function hexToColor(hexString: string, alpha: float): Color {
|
|
|
19
20
|
* Converts a hex string like "#33aa33" to a Color object.
|
|
20
21
|
*
|
|
21
22
|
* @param hexString A hex string like "#ffffff" or "ffffff". (The "#" character is optional.)
|
|
23
|
+
* @param alpha Range is from 0 to 1. Default is 1.
|
|
22
24
|
*/
|
|
23
|
-
export function hexToKColor(hexString: string, alpha
|
|
25
|
+
export function hexToKColor(hexString: string, alpha = 1.0): KColor {
|
|
24
26
|
const [r, g, b] = hexToRGB(hexString);
|
|
25
27
|
|
|
26
28
|
// KColor values should be between 0 and 1.
|
package/src/functions/input.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { KEYBOARD_TO_STRING } from "../maps/keyboardToString";
|
|
|
8
8
|
import { getEnumValues } from "./enums";
|
|
9
9
|
import { trimPrefix } from "./string";
|
|
10
10
|
|
|
11
|
-
const MODIFIER_KEYS
|
|
11
|
+
const MODIFIER_KEYS = [
|
|
12
12
|
Keyboard.LEFT_SHIFT, // 340
|
|
13
13
|
Keyboard.LEFT_CONTROL, // 341
|
|
14
14
|
Keyboard.LEFT_ALT, // 342
|
|
@@ -17,25 +17,25 @@ const MODIFIER_KEYS: readonly Keyboard[] = [
|
|
|
17
17
|
Keyboard.RIGHT_CONTROL, // 345
|
|
18
18
|
Keyboard.RIGHT_ALT, // 346
|
|
19
19
|
Keyboard.RIGHT_SUPER, // 347
|
|
20
|
-
];
|
|
20
|
+
] as const;
|
|
21
21
|
|
|
22
|
-
const MOVEMENT_ACTIONS
|
|
22
|
+
const MOVEMENT_ACTIONS = [
|
|
23
23
|
ButtonAction.LEFT, // 0
|
|
24
24
|
ButtonAction.RIGHT, // 1
|
|
25
25
|
ButtonAction.UP, // 2
|
|
26
26
|
ButtonAction.DOWN, // 3
|
|
27
|
-
];
|
|
27
|
+
] as const;
|
|
28
28
|
|
|
29
29
|
export const MOVEMENT_ACTIONS_SET: ReadonlySet<ButtonAction> = new Set(
|
|
30
30
|
MOVEMENT_ACTIONS,
|
|
31
31
|
);
|
|
32
32
|
|
|
33
|
-
const SHOOTING_ACTIONS
|
|
33
|
+
const SHOOTING_ACTIONS = [
|
|
34
34
|
ButtonAction.SHOOT_LEFT, // 4
|
|
35
35
|
ButtonAction.SHOOT_RIGHT, // 5
|
|
36
36
|
ButtonAction.SHOOT_UP, // 6
|
|
37
37
|
ButtonAction.SHOOT_DOWN, // 7
|
|
38
|
-
];
|
|
38
|
+
] as const;
|
|
39
39
|
|
|
40
40
|
export const SHOOTING_ACTIONS_SET: ReadonlySet<ButtonAction> = new Set(
|
|
41
41
|
SHOOTING_ACTIONS,
|
|
@@ -162,7 +162,7 @@ export function isTear(variable: unknown): variable is EntityTear {
|
|
|
162
162
|
export function isaacAPIClassEquals(
|
|
163
163
|
object1: unknown,
|
|
164
164
|
object2: unknown,
|
|
165
|
-
keys: string[],
|
|
165
|
+
keys: string[] | readonly string[],
|
|
166
166
|
): boolean {
|
|
167
167
|
const table1 = object1 as LuaMap<AnyNotNil, unknown>;
|
|
168
168
|
const table2 = object2 as LuaMap<AnyNotNil, unknown>;
|
package/src/functions/kColor.ts
CHANGED
|
@@ -16,7 +16,7 @@ export type SerializedKColor = LuaMap<string, unknown> & {
|
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
const OBJECT_NAME = "KColor";
|
|
19
|
-
const KEYS = ["Red", "Green", "Blue", "Alpha"];
|
|
19
|
+
const KEYS = ["Red", "Green", "Blue", "Alpha"] as const;
|
|
20
20
|
|
|
21
21
|
/** Helper function to copy a `KColor` Isaac API class. */
|
|
22
22
|
export function copyKColor(kColor: KColor): KColor {
|
|
@@ -45,7 +45,7 @@ const UP = -LEVEL_GRID_ROW_WIDTH;
|
|
|
45
45
|
const RIGHT = 1;
|
|
46
46
|
const DOWN = LEVEL_GRID_ROW_WIDTH;
|
|
47
47
|
|
|
48
|
-
const ADJACENT_ROOM_GRID_INDEX_DELTAS
|
|
48
|
+
const ADJACENT_ROOM_GRID_INDEX_DELTAS = [LEFT, UP, RIGHT, DOWN] as const;
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* Helper function to get only the adjacent room grid indexes that exist (i.e. have room data).
|
|
@@ -300,10 +300,7 @@ export function getRoomShapeAdjacentExistingGridIndexes(
|
|
|
300
300
|
getRoomShapeAdjacentGridIndexes(safeRoomGridIndex, roomShape),
|
|
301
301
|
);
|
|
302
302
|
|
|
303
|
-
for (const [
|
|
304
|
-
doorSlot,
|
|
305
|
-
roomGridIndex,
|
|
306
|
-
] of roomShapeAdjacentGridIndexes.entries()) {
|
|
303
|
+
for (const [doorSlot, roomGridIndex] of roomShapeAdjacentGridIndexes) {
|
|
307
304
|
const roomData = getRoomData(roomGridIndex);
|
|
308
305
|
if (roomData === undefined) {
|
|
309
306
|
roomShapeAdjacentGridIndexes.delete(doorSlot);
|
|
@@ -369,10 +366,7 @@ export function getRoomShapeAdjacentNonExistingGridIndexes(
|
|
|
369
366
|
getRoomShapeAdjacentGridIndexes(safeRoomGridIndex, roomShape),
|
|
370
367
|
);
|
|
371
368
|
|
|
372
|
-
for (const [
|
|
373
|
-
doorSlot,
|
|
374
|
-
roomGridIndex,
|
|
375
|
-
] of roomShapeAdjacentGridIndexes.entries()) {
|
|
369
|
+
for (const [doorSlot, roomGridIndex] of roomShapeAdjacentGridIndexes) {
|
|
376
370
|
const roomData = getRoomData(roomGridIndex);
|
|
377
371
|
if (roomData !== undefined) {
|
|
378
372
|
roomShapeAdjacentGridIndexes.delete(doorSlot);
|
package/src/functions/map.ts
CHANGED
|
@@ -56,10 +56,10 @@ export function defaultMapSetHash<V>(
|
|
|
56
56
|
* ]);
|
|
57
57
|
* const searchText = "f";
|
|
58
58
|
* const match = getMapPartialMatch(map, searchText); // match is now equal to ["foo", 123]
|
|
59
|
+
* ```
|
|
59
60
|
*
|
|
60
61
|
* @returns If a match was found, returns a tuple of the map key and value. If a match was not
|
|
61
|
-
*
|
|
62
|
-
* ```
|
|
62
|
+
* found, returns undefined.
|
|
63
63
|
*/
|
|
64
64
|
export function getMapPartialMatch<T>(
|
|
65
65
|
searchText: string,
|
package/src/functions/merge.ts
CHANGED
|
@@ -219,7 +219,7 @@ function mergeSerializedTable(
|
|
|
219
219
|
if (!isTable(oldValue)) {
|
|
220
220
|
// The child table does not exist on the old table. However, we still need to copy over
|
|
221
221
|
// the new table, because we need to handle data types like "Foo | null". Thus, set up a
|
|
222
|
-
// blank sub-table on the old table, and continue to recursively merge
|
|
222
|
+
// blank sub-table on the old table, and continue to recursively merge.
|
|
223
223
|
oldValue = new LuaMap();
|
|
224
224
|
oldTable.set(key, oldValue);
|
|
225
225
|
}
|
package/src/functions/minimap.ts
CHANGED
|
@@ -108,7 +108,7 @@ export function setDisplayFlags(
|
|
|
108
108
|
): void {
|
|
109
109
|
const level = game.GetLevel();
|
|
110
110
|
|
|
111
|
-
for (const [roomGridIndex, displayFlags] of displayFlagsMap
|
|
111
|
+
for (const [roomGridIndex, displayFlags] of displayFlagsMap) {
|
|
112
112
|
if (MinimapAPI === undefined) {
|
|
113
113
|
// We pass false to the `updateVisibility` argument as a small optimization.
|
|
114
114
|
setRoomDisplayFlags(roomGridIndex, displayFlags, false);
|
package/src/functions/rng.ts
CHANGED
|
@@ -18,7 +18,7 @@ export type SerializedRNG = LuaMap<string, unknown> & {
|
|
|
18
18
|
const RECOMMENDED_SHIFT_IDX = 35;
|
|
19
19
|
|
|
20
20
|
const OBJECT_NAME = "RNG";
|
|
21
|
-
const KEYS = ["seed"];
|
|
21
|
+
const KEYS = ["seed"] as const;
|
|
22
22
|
|
|
23
23
|
/** Helper function to copy an `RNG` Isaac API class. */
|
|
24
24
|
export function copyRNG(rng: RNG): RNG {
|
package/src/functions/table.ts
CHANGED
|
@@ -13,7 +13,7 @@ export function clearTable(luaMap: LuaMap<AnyNotNil, unknown>): void {
|
|
|
13
13
|
/** Helper function to copy specific values from a userdata object (e.g. `Vector`) to a table. */
|
|
14
14
|
export function copyUserdataValuesToTable(
|
|
15
15
|
object: unknown,
|
|
16
|
-
keys: string[],
|
|
16
|
+
keys: string[] | readonly string[],
|
|
17
17
|
luaMap: LuaMap<string, unknown>,
|
|
18
18
|
): void {
|
|
19
19
|
if (!isUserdata(object)) {
|
package/src/functions/utils.ts
CHANGED
|
@@ -9,15 +9,14 @@ import { CONSOLE_COMMANDS_SET } from "../sets/consoleCommandsSet";
|
|
|
9
9
|
* - For example, `eRange(1, 3)` will return `[1, 2]`.
|
|
10
10
|
* - For example, `eRange(2)` will return `[0, 1]`.
|
|
11
11
|
*
|
|
12
|
-
* @param start The
|
|
13
|
-
* @param end Optional. The
|
|
12
|
+
* @param start The integer to start at.
|
|
13
|
+
* @param end Optional. The integer to end at. If not specified, then the start will be 0 and the
|
|
14
14
|
* first argument will be the end.
|
|
15
15
|
* @param increment Optional. The increment to use. Default is 1.
|
|
16
16
|
*/
|
|
17
17
|
export function eRange(start: int, end?: int, increment = 1): int[] {
|
|
18
18
|
if (end === undefined) {
|
|
19
|
-
|
|
20
|
-
start = 0;
|
|
19
|
+
return eRange(0, start);
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
const array: int[] = [];
|
|
@@ -52,23 +51,18 @@ export function getTraversalDescription(
|
|
|
52
51
|
* - For example, `iRange(1, 3)` will return `[1, 2, 3]`.
|
|
53
52
|
* - For example, `iRange(2)` will return `[0, 1, 2]`.
|
|
54
53
|
*
|
|
55
|
-
* @param start The
|
|
56
|
-
* @param end Optional. The
|
|
54
|
+
* @param start The integer to start at.
|
|
55
|
+
* @param end Optional. The integer to end at. If not specified, then the start will be 0 and the
|
|
57
56
|
* first argument will be the end.
|
|
58
57
|
* @param increment Optional. The increment to use. Default is 1.
|
|
59
58
|
*/
|
|
60
59
|
export function iRange(start: int, end?: int, increment = 1): int[] {
|
|
61
60
|
if (end === undefined) {
|
|
62
|
-
|
|
63
|
-
start = 0;
|
|
61
|
+
return iRange(0, start);
|
|
64
62
|
}
|
|
65
63
|
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
array.push(i);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return array;
|
|
64
|
+
const exclusiveEnd = end + 1;
|
|
65
|
+
return eRange(start, exclusiveEnd, increment);
|
|
72
66
|
}
|
|
73
67
|
|
|
74
68
|
/**
|
|
@@ -226,7 +220,7 @@ export function twoDimensionalSort<T>(array1: T[], array2: T[]): -1 | 0 | 1 {
|
|
|
226
220
|
*
|
|
227
221
|
* This function is only meant to be used with interfaces (i.e. types that will not exist at
|
|
228
222
|
* run-time). If you are generating an object that will contain all of the keys of an enum, use the
|
|
229
|
-
* `
|
|
223
|
+
* `satisfies` operator with the `HasAllEnumValues` helper type instead.
|
|
230
224
|
*/
|
|
231
225
|
export function validateInterfaceMatchesEnum<
|
|
232
226
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
package/src/functions/vector.ts
CHANGED
|
@@ -20,7 +20,7 @@ export type SerializedVector = LuaMap<string, unknown> & {
|
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
const OBJECT_NAME = "Vector";
|
|
23
|
-
const KEYS = ["X", "Y"];
|
|
23
|
+
const KEYS = ["X", "Y"] as const;
|
|
24
24
|
|
|
25
25
|
/** Helper function to copy a `Vector` Isaac API class. */
|
|
26
26
|
export function copyVector(vector: Vector): Vector {
|