isaacscript-common 7.2.0 → 7.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/callbacks/itemPickup.d.ts.map +1 -1
- package/dist/callbacks/itemPickup.lua +3 -1
- package/dist/callbacks/postCustomDoorEnter.d.ts.map +1 -1
- package/dist/callbacks/postCustomDoorEnter.lua +14 -11
- package/dist/callbacks/postItemDischarged.d.ts.map +1 -1
- package/dist/callbacks/postItemDischarged.lua +3 -1
- package/dist/callbacks/postPlayerChangeStat.d.ts.map +1 -1
- package/dist/callbacks/postPlayerChangeStat.lua +10 -7
- package/dist/callbacks/postSlotDestroyed.lua +3 -3
- package/dist/core/constants.d.ts +2 -2
- package/dist/core/constants.d.ts.map +1 -1
- package/dist/core/constants.lua +3 -1
- package/dist/core/constantsFirstLast.d.ts +2 -0
- package/dist/core/constantsFirstLast.d.ts.map +1 -1
- package/dist/core/constantsFirstLast.lua +36 -9
- package/dist/enums/SaveDataKey.d.ts +11 -0
- package/dist/enums/SaveDataKey.d.ts.map +1 -0
- package/dist/enums/{private/SaveDataKey.lua → SaveDataKey.lua} +2 -0
- package/dist/enums/index.d.ts +1 -0
- package/dist/enums/index.d.ts.map +1 -1
- package/dist/enums/index.lua +8 -0
- package/dist/features/customGridEntity.d.ts.map +1 -1
- package/dist/features/customGridEntity.lua +3 -1
- package/dist/features/customStage/backdrop.lua +4 -2
- package/dist/features/customStage/customStageGridEntities.d.ts.map +1 -1
- package/dist/features/customStage/customStageGridEntities.lua +3 -1
- package/dist/features/customStage/exports.d.ts.map +1 -1
- package/dist/features/customStage/exports.lua +3 -1
- package/dist/features/customStage/shadows.d.ts.map +1 -1
- package/dist/features/customStage/shadows.lua +2 -1
- package/dist/features/deployJSONRoom.lua +13 -10
- package/dist/features/extraConsoleCommands/listCommands.d.ts.map +1 -1
- package/dist/features/extraConsoleCommands/listCommands.lua +8 -2
- package/dist/features/saveDataManager/exports.d.ts +2 -1
- package/dist/features/saveDataManager/exports.d.ts.map +1 -1
- package/dist/features/saveDataManager/main.d.ts +1 -1
- package/dist/features/saveDataManager/main.d.ts.map +1 -1
- package/dist/features/saveDataManager/main.lua +1 -1
- package/dist/functions/bitSet128.d.ts.map +1 -1
- package/dist/functions/bosses.d.ts.map +1 -1
- package/dist/functions/bosses.lua +3 -1
- package/dist/functions/collectibles.d.ts.map +1 -1
- package/dist/functions/deepCopy.lua +2 -1
- package/dist/functions/doors.d.ts.map +1 -1
- package/dist/functions/doors.lua +3 -1
- package/dist/functions/entities.lua +2 -1
- package/dist/functions/gridEntities.lua +2 -1
- package/dist/functions/gridEntitiesSpecific.d.ts.map +1 -1
- package/dist/functions/gridEntitiesSpecific.lua +5 -3
- package/dist/functions/input.d.ts +1 -1
- package/dist/functions/input.d.ts.map +1 -1
- package/dist/functions/input.lua +1 -1
- package/dist/functions/kColor.d.ts.map +1 -1
- package/dist/functions/levelGrid.d.ts.map +1 -1
- package/dist/functions/levelGrid.lua +3 -1
- package/dist/functions/nextStage.d.ts.map +1 -1
- package/dist/functions/nextStage.lua +7 -5
- package/dist/functions/npcs.d.ts.map +1 -1
- package/dist/functions/npcs.lua +4 -2
- package/dist/functions/pills.d.ts.map +1 -1
- package/dist/functions/pills.lua +9 -3
- package/dist/functions/playerIndex.d.ts.map +1 -1
- package/dist/functions/playerIndex.lua +2 -1
- package/dist/functions/players.d.ts +1 -1
- package/dist/functions/players.d.ts.map +1 -1
- package/dist/functions/players.lua +13 -15
- package/dist/functions/pocketItems.d.ts.map +1 -1
- package/dist/functions/pocketItems.lua +3 -1
- package/dist/functions/rng.d.ts.map +1 -1
- package/dist/functions/rng.lua +3 -0
- package/dist/functions/rooms.d.ts +4 -4
- package/dist/functions/rooms.d.ts.map +1 -1
- package/dist/functions/rooms.lua +17 -16
- package/dist/functions/spawnCollectible.d.ts.map +1 -1
- package/dist/functions/stage.d.ts.map +1 -1
- package/dist/functions/stage.lua +8 -2
- package/dist/functions/trinkets.d.ts.map +1 -1
- package/dist/functions/trinkets.lua +4 -2
- package/dist/functions/types.d.ts +71 -0
- package/dist/functions/types.d.ts.map +1 -1
- package/dist/functions/types.lua +70 -0
- package/dist/functions/vector.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/callbacks/itemPickup.ts +5 -2
- package/src/callbacks/postCustomDoorEnter.ts +18 -11
- package/src/callbacks/postItemDischarged.ts +2 -1
- package/src/callbacks/postPlayerChangeStat.ts +4 -8
- package/src/callbacks/postSlotDestroyed.ts +3 -2
- package/src/callbacks/reorderedCallbacks.ts +2 -2
- package/src/classes/DefaultMap.ts +1 -1
- package/src/core/constants.ts +3 -3
- package/src/core/constantsFirstLast.ts +29 -14
- package/src/enums/SaveDataKey.ts +10 -0
- package/src/enums/index.ts +1 -0
- package/src/enums/indexTypeDoc.ts +1 -0
- package/src/features/customGridEntity.ts +2 -1
- package/src/features/customStage/backdrop.ts +4 -2
- package/src/features/customStage/customStageGridEntities.ts +2 -1
- package/src/features/customStage/exports.ts +5 -4
- package/src/features/customStage/shadows.ts +2 -1
- package/src/features/deployJSONRoom.ts +14 -19
- package/src/features/extraConsoleCommands/listCommands.ts +3 -2
- package/src/features/saveDataManager/exports.ts +4 -4
- package/src/features/saveDataManager/main.ts +1 -1
- package/src/features/saveDataManager/save.ts +1 -1
- package/src/functions/bitSet128.ts +1 -5
- package/src/functions/bosses.ts +2 -1
- package/src/functions/cards.ts +3 -3
- package/src/functions/collectibles.ts +2 -8
- package/src/functions/color.ts +1 -1
- package/src/functions/deepCopy.ts +2 -2
- package/src/functions/dimensions.ts +1 -1
- package/src/functions/doors.ts +2 -2
- package/src/functions/entities.ts +2 -2
- package/src/functions/gridEntities.ts +2 -2
- package/src/functions/gridEntitiesSpecific.ts +4 -3
- package/src/functions/input.ts +2 -2
- package/src/functions/jsonHelpers.ts +1 -1
- package/src/functions/kColor.ts +1 -5
- package/src/functions/levelGrid.ts +3 -2
- package/src/functions/nextStage.ts +6 -5
- package/src/functions/npcs.ts +3 -2
- package/src/functions/pills.ts +11 -9
- package/src/functions/playerIndex.ts +3 -1
- package/src/functions/players.ts +5 -6
- package/src/functions/pocketItems.ts +4 -4
- package/src/functions/rng.ts +8 -5
- package/src/functions/rooms.ts +26 -26
- package/src/functions/spawnCollectible.ts +1 -2
- package/src/functions/stage.ts +3 -2
- package/src/functions/trinkets.ts +6 -5
- package/src/functions/types.ts +111 -0
- package/src/functions/vector.ts +1 -5
- package/dist/enums/private/SaveDataKey.d.ts +0 -7
- package/dist/enums/private/SaveDataKey.d.ts.map +0 -1
- package/src/enums/private/SaveDataKey.ts +0 -6
|
@@ -6,7 +6,7 @@ import { AnyEntity } from "../types/AnyEntity";
|
|
|
6
6
|
import { getIsaacAPIClassName } from "./isaacAPIClass";
|
|
7
7
|
import { getRandom } from "./random";
|
|
8
8
|
import { isRNG, newRNG } from "./rng";
|
|
9
|
-
import { isPrimitive } from "./types";
|
|
9
|
+
import { asNumber, isPrimitive } from "./types";
|
|
10
10
|
import { isVector, vectorToString } from "./vector";
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -122,7 +122,7 @@ export function getEntities(
|
|
|
122
122
|
subType = -1,
|
|
123
123
|
ignoreFriendly = false,
|
|
124
124
|
): Entity[] {
|
|
125
|
-
if ((entityType
|
|
125
|
+
if (asNumber(entityType) === -1) {
|
|
126
126
|
return Isaac.GetRoomEntities();
|
|
127
127
|
}
|
|
128
128
|
|
|
@@ -19,7 +19,7 @@ import { AnyGridEntity } from "../types/AnyGridEntity";
|
|
|
19
19
|
import { isCircleIntersectingRectangle } from "./math";
|
|
20
20
|
import { roomUpdateSafe } from "./rooms";
|
|
21
21
|
import { clearSprite } from "./sprites";
|
|
22
|
-
import { isNumber } from "./types";
|
|
22
|
+
import { asNumber, isNumber } from "./types";
|
|
23
23
|
import { erange } from "./utils";
|
|
24
24
|
import { isVector } from "./vector";
|
|
25
25
|
|
|
@@ -136,7 +136,7 @@ export function getCollidingEntitiesWithGridEntity(
|
|
|
136
136
|
export function getCrawlSpaces(
|
|
137
137
|
crawlSpaceVariant: CrawlSpaceVariant = -1,
|
|
138
138
|
): GridEntity[] {
|
|
139
|
-
if ((crawlSpaceVariant
|
|
139
|
+
if (asNumber(crawlSpaceVariant) === -1) {
|
|
140
140
|
return getGridEntities(GridEntityType.CRAWL_SPACE);
|
|
141
141
|
}
|
|
142
142
|
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
removeGridEntities,
|
|
12
12
|
spawnGridEntityWithVariant,
|
|
13
13
|
} from "./gridEntities";
|
|
14
|
+
import { asNumber } from "./types";
|
|
14
15
|
|
|
15
16
|
// The `getDoors` function is not located here because doors are collected via the `Room.GetDoor`
|
|
16
17
|
// method instead, which is faster.
|
|
@@ -29,7 +30,7 @@ export function getPits(pitVariant: PitVariant = -1): GridEntityPit[] {
|
|
|
29
30
|
const pit = gridEntity.ToPit();
|
|
30
31
|
if (pit !== undefined) {
|
|
31
32
|
const gridEntityVariant = pit.GetVariant();
|
|
32
|
-
if ((pitVariant
|
|
33
|
+
if (asNumber(pitVariant) === -1 || pitVariant === gridEntityVariant) {
|
|
33
34
|
pits.push(pit);
|
|
34
35
|
}
|
|
35
36
|
}
|
|
@@ -54,7 +55,7 @@ export function getPoops(
|
|
|
54
55
|
const poop = gridEntity.ToPoop();
|
|
55
56
|
if (poop !== undefined) {
|
|
56
57
|
const gridEntityVariant = poop.GetVariant();
|
|
57
|
-
if ((poopVariant
|
|
58
|
+
if (asNumber(poopVariant) === -1 || poopVariant === gridEntityVariant) {
|
|
58
59
|
poops.push(poop);
|
|
59
60
|
}
|
|
60
61
|
}
|
|
@@ -80,7 +81,7 @@ export function getPressurePlates(
|
|
|
80
81
|
if (pressurePlate !== undefined) {
|
|
81
82
|
const gridEntityVariant = pressurePlate.GetVariant();
|
|
82
83
|
if (
|
|
83
|
-
(pressurePlateVariant
|
|
84
|
+
asNumber(pressurePlateVariant) === -1 ||
|
|
84
85
|
pressurePlateVariant === gridEntityVariant
|
|
85
86
|
) {
|
|
86
87
|
pressurePlates.push(pressurePlate);
|
package/src/functions/input.ts
CHANGED
|
@@ -43,10 +43,10 @@ const SHOOTING_ACTIONS_SET: ReadonlySet<ButtonAction> = new Set(
|
|
|
43
43
|
);
|
|
44
44
|
|
|
45
45
|
/** Helper function to get the enum name for the specified `Controller` value. */
|
|
46
|
-
export function controllerToString(controller: Controller): string {
|
|
46
|
+
export function controllerToString(controller: Controller): string | undefined {
|
|
47
47
|
const key = Controller[controller];
|
|
48
48
|
if (key === undefined) {
|
|
49
|
-
return
|
|
49
|
+
return undefined;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
return trimPrefix(key, "BUTTON_");
|
|
@@ -2,7 +2,7 @@ import * as jsonLua from "../lib/jsonLua";
|
|
|
2
2
|
import { logError } from "./log";
|
|
3
3
|
|
|
4
4
|
function tryDecode(this: void, jsonString: string) {
|
|
5
|
-
return jsonLua.decode(jsonString) as LuaMap
|
|
5
|
+
return jsonLua.decode(jsonString) as LuaMap<AnyNotNil, unknown>;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
function tryEncode(this: void, luaTable: unknown) {
|
package/src/functions/kColor.ts
CHANGED
|
@@ -34,11 +34,7 @@ export function deserializeKColor(kColor: SerializedKColor): KColor {
|
|
|
34
34
|
);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
const [r, g, b, a] = getNumbersFromTable(
|
|
38
|
-
kColor as LuaMap<string, unknown>,
|
|
39
|
-
OBJECT_NAME,
|
|
40
|
-
...KEYS,
|
|
41
|
-
);
|
|
37
|
+
const [r, g, b, a] = getNumbersFromTable(kColor, OBJECT_NAME, ...KEYS);
|
|
42
38
|
|
|
43
39
|
if (r === undefined) {
|
|
44
40
|
error(
|
|
@@ -37,6 +37,7 @@ import {
|
|
|
37
37
|
} from "./roomData";
|
|
38
38
|
import { getRooms, getRoomsInsideGrid } from "./rooms";
|
|
39
39
|
import { getGridIndexDelta } from "./roomShape";
|
|
40
|
+
import { asNumber } from "./types";
|
|
40
41
|
|
|
41
42
|
const LEFT = -1;
|
|
42
43
|
const UP = -LEVEL_GRID_ROW_WIDTH;
|
|
@@ -177,8 +178,8 @@ export function getNewRoomCandidatesForLevel(): Array<
|
|
|
177
178
|
(room) =>
|
|
178
179
|
room.Data !== undefined &&
|
|
179
180
|
room.Data.Type === RoomType.DEFAULT &&
|
|
180
|
-
room.Data.Subtype !== (DownpourRoomSubType.MIRROR
|
|
181
|
-
room.Data.Subtype !== (MinesRoomSubType.MINESHAFT_ENTRANCE
|
|
181
|
+
room.Data.Subtype !== asNumber(DownpourRoomSubType.MIRROR) &&
|
|
182
|
+
room.Data.Subtype !== asNumber(MinesRoomSubType.MINESHAFT_ENTRANCE),
|
|
182
183
|
);
|
|
183
184
|
|
|
184
185
|
const newRoomCandidates: Array<[int, DoorSlot, int]> = [];
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
calculateStageTypeRepentance,
|
|
14
14
|
onRepentanceStage,
|
|
15
15
|
} from "./stage";
|
|
16
|
+
import { asNumber } from "./types";
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* Helper function to get the stage that a trapdoor or heaven door would take the player to, based
|
|
@@ -53,7 +54,7 @@ export function getNextStage(): LevelStage {
|
|
|
53
54
|
case GridRoom.SECRET_EXIT: {
|
|
54
55
|
if (repentanceStage) {
|
|
55
56
|
// e.g. From Downpour 2 to Mines 1, etc.
|
|
56
|
-
return (stage
|
|
57
|
+
return asNumber(stage) + 1;
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
if (stage === LevelStage.DEPTHS_2) {
|
|
@@ -109,7 +110,7 @@ export function getNextStage(): LevelStage {
|
|
|
109
110
|
}
|
|
110
111
|
|
|
111
112
|
// By default, go to the next floor.
|
|
112
|
-
return (stage
|
|
113
|
+
return asNumber(stage) + 1;
|
|
113
114
|
}
|
|
114
115
|
|
|
115
116
|
function getNextStageBackwardsPath(
|
|
@@ -118,7 +119,7 @@ function getNextStageBackwardsPath(
|
|
|
118
119
|
): LevelStage {
|
|
119
120
|
// If we have no stage history to work with, then default to the previous stage.
|
|
120
121
|
if (!areFeaturesInitialized()) {
|
|
121
|
-
return (stage
|
|
122
|
+
return asNumber(stage) - 1;
|
|
122
123
|
}
|
|
123
124
|
|
|
124
125
|
const visitedDownpour1 = hasVisitedStage(
|
|
@@ -234,7 +235,7 @@ function getNextStageBackwardsPath(
|
|
|
234
235
|
return LevelStage.DEPTHS_1;
|
|
235
236
|
}
|
|
236
237
|
|
|
237
|
-
return (stage
|
|
238
|
+
return asNumber(stage) - 1;
|
|
238
239
|
}
|
|
239
240
|
|
|
240
241
|
/**
|
|
@@ -262,7 +263,7 @@ export function getNextStageType(upwards = false): StageType {
|
|
|
262
263
|
}
|
|
263
264
|
|
|
264
265
|
// Second, handle the special case of being in a specific off-grid room.
|
|
265
|
-
if (roomGridIndex === (GridRoom.SECRET_EXIT
|
|
266
|
+
if (roomGridIndex === asNumber(GridRoom.SECRET_EXIT)) {
|
|
266
267
|
return calculateStageTypeRepentance(nextStage);
|
|
267
268
|
}
|
|
268
269
|
|
package/src/functions/npcs.ts
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
} from "isaac-typescript-definitions";
|
|
18
18
|
import { EGGY_STATE_FRAME_OF_FINAL_SPIDER } from "../core/constants";
|
|
19
19
|
import { getNPCs } from "./entitiesSpecific";
|
|
20
|
+
import { asNumber } from "./types";
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* Used to filter out certain NPCs when determining of an NPC is "alive" and/or should keep the
|
|
@@ -125,7 +126,7 @@ export function isDaddyLongLegsChildStompEntity(npc: EntityNPC): boolean {
|
|
|
125
126
|
export function isDyingEggyWithNoSpidersLeft(npc: EntityNPC): boolean {
|
|
126
127
|
return (
|
|
127
128
|
npc.Type === EntityType.HOPPER &&
|
|
128
|
-
npc.Variant === (HopperVariant.EGGY
|
|
129
|
+
npc.Variant === asNumber(HopperVariant.EGGY) &&
|
|
129
130
|
npc.State === NpcState.SUICIDE &&
|
|
130
131
|
npc.StateFrame >= EGGY_STATE_FRAME_OF_FINAL_SPIDER
|
|
131
132
|
);
|
|
@@ -140,7 +141,7 @@ export function isDyingEggyWithNoSpidersLeft(npc: EntityNPC): boolean {
|
|
|
140
141
|
export function isRaglingDeathPatch(npc: EntityNPC): boolean {
|
|
141
142
|
return (
|
|
142
143
|
npc.Type === EntityType.RAGLING &&
|
|
143
|
-
npc.Variant === (RaglingVariant.RAG_MANS_RAGLING
|
|
144
|
+
npc.Variant === asNumber(RaglingVariant.RAG_MANS_RAGLING) &&
|
|
144
145
|
// They go to `STATE_SPECIAL` when they are patches on the ground.
|
|
145
146
|
npc.State === NpcState.SPECIAL
|
|
146
147
|
);
|
package/src/functions/pills.ts
CHANGED
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
PILL_EFFECT_TYPES,
|
|
31
31
|
} from "../objects/pillEffectTypes";
|
|
32
32
|
import { getEnumValues } from "./enums";
|
|
33
|
+
import { asNumber, asPillColor } from "./types";
|
|
33
34
|
import { irange } from "./utils";
|
|
34
35
|
|
|
35
36
|
/**
|
|
@@ -55,7 +56,7 @@ export function getAllPillColors(): PillColor[] {
|
|
|
55
56
|
* Helper function to get an array with every valid pill effect. This includes modded pill effects.
|
|
56
57
|
*/
|
|
57
58
|
export function getAllPillEffects(): PillEffect[] {
|
|
58
|
-
return irange(FIRST_PILL_EFFECT, LAST_PILL_EFFECT)
|
|
59
|
+
return irange(FIRST_PILL_EFFECT, LAST_PILL_EFFECT);
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
/**
|
|
@@ -74,12 +75,12 @@ export function getFalsePHDPillEffect(pillEffect: PillEffect): PillEffect {
|
|
|
74
75
|
* corresponds to the horse pill color for blue/blue.
|
|
75
76
|
*/
|
|
76
77
|
export function getHorsePillColor(pillColor: PillColor): PillColor {
|
|
77
|
-
return pillColor + HORSE_PILL_ADJUSTMENT;
|
|
78
|
+
return asNumber(pillColor) + HORSE_PILL_ADJUSTMENT;
|
|
78
79
|
}
|
|
79
80
|
|
|
80
81
|
/** Helper function to get an array with every non-gold horse pill color. */
|
|
81
82
|
export function getHorsePillColors(): PillColor[] {
|
|
82
|
-
return irange(FIRST_HORSE_PILL_COLOR, LAST_HORSE_PILL_COLOR)
|
|
83
|
+
return irange(FIRST_HORSE_PILL_COLOR, LAST_HORSE_PILL_COLOR);
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
/**
|
|
@@ -92,7 +93,7 @@ export function getModdedPillEffects(): PillEffect[] {
|
|
|
92
93
|
return [];
|
|
93
94
|
}
|
|
94
95
|
|
|
95
|
-
return irange(FIRST_MODDED_PILL_EFFECT, LAST_PILL_EFFECT)
|
|
96
|
+
return irange(FIRST_MODDED_PILL_EFFECT, LAST_PILL_EFFECT);
|
|
96
97
|
}
|
|
97
98
|
|
|
98
99
|
/**
|
|
@@ -103,15 +104,16 @@ export function getModdedPillEffects(): PillEffect[] {
|
|
|
103
104
|
* If called with a non-horse pill color, this function will return back the same color.
|
|
104
105
|
*/
|
|
105
106
|
export function getNormalPillColorFromHorse(pillColor: PillColor): PillColor {
|
|
106
|
-
|
|
107
|
-
|
|
107
|
+
const normalPillColor = asPillColor(
|
|
108
|
+
asNumber(pillColor) - HORSE_PILL_ADJUSTMENT,
|
|
109
|
+
);
|
|
108
110
|
|
|
109
111
|
return normalPillColor > PillColor.NULL ? normalPillColor : pillColor;
|
|
110
112
|
}
|
|
111
113
|
|
|
112
114
|
/** Helper function to get an array with every non-gold and non-horse pill color. */
|
|
113
115
|
export function getNormalPillColors(): PillColor[] {
|
|
114
|
-
return irange(FIRST_PILL_COLOR, LAST_NORMAL_PILL_COLOR)
|
|
116
|
+
return irange(FIRST_PILL_COLOR, LAST_NORMAL_PILL_COLOR);
|
|
115
117
|
}
|
|
116
118
|
|
|
117
119
|
/**
|
|
@@ -197,9 +199,9 @@ export function getPillEffectType(
|
|
|
197
199
|
|
|
198
200
|
/** Helper function to get an array with every vanilla pill effect. */
|
|
199
201
|
export function getVanillaPillEffects(): PillEffect[] {
|
|
200
|
-
return irange(FIRST_PILL_EFFECT, LAST_VANILLA_PILL_EFFECT)
|
|
202
|
+
return irange(FIRST_PILL_EFFECT, LAST_VANILLA_PILL_EFFECT);
|
|
201
203
|
}
|
|
202
204
|
|
|
203
205
|
export function isHorsePill(pillColor: PillColor): boolean {
|
|
204
|
-
return pillColor >
|
|
206
|
+
return asNumber(pillColor) > HORSE_PILL_ADJUSTMENT;
|
|
205
207
|
}
|
|
@@ -96,9 +96,11 @@ export function getPlayerIndex(
|
|
|
96
96
|
let playerToUse = player;
|
|
97
97
|
const isSubPlayer = player.IsSubPlayer();
|
|
98
98
|
if (isSubPlayer) {
|
|
99
|
+
const subPlayer = player as EntitySubPlayer;
|
|
100
|
+
|
|
99
101
|
// The "getSubPlayerParent" function will return undefined in the situation where we are on Dead
|
|
100
102
|
// Tainted Lazarus in the `POST_PLAYER_INIT` callback.
|
|
101
|
-
const playerParent = getSubPlayerParent(
|
|
103
|
+
const playerParent = getSubPlayerParent(subPlayer);
|
|
102
104
|
if (playerParent !== undefined) {
|
|
103
105
|
playerToUse = playerParent;
|
|
104
106
|
}
|
package/src/functions/players.ts
CHANGED
|
@@ -23,6 +23,7 @@ import { getCollectibleArray } from "./collectibleSet";
|
|
|
23
23
|
import { getEnumValues } from "./enums";
|
|
24
24
|
import { getPlayerIndexVanilla, getPlayers } from "./playerIndex";
|
|
25
25
|
import { addTearsStat } from "./tears";
|
|
26
|
+
import { isNumber } from "./types";
|
|
26
27
|
import { repeat } from "./utils";
|
|
27
28
|
|
|
28
29
|
const STAT_CACHE_FLAGS_SET: ReadonlySet<CacheFlag> = new Set([
|
|
@@ -225,16 +226,14 @@ export function getActiveItemSlot(
|
|
|
225
226
|
* Helper function to get how long Azazel's Brimstone laser should be. You can pass either an
|
|
226
227
|
* `EntityPlayer` object or a tear height stat.
|
|
227
228
|
*
|
|
228
|
-
* The formula for calculating it is: 32 - 2.5 *
|
|
229
|
+
* The formula for calculating it is: 32 - 2.5 * tearHeight
|
|
229
230
|
*/
|
|
230
231
|
export function getAzazelBrimstoneDistance(
|
|
231
232
|
playerOrTearHeight: EntityPlayer | float,
|
|
232
233
|
): float {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
tearHeight = player.TearHeight;
|
|
237
|
-
}
|
|
234
|
+
const tearHeight = isNumber(playerOrTearHeight)
|
|
235
|
+
? playerOrTearHeight
|
|
236
|
+
: playerOrTearHeight.TearHeight;
|
|
238
237
|
|
|
239
238
|
return 32 - 2.5 * tearHeight;
|
|
240
239
|
}
|
|
@@ -10,6 +10,7 @@ import { PocketItemType } from "../enums/PocketItemType";
|
|
|
10
10
|
import { PocketItemDescription } from "../interfaces/PocketItemDescription";
|
|
11
11
|
import { getEnumValues } from "./enums";
|
|
12
12
|
import { isCharacter } from "./players";
|
|
13
|
+
import { asNumber } from "./types";
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* Helper function to get the `PocketItemSlot` that the player's pocket active collectible item is
|
|
@@ -63,8 +64,8 @@ export function getPocketItems(player: EntityPlayer): PocketItemDescription[] {
|
|
|
63
64
|
let pocketItemIdentified = false;
|
|
64
65
|
let pocketItem2Identified = false;
|
|
65
66
|
for (const slot of pocketItemSlots) {
|
|
66
|
-
const card = player.GetCard(slot
|
|
67
|
-
const pillColor = player.GetPill(slot
|
|
67
|
+
const card = player.GetCard(slot);
|
|
68
|
+
const pillColor = player.GetPill(slot);
|
|
68
69
|
|
|
69
70
|
if (card !== Card.NULL) {
|
|
70
71
|
pocketItems.push({
|
|
@@ -106,8 +107,7 @@ export function getPocketItems(player: EntityPlayer): PocketItemDescription[] {
|
|
|
106
107
|
});
|
|
107
108
|
}
|
|
108
109
|
|
|
109
|
-
|
|
110
|
-
if (slot + 1 === maxPocketItems) {
|
|
110
|
+
if (asNumber(slot) + 1 === maxPocketItems) {
|
|
111
111
|
break;
|
|
112
112
|
}
|
|
113
113
|
}
|
package/src/functions/rng.ts
CHANGED
|
@@ -41,11 +41,14 @@ export function deserializeRNG(rng: SerializedRNG): RNG {
|
|
|
41
41
|
);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
const [seed] = getNumbersFromTable(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
const [seed] = getNumbersFromTable(rng, OBJECT_NAME, ...KEYS);
|
|
45
|
+
|
|
46
|
+
if (seed === undefined) {
|
|
47
|
+
error(
|
|
48
|
+
`Failed to deserialize a ${OBJECT_NAME} object since the provided object did not have a value for: seed`,
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
49
52
|
return newRNG(seed as Seed);
|
|
50
53
|
}
|
|
51
54
|
|
package/src/functions/rooms.ts
CHANGED
|
@@ -16,10 +16,10 @@ import {
|
|
|
16
16
|
StageID,
|
|
17
17
|
} from "isaac-typescript-definitions";
|
|
18
18
|
import { game, sfxManager } from "../core/cachedClasses";
|
|
19
|
-
import { MAX_LEVEL_GRID_INDEX
|
|
19
|
+
import { MAX_LEVEL_GRID_INDEX } from "../core/constants";
|
|
20
20
|
import { ROOM_TYPE_NAMES } from "../objects/roomTypeNames";
|
|
21
21
|
import { MINE_SHAFT_ROOM_SUB_TYPE_SET } from "../sets/mineShaftRoomSubTypesSet";
|
|
22
|
-
import { inDimension } from "./dimensions";
|
|
22
|
+
import { getAllDimensions, inDimension } from "./dimensions";
|
|
23
23
|
import {
|
|
24
24
|
closeAllDoors,
|
|
25
25
|
getDoors,
|
|
@@ -45,7 +45,8 @@ import {
|
|
|
45
45
|
} from "./roomData";
|
|
46
46
|
import { reloadRoom } from "./roomTransition";
|
|
47
47
|
import { getGotoCommand } from "./stage";
|
|
48
|
-
import {
|
|
48
|
+
import { asNumber } from "./types";
|
|
49
|
+
import { irange } from "./utils";
|
|
49
50
|
|
|
50
51
|
/**
|
|
51
52
|
* Helper function for quickly switching to a new room without playing a particular animation. Use
|
|
@@ -207,7 +208,7 @@ export function getRoomsInsideGrid(
|
|
|
207
208
|
const level = game.GetLevel();
|
|
208
209
|
|
|
209
210
|
const dimensions = includeExtraDimensionalRooms
|
|
210
|
-
? (
|
|
211
|
+
? getAllDimensions()
|
|
211
212
|
: [Dimension.CURRENT];
|
|
212
213
|
|
|
213
214
|
/** We use a map instead of an array because room shapes occupy more than one room grid index. */
|
|
@@ -284,8 +285,10 @@ export function inAngelShop(): boolean {
|
|
|
284
285
|
const roomType = room.GetType();
|
|
285
286
|
const roomSubType = getRoomSubType();
|
|
286
287
|
|
|
287
|
-
|
|
288
|
-
|
|
288
|
+
return (
|
|
289
|
+
roomType === RoomType.ANGEL &&
|
|
290
|
+
roomSubType === asNumber(AngelRoomSubType.SHOP)
|
|
291
|
+
);
|
|
289
292
|
}
|
|
290
293
|
|
|
291
294
|
export function inBeastRoom(): boolean {
|
|
@@ -294,8 +297,8 @@ export function inBeastRoom(): boolean {
|
|
|
294
297
|
const roomSubType = getRoomSubType();
|
|
295
298
|
|
|
296
299
|
return (
|
|
297
|
-
|
|
298
|
-
|
|
300
|
+
roomType === RoomType.DUNGEON &&
|
|
301
|
+
roomSubType === asNumber(DungeonSubType.BEAST_ROOM)
|
|
299
302
|
);
|
|
300
303
|
}
|
|
301
304
|
|
|
@@ -312,7 +315,7 @@ export function inBossRoomOf(bossID: BossID): boolean {
|
|
|
312
315
|
return (
|
|
313
316
|
roomType === RoomType.BOSS &&
|
|
314
317
|
roomStageID === StageID.SPECIAL_ROOMS &&
|
|
315
|
-
roomSubType === bossID
|
|
318
|
+
roomSubType === asNumber(bossID)
|
|
316
319
|
);
|
|
317
320
|
}
|
|
318
321
|
|
|
@@ -326,13 +329,14 @@ export function inCrawlSpace(): boolean {
|
|
|
326
329
|
const roomType = room.GetType();
|
|
327
330
|
const roomSubType = getRoomSubType();
|
|
328
331
|
|
|
329
|
-
|
|
330
|
-
|
|
332
|
+
return (
|
|
333
|
+
roomType === RoomType.DUNGEON &&
|
|
334
|
+
roomSubType === asNumber(DungeonSubType.NORMAL)
|
|
335
|
+
);
|
|
331
336
|
}
|
|
332
337
|
|
|
333
338
|
/**
|
|
334
|
-
*
|
|
335
|
-
* with the Death Certificate area.
|
|
339
|
+
* Helper function to detect if the current room is one of the room in the Death Certificate area.
|
|
336
340
|
*/
|
|
337
341
|
export function inDeathCertificateArea(): boolean {
|
|
338
342
|
const roomStageID = getRoomStageID();
|
|
@@ -340,17 +344,16 @@ export function inDeathCertificateArea(): boolean {
|
|
|
340
344
|
|
|
341
345
|
return (
|
|
342
346
|
roomStageID === StageID.HOME &&
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
// eslint-disable-next-line isaacscript/strict-enums
|
|
346
|
-
roomSubType === HomeRoomSubType.DEATH_CERTIFICATE_ITEMS)
|
|
347
|
+
(roomSubType === asNumber(HomeRoomSubType.DEATH_CERTIFICATE_ENTRANCE) ||
|
|
348
|
+
roomSubType === asNumber(HomeRoomSubType.DEATH_CERTIFICATE_ITEMS))
|
|
347
349
|
);
|
|
348
350
|
}
|
|
349
351
|
|
|
350
352
|
/**
|
|
351
353
|
* Helper function to detect if the current room is a Treasure Room created when entering with a
|
|
352
|
-
* Devil's Crown trinket.
|
|
353
|
-
*
|
|
354
|
+
* Devil's Crown trinket.
|
|
355
|
+
*
|
|
356
|
+
* Under the hood, this checks for `RoomDescriptorFlag.DEVIL_TREASURE`.
|
|
354
357
|
*/
|
|
355
358
|
export function inDevilsCrownTreasureRoom(): boolean {
|
|
356
359
|
const roomDescriptor = getRoomDescriptorReadOnly();
|
|
@@ -368,8 +371,7 @@ export function inDoubleTrouble(): boolean {
|
|
|
368
371
|
export function inGenesisRoom(): boolean {
|
|
369
372
|
const roomGridIndex = getRoomGridIndex();
|
|
370
373
|
|
|
371
|
-
|
|
372
|
-
return roomGridIndex === GridRoom.GENESIS;
|
|
374
|
+
return roomGridIndex === asNumber(GridRoom.GENESIS);
|
|
373
375
|
}
|
|
374
376
|
|
|
375
377
|
/** Helper function to determine if the current room shape is one of the four L room shapes. */
|
|
@@ -388,8 +390,7 @@ export function inLRoom(): boolean {
|
|
|
388
390
|
export function inMegaSatanRoom(): boolean {
|
|
389
391
|
const roomGridIndex = getRoomGridIndex();
|
|
390
392
|
|
|
391
|
-
|
|
392
|
-
return roomGridIndex === GridRoom.MEGA_SATAN;
|
|
393
|
+
return roomGridIndex === asNumber(GridRoom.MEGA_SATAN);
|
|
393
394
|
}
|
|
394
395
|
|
|
395
396
|
/**
|
|
@@ -420,7 +421,7 @@ export function inMinibossRoomOf(minibossID: MinibossID): boolean {
|
|
|
420
421
|
return (
|
|
421
422
|
roomType === RoomType.MINI_BOSS &&
|
|
422
423
|
roomStageID === StageID.SPECIAL_ROOMS &&
|
|
423
|
-
roomSubType === minibossID
|
|
424
|
+
roomSubType === asNumber(minibossID)
|
|
424
425
|
);
|
|
425
426
|
}
|
|
426
427
|
|
|
@@ -434,8 +435,7 @@ export function inMinibossRoomOf(minibossID: MinibossID): boolean {
|
|
|
434
435
|
export function inSecretShop(): boolean {
|
|
435
436
|
const roomGridIndex = getRoomGridIndex();
|
|
436
437
|
|
|
437
|
-
|
|
438
|
-
return roomGridIndex === GridRoom.SECRET_SHOP;
|
|
438
|
+
return roomGridIndex === asNumber(GridRoom.SECRET_SHOP);
|
|
439
439
|
}
|
|
440
440
|
|
|
441
441
|
/**
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CollectibleType,
|
|
3
|
-
PickupPrice,
|
|
4
3
|
PickupVariant,
|
|
5
4
|
PlayerType,
|
|
6
5
|
} from "isaac-typescript-definitions";
|
|
@@ -65,7 +64,7 @@ export function spawnCollectible(
|
|
|
65
64
|
|
|
66
65
|
// We can set the price to any arbitrary value; it will auto-update to the true price on the
|
|
67
66
|
// next frame.
|
|
68
|
-
collectible.Price = 15
|
|
67
|
+
collectible.Price = 15;
|
|
69
68
|
}
|
|
70
69
|
|
|
71
70
|
if (isQuestCollectible(collectibleType) && areFeaturesInitialized()) {
|
package/src/functions/stage.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { game } from "../core/cachedClasses";
|
|
|
8
8
|
import { ROOM_TYPE_GOTO_PREFIXES } from "../objects/roomTypeGotoPrefixes";
|
|
9
9
|
import { STAGE_TYPE_SUFFIXES } from "../objects/stageTypeSuffixes";
|
|
10
10
|
import { STAGE_TYPE_TO_LETTER } from "../objects/stageTypeToLetter";
|
|
11
|
+
import { asLevelStage, asNumber } from "./types";
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Helper function that calculates what the stage type should be for the provided stage. This
|
|
@@ -57,7 +58,7 @@ export function calculateStageTypeRepentance(stage: LevelStage): StageType {
|
|
|
57
58
|
// This algorithm is from Kilburn. We add one because the alt path is offset by 1 relative to the
|
|
58
59
|
// normal path.
|
|
59
60
|
const seeds = game.GetSeeds();
|
|
60
|
-
const adjustedStage = ((stage
|
|
61
|
+
const adjustedStage = asLevelStage(asNumber(stage) + 1);
|
|
61
62
|
const stageSeed = seeds.GetStageSeed(adjustedStage);
|
|
62
63
|
|
|
63
64
|
// Kilburn does not know why he divided the stage seed by 2 first.
|
|
@@ -79,7 +80,7 @@ export function getEffectiveStage(): int {
|
|
|
79
80
|
const stage = level.GetStage();
|
|
80
81
|
|
|
81
82
|
if (onRepentanceStage()) {
|
|
82
|
-
return stage + 1;
|
|
83
|
+
return asNumber(stage) + 1;
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
return stage;
|
|
@@ -21,6 +21,7 @@ import { hasFlag } from "./flag";
|
|
|
21
21
|
import { isTrinket } from "./pickupVariants";
|
|
22
22
|
import { isCharacter } from "./players";
|
|
23
23
|
import { clearSprite } from "./sprites";
|
|
24
|
+
import { asNumber } from "./types";
|
|
24
25
|
import { irange } from "./utils";
|
|
25
26
|
|
|
26
27
|
/**
|
|
@@ -41,7 +42,7 @@ const TRINKET_SPRITE_LAYER = 0;
|
|
|
41
42
|
* corresponds to the golden trinket sub-type for Swallowed Penny.
|
|
42
43
|
*/
|
|
43
44
|
export function getGoldenTrinketType(trinketType: TrinketType): TrinketType {
|
|
44
|
-
return trinketType + GOLDEN_TRINKET_ADJUSTMENT;
|
|
45
|
+
return asNumber(trinketType) + GOLDEN_TRINKET_ADJUSTMENT;
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
/**
|
|
@@ -54,7 +55,7 @@ export function getModdedTrinketTypes(): TrinketType[] {
|
|
|
54
55
|
return [];
|
|
55
56
|
}
|
|
56
57
|
|
|
57
|
-
return irange(FIRST_MODDED_TRINKET_TYPE, LAST_TRINKET_TYPE)
|
|
58
|
+
return irange(FIRST_MODDED_TRINKET_TYPE, LAST_TRINKET_TYPE);
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
/**
|
|
@@ -140,12 +141,12 @@ export function getTrinketName(trinketType: TrinketType): string {
|
|
|
140
141
|
|
|
141
142
|
/** Helper function to get an array that contains every trinket type. */
|
|
142
143
|
export function getTrinketTypes(): TrinketType[] {
|
|
143
|
-
return irange(FIRST_TRINKET_TYPE, LAST_TRINKET_TYPE)
|
|
144
|
+
return irange(FIRST_TRINKET_TYPE, LAST_TRINKET_TYPE);
|
|
144
145
|
}
|
|
145
146
|
|
|
146
147
|
/** Helper function to get an array that represents every vanilla trinket type. */
|
|
147
148
|
export function getVanillaTrinketTypes(): TrinketType[] {
|
|
148
|
-
return irange(FIRST_TRINKET_TYPE, LAST_VANILLA_TRINKET_TYPE)
|
|
149
|
+
return irange(FIRST_TRINKET_TYPE, LAST_VANILLA_TRINKET_TYPE);
|
|
149
150
|
}
|
|
150
151
|
|
|
151
152
|
/**
|
|
@@ -165,7 +166,7 @@ export function hasOpenTrinketSlot(player: EntityPlayer): boolean {
|
|
|
165
166
|
}
|
|
166
167
|
|
|
167
168
|
export function isGoldenTrinket(trinketType: TrinketType): boolean {
|
|
168
|
-
return trinketType >
|
|
169
|
+
return asNumber(trinketType) > GOLDEN_TRINKET_ADJUSTMENT;
|
|
169
170
|
}
|
|
170
171
|
|
|
171
172
|
/**
|