isaacscript-common 13.0.0 → 13.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +105 -26
- package/dist/isaacscript-common.lua +615 -168
- package/dist/src/features/customStage/backdrop.lua +4 -4
- package/dist/src/features/customStage/versusScreen.lua +2 -2
- package/dist/src/features/deployJSONRoom.d.ts +0 -11
- package/dist/src/features/deployJSONRoom.d.ts.map +1 -1
- package/dist/src/features/deployJSONRoom.lua +10 -74
- package/dist/src/features/extraConsoleCommands/listCommands.lua +2 -2
- package/dist/src/features/firstLast.lua +8 -8
- package/dist/src/features/setHotkey.d.ts +27 -8
- package/dist/src/features/setHotkey.d.ts.map +1 -1
- package/dist/src/features/setHotkey.lua +41 -30
- package/dist/src/functions/array.lua +2 -2
- package/dist/src/functions/cards.lua +2 -2
- package/dist/src/functions/collectibles.lua +2 -2
- package/dist/src/functions/dimensions.lua +2 -2
- package/dist/src/functions/emptyRoom.d.ts +8 -0
- package/dist/src/functions/emptyRoom.d.ts.map +1 -0
- package/dist/src/functions/emptyRoom.lua +74 -0
- package/dist/src/functions/enums.d.ts.map +1 -1
- package/dist/src/functions/enums.lua +3 -3
- package/dist/src/functions/gridEntities.lua +2 -2
- package/dist/src/functions/gridIndex.d.ts +10 -0
- package/dist/src/functions/gridIndex.d.ts.map +1 -0
- package/dist/src/functions/gridIndex.lua +32 -0
- package/dist/src/functions/log.d.ts.map +1 -1
- package/dist/src/functions/log.lua +9 -8
- package/dist/src/functions/logEntities.d.ts.map +1 -1
- package/dist/src/functions/logEntities.lua +17 -9
- package/dist/src/functions/pills.lua +4 -4
- package/dist/src/functions/roomShape.d.ts +6 -1
- package/dist/src/functions/roomShape.d.ts.map +1 -1
- package/dist/src/functions/roomShape.lua +3 -0
- package/dist/src/functions/roomShapeWalls.d.ts +20 -0
- package/dist/src/functions/roomShapeWalls.d.ts.map +1 -0
- package/dist/src/functions/roomShapeWalls.lua +285 -0
- package/dist/src/functions/rooms.d.ts +7 -0
- package/dist/src/functions/rooms.d.ts.map +1 -1
- package/dist/src/functions/rooms.lua +16 -5
- package/dist/src/functions/set.d.ts +7 -0
- package/dist/src/functions/set.d.ts.map +1 -1
- package/dist/src/functions/set.lua +10 -0
- package/dist/src/functions/sprites.lua +2 -2
- package/dist/src/functions/trinkets.lua +2 -2
- package/dist/src/functions/utils.d.ts +18 -12
- package/dist/src/functions/utils.d.ts.map +1 -1
- package/dist/src/functions/utils.lua +26 -14
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.lua +24 -0
- package/dist/src/interfaces/Corner.d.ts +8 -0
- package/dist/src/interfaces/Corner.d.ts.map +1 -1
- package/dist/src/objects/roomShapeCorners.d.ts +6 -1
- package/dist/src/objects/roomShapeCorners.d.ts.map +1 -1
- package/dist/src/objects/roomShapeCorners.lua +71 -14
- package/package.json +2 -2
- package/src/features/customStage/backdrop.ts +3 -3
- package/src/features/customStage/versusScreen.ts +2 -2
- package/src/features/deployJSONRoom.ts +8 -98
- package/src/features/extraConsoleCommands/listCommands.ts +2 -2
- package/src/features/firstLast.ts +8 -8
- package/src/features/setHotkey.ts +60 -40
- package/src/functions/array.ts +2 -2
- package/src/functions/cards.ts +2 -2
- package/src/functions/collectibles.ts +2 -2
- package/src/functions/dimensions.ts +2 -2
- package/src/functions/emptyRoom.ts +85 -0
- package/src/functions/enums.ts +4 -3
- package/src/functions/gridEntities.ts +2 -2
- package/src/functions/gridIndex.ts +40 -0
- package/src/functions/log.ts +9 -10
- package/src/functions/logEntities.ts +25 -9
- package/src/functions/pills.ts +4 -4
- package/src/functions/roomShape.ts +6 -1
- package/src/functions/roomShapeWalls.ts +359 -0
- package/src/functions/rooms.ts +22 -3
- package/src/functions/set.ts +12 -0
- package/src/functions/sprites.ts +2 -2
- package/src/functions/trinkets.ts +2 -2
- package/src/functions/utils.ts +20 -14
- package/src/index.ts +3 -0
- package/src/interfaces/Corner.ts +9 -0
- package/src/objects/roomShapeCorners.ts +74 -16
|
@@ -2,7 +2,6 @@ import { Keyboard, ModCallback } from "isaac-typescript-definitions";
|
|
|
2
2
|
import { DefaultMap } from "../classes/DefaultMap";
|
|
3
3
|
import { errorIfFeaturesNotInitialized } from "../featuresInitialized";
|
|
4
4
|
import { isKeyboardPressed } from "../functions/input";
|
|
5
|
-
import { isFunction } from "../functions/types";
|
|
6
5
|
|
|
7
6
|
const FEATURE_NAME = "setHotkey";
|
|
8
7
|
|
|
@@ -61,64 +60,85 @@ function checkIfTriggered(keyboard: Keyboard, triggerFunc: () => void) {
|
|
|
61
60
|
* This can be used to easily set up custom hotkeys to facilitate custom game features or to assist
|
|
62
61
|
* in debugging.
|
|
63
62
|
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
63
|
+
* This is different from the `setHotkey` function in that the keyboard activation key is not
|
|
64
|
+
* hardcoded and is instead the return value of a provided function. This is useful for situations
|
|
65
|
+
* where the key can change (like if end-users can specify a custom hotkey using Mod Config Menu).
|
|
66
|
+
*
|
|
67
|
+
* @param getKeyFunc The function that returns the key that will trigger the hotkey.
|
|
69
68
|
* @param triggerFunc A function containing the arbitrary code that you want to execute when the
|
|
70
69
|
* hotkey is triggered.
|
|
71
70
|
*/
|
|
72
|
-
export function
|
|
73
|
-
|
|
71
|
+
export function setConditionalHotkey(
|
|
72
|
+
getKeyFunc: () => Keyboard | undefined,
|
|
74
73
|
triggerFunc: () => void,
|
|
75
74
|
): void {
|
|
76
75
|
errorIfFeaturesNotInitialized(FEATURE_NAME);
|
|
77
76
|
|
|
78
|
-
if (
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
77
|
+
if (dynamicHotkeyFunctionMap.has(getKeyFunc)) {
|
|
78
|
+
error(
|
|
79
|
+
"Failed to register a hotkey due to a custom hotkey already being defined for the submitted function.",
|
|
80
|
+
);
|
|
81
|
+
}
|
|
84
82
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (staticHotkeyFunctionMap.has(keyboardOrFunc)) {
|
|
88
|
-
error(
|
|
89
|
-
`Failed to register a hotkey due to a hotkey already being defined for key: Keyboard.${Keyboard[keyboardOrFunc]} (${keyboardOrFunc})`,
|
|
90
|
-
);
|
|
91
|
-
}
|
|
83
|
+
dynamicHotkeyFunctionMap.set(getKeyFunc, triggerFunc);
|
|
84
|
+
}
|
|
92
85
|
|
|
93
|
-
|
|
86
|
+
/**
|
|
87
|
+
* Helper function to run arbitrary code when you press and release a specific keyboard key.
|
|
88
|
+
*
|
|
89
|
+
* This can be used to easily set up custom hotkeys to facilitate custom game features or to assist
|
|
90
|
+
* in debugging.
|
|
91
|
+
*
|
|
92
|
+
* @param keyboard The key that you want to trigger the hotkey.
|
|
93
|
+
* @param triggerFunc A function containing the arbitrary code that you want to execute when the
|
|
94
|
+
* hotkey is triggered.
|
|
95
|
+
*/
|
|
96
|
+
export function setHotkey(keyboard: Keyboard, triggerFunc: () => void): void {
|
|
97
|
+
errorIfFeaturesNotInitialized(FEATURE_NAME);
|
|
98
|
+
|
|
99
|
+
if (staticHotkeyFunctionMap.has(keyboard)) {
|
|
100
|
+
error(
|
|
101
|
+
`Failed to register a hotkey due to a hotkey already being defined for: Keyboard.${Keyboard[keyboard]} (${keyboard})`,
|
|
102
|
+
);
|
|
94
103
|
}
|
|
104
|
+
|
|
105
|
+
staticHotkeyFunctionMap.set(keyboard, triggerFunc);
|
|
95
106
|
}
|
|
96
107
|
|
|
97
108
|
/**
|
|
98
|
-
* Helper function to remove a hotkey created with the `
|
|
109
|
+
* Helper function to remove a hotkey created with the `setConditionalHotkey` function.
|
|
99
110
|
*
|
|
100
|
-
* @param
|
|
111
|
+
* @param getKeyFunc Equal to the `getKeyFunc` that you passed when initially registering the
|
|
112
|
+
* hotkey.
|
|
101
113
|
*/
|
|
102
|
-
export function
|
|
103
|
-
|
|
114
|
+
export function unsetConditionalHotkey(
|
|
115
|
+
getKeyFunc: () => Keyboard | undefined,
|
|
104
116
|
): void {
|
|
105
117
|
errorIfFeaturesNotInitialized(FEATURE_NAME);
|
|
106
118
|
|
|
107
|
-
if (
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
119
|
+
if (!dynamicHotkeyFunctionMap.has(getKeyFunc)) {
|
|
120
|
+
error(
|
|
121
|
+
"Failed to unregister a hotkey since there is no existing hotkey defined for the submitted function.",
|
|
122
|
+
);
|
|
123
|
+
}
|
|
113
124
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
if (!staticHotkeyFunctionMap.has(keyboardOrFunc)) {
|
|
117
|
-
error(
|
|
118
|
-
`Failed to unregister a hotkey since there is no existing hotkey defined for key: Keyboard.${Keyboard[keyboardOrFunc]} (${keyboardOrFunc})`,
|
|
119
|
-
);
|
|
120
|
-
}
|
|
125
|
+
dynamicHotkeyFunctionMap.delete(getKeyFunc);
|
|
126
|
+
}
|
|
121
127
|
|
|
122
|
-
|
|
128
|
+
/**
|
|
129
|
+
* Helper function to remove a hotkey created with the `setHotkey` function.
|
|
130
|
+
*
|
|
131
|
+
* @param keyboard Equal to the keyboard value that you passed when initially registering the
|
|
132
|
+
* hotkey.
|
|
133
|
+
*/
|
|
134
|
+
export function unsetHotkey(keyboard: Keyboard): void {
|
|
135
|
+
errorIfFeaturesNotInitialized(FEATURE_NAME);
|
|
136
|
+
|
|
137
|
+
if (!staticHotkeyFunctionMap.has(keyboard)) {
|
|
138
|
+
error(
|
|
139
|
+
`Failed to unregister a hotkey since there is no existing hotkey defined for: Keyboard.${Keyboard[keyboard]} (${keyboard})`,
|
|
140
|
+
);
|
|
123
141
|
}
|
|
142
|
+
|
|
143
|
+
staticHotkeyFunctionMap.delete(keyboard);
|
|
124
144
|
}
|
package/src/functions/array.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getRandomInt } from "./random";
|
|
2
2
|
import { getRandomSeed, isRNG, newRNG } from "./rng";
|
|
3
3
|
import { isNumber, isTable } from "./types";
|
|
4
|
-
import {
|
|
4
|
+
import { eRange } from "./utils";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Helper function for determining if two arrays contain the exact same elements. Note that this
|
|
@@ -310,7 +310,7 @@ export function getArrayCombinations<T>(
|
|
|
310
310
|
* For example, an array of `["Apple", "Banana"]` would return an array of `[0, 1]`.
|
|
311
311
|
*/
|
|
312
312
|
export function getArrayIndexes<T>(array: T[] | readonly T[]): int[] {
|
|
313
|
-
return
|
|
313
|
+
return eRange(array.length);
|
|
314
314
|
}
|
|
315
315
|
|
|
316
316
|
/**
|
package/src/functions/cards.ts
CHANGED
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
import { getEnumValues } from "./enums";
|
|
17
17
|
import { getRandomSeed } from "./rng";
|
|
18
18
|
import { addSetsToSet, getRandomSetElement } from "./set";
|
|
19
|
-
import {
|
|
19
|
+
import { iRange } from "./utils";
|
|
20
20
|
|
|
21
21
|
const ITEM_CONFIG_CARD_TYPE_TO_CARD_TYPE_MAP = new Map<
|
|
22
22
|
ItemConfigCardType,
|
|
@@ -206,7 +206,7 @@ export function getRandomRune(
|
|
|
206
206
|
|
|
207
207
|
/** Helper function to get an array with every valid vanilla card sub-type. */
|
|
208
208
|
export function getVanillaCardTypes(): CardType[] {
|
|
209
|
-
return
|
|
209
|
+
return iRange(FIRST_CARD_TYPE, LAST_VANILLA_CARD_TYPE);
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
/**
|
|
@@ -32,7 +32,7 @@ import { getEntityID } from "./entities";
|
|
|
32
32
|
import { isCollectible } from "./pickupVariants";
|
|
33
33
|
import { getRoomListIndex } from "./roomData";
|
|
34
34
|
import { clearSprite, spriteEquals } from "./sprites";
|
|
35
|
-
import {
|
|
35
|
+
import { iRange } from "./utils";
|
|
36
36
|
|
|
37
37
|
const COLLECTIBLE_ANM2_PATH = "gfx/005.100_collectible.anm2";
|
|
38
38
|
|
|
@@ -400,7 +400,7 @@ export function getCollectibleTags(
|
|
|
400
400
|
* instead.
|
|
401
401
|
*/
|
|
402
402
|
export function getVanillaCollectibleTypeRange(): CollectibleType[] {
|
|
403
|
-
return
|
|
403
|
+
return iRange(FIRST_COLLECTIBLE_TYPE, LAST_VANILLA_COLLECTIBLE_TYPE);
|
|
404
404
|
}
|
|
405
405
|
|
|
406
406
|
/** Returns true if the item type in the item config is equal to `ItemType.ITEM_ACTIVE`. */
|
|
@@ -2,13 +2,13 @@ import { Dimension } from "isaac-typescript-definitions";
|
|
|
2
2
|
import { game } from "../core/cachedClasses";
|
|
3
3
|
import { NUM_DIMENSIONS } from "../core/constants";
|
|
4
4
|
import { getRoomGridIndex } from "./roomData";
|
|
5
|
-
import {
|
|
5
|
+
import { eRange } from "./utils";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Helper function to get an array with every valid `Dimension` (not including `Dimension.CURRENT`).
|
|
9
9
|
*/
|
|
10
10
|
export function getAllDimensions(): Dimension[] {
|
|
11
|
-
return
|
|
11
|
+
return eRange(NUM_DIMENSIONS);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EntityFlag,
|
|
3
|
+
EntityType,
|
|
4
|
+
GridEntityType,
|
|
5
|
+
} from "isaac-typescript-definitions";
|
|
6
|
+
import { game } from "../core/cachedClasses";
|
|
7
|
+
import { getEntities } from "./entities";
|
|
8
|
+
import { getGridEntities, removeGridEntity } from "./gridEntities";
|
|
9
|
+
import { roomUpdateSafe } from "./rooms";
|
|
10
|
+
|
|
11
|
+
const EMPTY_ROOM_BLACKLIST_ENTITY_SET: ReadonlySet<EntityType> = new Set([
|
|
12
|
+
EntityType.PLAYER, // 1
|
|
13
|
+
EntityType.TEAR, // 2
|
|
14
|
+
EntityType.FAMILIAR, // 3
|
|
15
|
+
EntityType.LASER, // 7
|
|
16
|
+
EntityType.KNIFE, // 8
|
|
17
|
+
EntityType.PROJECTILE, // 9
|
|
18
|
+
EntityType.DARK_ESAU, // 866
|
|
19
|
+
]);
|
|
20
|
+
|
|
21
|
+
const EMPTY_ROOM_BLACKLIST_GRID_ENTITY_SET: ReadonlySet<GridEntityType> =
|
|
22
|
+
new Set([
|
|
23
|
+
GridEntityType.WALL, // 15
|
|
24
|
+
GridEntityType.DOOR, // 16
|
|
25
|
+
]);
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Helper function to remove all naturally spawning entities and grid entities from a room. Notably,
|
|
29
|
+
* this will not remove players (1), tears (2), familiars (3), lasers (7), knives (8), projectiles
|
|
30
|
+
* (9), blacklisted NPCs such as Dark Esau, charmed NPCs, friendly NPCs, persistent NPCs, most
|
|
31
|
+
* effects (1000), doors, and walls.
|
|
32
|
+
*/
|
|
33
|
+
export function emptyRoom(): void {
|
|
34
|
+
emptyRoomEntities();
|
|
35
|
+
emptyRoomGridEntities();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* We remove entities in the `POST_NEW_ROOM` callback instead of in the `PRE_ROOM_ENTITY_SPAWN`
|
|
40
|
+
* callback so that they will not re-appear when we re-enter the room.
|
|
41
|
+
*/
|
|
42
|
+
function emptyRoomEntities() {
|
|
43
|
+
const room = game.GetRoom();
|
|
44
|
+
|
|
45
|
+
for (const entity of getEntities()) {
|
|
46
|
+
if (EMPTY_ROOM_BLACKLIST_ENTITY_SET.has(entity.Type)) {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (
|
|
51
|
+
entity.HasEntityFlags(EntityFlag.CHARM) ||
|
|
52
|
+
entity.HasEntityFlags(EntityFlag.FRIENDLY) ||
|
|
53
|
+
entity.HasEntityFlags(EntityFlag.PERSISTENT)
|
|
54
|
+
) {
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
entity.ClearEntityFlags(EntityFlag.APPEAR);
|
|
59
|
+
entity.Remove();
|
|
60
|
+
|
|
61
|
+
// When fire places are removed, they will leave behind a "path" that will prevent future grid
|
|
62
|
+
// entities from being spawned on the same tile. Thus, reset the path for this tile if this is a
|
|
63
|
+
// fire place.
|
|
64
|
+
if (entity.Type === EntityType.FIREPLACE) {
|
|
65
|
+
const gridIndex = room.GetGridIndex(entity.Position);
|
|
66
|
+
room.SetGridPath(gridIndex, 0);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function emptyRoomGridEntities() {
|
|
72
|
+
let removedOneOrMoreGridEntities = false;
|
|
73
|
+
for (const gridEntity of getGridEntities()) {
|
|
74
|
+
const gridEntityType = gridEntity.GetType();
|
|
75
|
+
if (EMPTY_ROOM_BLACKLIST_GRID_ENTITY_SET.has(gridEntityType)) {
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
removeGridEntity(gridEntity, false);
|
|
80
|
+
removedOneOrMoreGridEntities = true;
|
|
81
|
+
}
|
|
82
|
+
if (removedOneOrMoreGridEntities) {
|
|
83
|
+
roomUpdateSafe();
|
|
84
|
+
}
|
|
85
|
+
}
|
package/src/functions/enums.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getRandomArrayElement } from "./array";
|
|
2
2
|
import { getRandomSeed } from "./rng";
|
|
3
3
|
import { isString } from "./types";
|
|
4
|
-
import {
|
|
4
|
+
import { iRange } from "./utils";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* TypeScriptToLua will transpile TypeScript enums to Lua tables that have a double mapping. Thus,
|
|
@@ -165,7 +165,6 @@ export function validateEnumContiguous<T>(
|
|
|
165
165
|
transpiledEnum: T,
|
|
166
166
|
): void {
|
|
167
167
|
const values = getEnumValues(transpiledEnum);
|
|
168
|
-
const valuesSet = new Set(values);
|
|
169
168
|
const lastValue = values[values.length - 1];
|
|
170
169
|
if (lastValue === undefined) {
|
|
171
170
|
error(
|
|
@@ -177,7 +176,9 @@ export function validateEnumContiguous<T>(
|
|
|
177
176
|
"Failed to validate that an enum was contiguous, since the last value was not a number.",
|
|
178
177
|
);
|
|
179
178
|
}
|
|
180
|
-
|
|
179
|
+
|
|
180
|
+
const valuesSet = new Set(values);
|
|
181
|
+
for (const value of iRange(lastValue)) {
|
|
181
182
|
if (!valuesSet.has(value as unknown as T[keyof T])) {
|
|
182
183
|
error(
|
|
183
184
|
`Failed to find a custom enum value of ${value} for: ${transpiledEnumName}`,
|
|
@@ -22,7 +22,7 @@ import { isCircleIntersectingRectangle } from "./math";
|
|
|
22
22
|
import { roomUpdateSafe } from "./rooms";
|
|
23
23
|
import { clearSprite } from "./sprites";
|
|
24
24
|
import { asNumber, isNumber } from "./types";
|
|
25
|
-
import {
|
|
25
|
+
import { eRange } from "./utils";
|
|
26
26
|
import { isVector, vectorEquals } from "./vector";
|
|
27
27
|
|
|
28
28
|
const BREAKABLE_GRID_ENTITY_TYPES_BY_EXPLOSIONS: ReadonlySet<GridEntityType> =
|
|
@@ -87,7 +87,7 @@ export function getAllGridIndexes(): int[] {
|
|
|
87
87
|
const room = game.GetRoom();
|
|
88
88
|
const gridSize = room.GetGridSize();
|
|
89
89
|
|
|
90
|
-
return
|
|
90
|
+
return eRange(gridSize);
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
/**
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { RoomShape } from "isaac-typescript-definitions";
|
|
2
|
+
import { getRoomShapeWidth } from "./roomShape";
|
|
3
|
+
import { iRange } from "./utils";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Helper function to get all of the grid indexes between two grid indexes on either a horizontal or
|
|
7
|
+
* vertical line, inclusive on both ends.
|
|
8
|
+
*
|
|
9
|
+
* This function will throw a run-time error if the two provided grid indexes are not on the same
|
|
10
|
+
* horizontal or vertical line.
|
|
11
|
+
*/
|
|
12
|
+
export function getGridIndexesBetween(
|
|
13
|
+
gridIndex1: int,
|
|
14
|
+
gridIndex2: int,
|
|
15
|
+
roomShape: RoomShape,
|
|
16
|
+
): int[] {
|
|
17
|
+
if (gridIndex1 > gridIndex2) {
|
|
18
|
+
const oldGridIndex1 = gridIndex1;
|
|
19
|
+
const oldGridIndex2 = gridIndex2;
|
|
20
|
+
gridIndex1 = oldGridIndex2;
|
|
21
|
+
gridIndex2 = oldGridIndex1;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const delta = gridIndex2 - gridIndex1;
|
|
25
|
+
const gridWidth = getRoomShapeWidth(roomShape);
|
|
26
|
+
|
|
27
|
+
const isOnHorizontalLine = delta <= gridWidth;
|
|
28
|
+
if (isOnHorizontalLine) {
|
|
29
|
+
return iRange(gridIndex1, gridIndex2);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const isOnVerticalLine = delta % gridWidth === 0;
|
|
33
|
+
if (isOnVerticalLine) {
|
|
34
|
+
return iRange(gridIndex1, gridIndex2, gridWidth);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
error(
|
|
38
|
+
`Failed to get the grid indexes between ${gridIndex1} and ${gridIndex2} for RoomShape.${RoomShape[roomShape]} (${roomShape}) since they are not on the same horizontal or vertical line.`,
|
|
39
|
+
);
|
|
40
|
+
}
|
package/src/functions/log.ts
CHANGED
|
@@ -277,27 +277,26 @@ export function logRoom(): void {
|
|
|
277
277
|
const roomListIndex = getRoomListIndex();
|
|
278
278
|
const roomData = getRoomData();
|
|
279
279
|
|
|
280
|
+
log("Current room information:");
|
|
280
281
|
if (roomData === undefined) {
|
|
281
|
-
log("
|
|
282
|
+
log("- Room data is undefined.");
|
|
282
283
|
} else {
|
|
283
|
-
log(
|
|
284
|
+
log(`- Room stage ID: ${roomData.StageID}`);
|
|
284
285
|
log(
|
|
285
|
-
|
|
286
|
+
`- Type/variant/sub-type: ${roomData.Type}.${roomData.Variant}.${roomData.Subtype}`,
|
|
286
287
|
);
|
|
287
|
-
log(
|
|
288
|
+
log(`- Name: ${roomData.Name}`);
|
|
288
289
|
}
|
|
289
290
|
|
|
290
291
|
const roomGridIndexName = GridRoom[roomGridIndex];
|
|
291
292
|
if (roomGridIndexName === undefined) {
|
|
292
|
-
log(
|
|
293
|
+
log(`- Grid index: ${roomGridIndex}`);
|
|
293
294
|
} else {
|
|
294
|
-
log(
|
|
295
|
-
`Current room grid index: ${roomGridIndex} (GridRoom.${roomGridIndexName})`,
|
|
296
|
-
);
|
|
295
|
+
log(`- Grid index: GridRoom.${roomGridIndexName} (${roomGridIndex})`);
|
|
297
296
|
}
|
|
298
297
|
|
|
299
|
-
log(
|
|
300
|
-
log(
|
|
298
|
+
log(`- List index: ${roomListIndex}`);
|
|
299
|
+
log(`- Boss ID: ${bossID}`);
|
|
301
300
|
}
|
|
302
301
|
|
|
303
302
|
/**
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
|
+
BombVariant,
|
|
2
3
|
EffectVariant,
|
|
3
4
|
EntityType,
|
|
5
|
+
FamiliarVariant,
|
|
4
6
|
GridEntityType,
|
|
7
|
+
KnifeVariant,
|
|
8
|
+
LaserVariant,
|
|
9
|
+
PickupVariant,
|
|
10
|
+
PlayerVariant,
|
|
11
|
+
ProjectileVariant,
|
|
12
|
+
TearVariant,
|
|
5
13
|
} from "isaac-typescript-definitions";
|
|
6
14
|
import { getEntities, getEntityFromPtrHash, getEntityID } from "./entities";
|
|
7
15
|
import { getGridEntities, getGridEntityID } from "./gridEntities";
|
|
@@ -137,27 +145,31 @@ function getEntityLogLine(entity: Entity, num?: int): string {
|
|
|
137
145
|
|
|
138
146
|
const bomb = entity.ToBomb();
|
|
139
147
|
if (bomb !== undefined) {
|
|
140
|
-
msg +=
|
|
148
|
+
msg += ` (bomb - BombVariant.${BombVariant[bomb.Variant]})`;
|
|
141
149
|
}
|
|
142
150
|
|
|
143
151
|
const effect = entity.ToEffect();
|
|
144
152
|
if (effect !== undefined) {
|
|
145
|
-
msg += ` (effect
|
|
153
|
+
msg += ` (effect - EffectVariant.${
|
|
154
|
+
EffectVariant[effect.Variant]
|
|
155
|
+
}) (State: ${effect.State})`;
|
|
146
156
|
}
|
|
147
157
|
|
|
148
158
|
const familiar = entity.ToFamiliar();
|
|
149
159
|
if (familiar !== undefined) {
|
|
150
|
-
msg += ` (familiar
|
|
160
|
+
msg += ` (familiar - FamiliarVariant.${
|
|
161
|
+
FamiliarVariant[familiar.Variant]
|
|
162
|
+
}) (State: ${familiar.State})`;
|
|
151
163
|
}
|
|
152
164
|
|
|
153
165
|
const knife = entity.ToKnife();
|
|
154
166
|
if (knife !== undefined) {
|
|
155
|
-
msg +=
|
|
167
|
+
msg += ` (knife - KnifeVariant.${KnifeVariant[knife.Variant]})`;
|
|
156
168
|
}
|
|
157
169
|
|
|
158
170
|
const laser = entity.ToLaser();
|
|
159
171
|
if (laser !== undefined) {
|
|
160
|
-
msg +=
|
|
172
|
+
msg += ` (laser - LaserVariant.${LaserVariant[laser.Variant]})`;
|
|
161
173
|
}
|
|
162
174
|
|
|
163
175
|
const npc = entity.ToNPC();
|
|
@@ -167,22 +179,26 @@ function getEntityLogLine(entity: Entity, num?: int): string {
|
|
|
167
179
|
|
|
168
180
|
const pickup = entity.ToPickup();
|
|
169
181
|
if (pickup !== undefined) {
|
|
170
|
-
msg += ` (pickup
|
|
182
|
+
msg += ` (pickup - PickupVariant.${
|
|
183
|
+
PickupVariant[pickup.Variant]
|
|
184
|
+
}) (State: ${pickup.State})`;
|
|
171
185
|
}
|
|
172
186
|
|
|
173
187
|
const player = entity.ToPlayer();
|
|
174
188
|
if (player !== undefined) {
|
|
175
|
-
msg +=
|
|
189
|
+
msg += ` (player - PlayerVariant.${PlayerVariant[player.Variant]})`;
|
|
176
190
|
}
|
|
177
191
|
|
|
178
192
|
const projectile = entity.ToProjectile();
|
|
179
193
|
if (projectile !== undefined) {
|
|
180
|
-
msg +=
|
|
194
|
+
msg += ` (projectile - ProjectileVariant.${
|
|
195
|
+
ProjectileVariant[projectile.Variant]
|
|
196
|
+
}))`;
|
|
181
197
|
}
|
|
182
198
|
|
|
183
199
|
const tear = entity.ToTear();
|
|
184
200
|
if (tear !== undefined) {
|
|
185
|
-
msg +=
|
|
201
|
+
msg += ` (tear - TearVariant.${TearVariant[tear.Variant]}))`;
|
|
186
202
|
}
|
|
187
203
|
|
|
188
204
|
msg += "\n";
|
package/src/functions/pills.ts
CHANGED
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
} from "../objects/pillEffectTypes";
|
|
30
30
|
import { getEnumValues } from "./enums";
|
|
31
31
|
import { asNumber, asPillColor } from "./types";
|
|
32
|
-
import {
|
|
32
|
+
import { iRange } from "./utils";
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* Add this to a `PillColor` to get the corresponding giant pill color.
|
|
@@ -71,7 +71,7 @@ export function getHorsePillColor(pillColor: PillColor): PillColor {
|
|
|
71
71
|
|
|
72
72
|
/** Helper function to get an array with every non-gold horse pill color. */
|
|
73
73
|
export function getHorsePillColors(): PillColor[] {
|
|
74
|
-
return
|
|
74
|
+
return iRange(FIRST_HORSE_PILL_COLOR, LAST_HORSE_PILL_COLOR);
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
/**
|
|
@@ -91,7 +91,7 @@ export function getNormalPillColorFromHorse(pillColor: PillColor): PillColor {
|
|
|
91
91
|
|
|
92
92
|
/** Helper function to get an array with every non-gold and non-horse pill color. */
|
|
93
93
|
export function getNormalPillColors(): PillColor[] {
|
|
94
|
-
return
|
|
94
|
+
return iRange(FIRST_PILL_COLOR, LAST_NORMAL_PILL_COLOR);
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
/**
|
|
@@ -172,7 +172,7 @@ export function getPillEffectType(
|
|
|
172
172
|
|
|
173
173
|
/** Helper function to get an array with every vanilla pill effect. */
|
|
174
174
|
export function getVanillaPillEffects(): PillEffect[] {
|
|
175
|
-
return
|
|
175
|
+
return iRange(FIRST_PILL_EFFECT, LAST_VANILLA_PILL_EFFECT);
|
|
176
176
|
}
|
|
177
177
|
|
|
178
178
|
export function isHorsePill(pillColor: PillColor): boolean {
|
|
@@ -60,7 +60,12 @@ export function getRoomShapeCharges(roomShape: RoomShape): int {
|
|
|
60
60
|
return isRoomShapeDoubleCharge(roomShape) ? 2 : 1;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
/**
|
|
63
|
+
/**
|
|
64
|
+
* Helper function to get the corners that exist in the given room shape.
|
|
65
|
+
*
|
|
66
|
+
* Note that these corner locations are not accurate for the Mother Boss Room and the Home closet
|
|
67
|
+
* rooms. (Those rooms have custom shapes.)
|
|
68
|
+
*/
|
|
64
69
|
export function getRoomShapeCorners(roomShape: RoomShape): readonly Corner[] {
|
|
65
70
|
return ROOM_SHAPE_CORNERS[roomShape];
|
|
66
71
|
}
|