isaacscript-common 6.19.0 → 6.20.2

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.
Files changed (51) hide show
  1. package/dist/constants.d.ts +5 -0
  2. package/dist/constants.d.ts.map +1 -1
  3. package/dist/constants.lua +4 -0
  4. package/dist/features/customStage/exports.d.ts +6 -1
  5. package/dist/features/customStage/exports.d.ts.map +1 -1
  6. package/dist/features/customStage/exports.lua +14 -11
  7. package/dist/features/customTrapdoor/blackSprite.d.ts.map +1 -1
  8. package/dist/features/customTrapdoor/blackSprite.lua +1 -0
  9. package/dist/features/customTrapdoor/init.d.ts.map +1 -1
  10. package/dist/features/customTrapdoor/init.lua +10 -2
  11. package/dist/features/extraConsoleCommands/commandsSubroutines.d.ts.map +1 -1
  12. package/dist/features/extraConsoleCommands/commandsSubroutines.lua +2 -1
  13. package/dist/features/extraConsoleCommands/listCommands.d.ts.map +1 -1
  14. package/dist/features/extraConsoleCommands/listCommands.lua +2 -1
  15. package/dist/functions/curses.d.ts +3 -0
  16. package/dist/functions/curses.d.ts.map +1 -0
  17. package/dist/functions/curses.lua +11 -0
  18. package/dist/functions/dimensions.d.ts +12 -0
  19. package/dist/functions/dimensions.d.ts.map +1 -0
  20. package/dist/functions/dimensions.lua +35 -0
  21. package/dist/functions/level.d.ts.map +1 -1
  22. package/dist/functions/level.lua +8 -7
  23. package/dist/functions/levelGrid.d.ts +155 -0
  24. package/dist/functions/levelGrid.d.ts.map +1 -0
  25. package/dist/functions/levelGrid.lua +349 -0
  26. package/dist/functions/roomData.d.ts +6 -1
  27. package/dist/functions/roomData.d.ts.map +1 -1
  28. package/dist/functions/roomData.lua +6 -0
  29. package/dist/functions/roomGrid.d.ts +8 -0
  30. package/dist/functions/roomGrid.d.ts.map +1 -1
  31. package/dist/functions/rooms.d.ts +67 -68
  32. package/dist/functions/rooms.d.ts.map +1 -1
  33. package/dist/functions/rooms.lua +176 -203
  34. package/dist/index.d.ts +3 -0
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.lua +24 -0
  37. package/package.json +2 -2
  38. package/src/constants.ts +8 -0
  39. package/src/features/customStage/exports.ts +25 -14
  40. package/src/features/customTrapdoor/blackSprite.ts +1 -0
  41. package/src/features/customTrapdoor/init.ts +7 -3
  42. package/src/features/extraConsoleCommands/commandsSubroutines.ts +2 -1
  43. package/src/features/extraConsoleCommands/listCommands.ts +2 -1
  44. package/src/functions/curses.ts +9 -0
  45. package/src/functions/dimensions.ts +41 -0
  46. package/src/functions/level.ts +7 -10
  47. package/src/functions/levelGrid.ts +468 -0
  48. package/src/functions/roomData.ts +13 -1
  49. package/src/functions/roomGrid.ts +9 -0
  50. package/src/functions/rooms.ts +161 -219
  51. package/src/index.ts +3 -0
@@ -0,0 +1,468 @@
1
+ /**
2
+ * These functions have to do with the room grid index for the level (i.e. the position that the
3
+ * room is on the grid that represents the map for the level).
4
+ *
5
+ * For functions having to do with the grid index inside of the room, see the "Room Grid" functions.
6
+ *
7
+ * @module
8
+ */
9
+
10
+ import {
11
+ DisplayFlag,
12
+ DoorSlot,
13
+ DownpourRoomSubType,
14
+ LevelStateFlag,
15
+ MinesRoomSubType,
16
+ RoomDescriptorFlag,
17
+ RoomShape,
18
+ RoomType,
19
+ } from "isaac-typescript-definitions";
20
+ import { game } from "../cachedClasses";
21
+ import {
22
+ ALL_DISPLAY_FLAGS,
23
+ LEVEL_GRID_ROW_WIDTH,
24
+ MAX_LEVEL_GRID_INDEX,
25
+ } from "../constants";
26
+ import { ROOM_SHAPE_TO_DOOR_SLOTS_TO_GRID_INDEX_DELTA } from "../objects/roomShapeToDoorSlotsToGridIndexDelta";
27
+ import { getRandomArrayElement } from "./array";
28
+ import { doorSlotToDoorSlotFlag } from "./doors";
29
+ import { addFlag, hasFlag, removeFlag } from "./flag";
30
+ import { getRandomSeed } from "./rng";
31
+ import {
32
+ getRoomAllowedDoors,
33
+ getRoomData,
34
+ getRoomDescriptor,
35
+ getRoomGridIndex,
36
+ getRoomShape,
37
+ } from "./roomData";
38
+ import { getRooms, getRoomsInGrid } from "./rooms";
39
+ import { getGridIndexDelta } from "./roomShape";
40
+
41
+ const LEFT = -1;
42
+ const UP = -LEVEL_GRID_ROW_WIDTH;
43
+ const RIGHT = 1;
44
+ const DOWN = LEVEL_GRID_ROW_WIDTH;
45
+
46
+ const ADJACENT_ROOM_GRID_INDEX_DELTAS: readonly int[] = [LEFT, UP, RIGHT, DOWN];
47
+
48
+ /**
49
+ * Helper function to get the room grid indexes that are adjacent to a given room grid index.
50
+ *
51
+ * Adjacent room grid indexes that are outside of the grid will not be included in the returned
52
+ * array.
53
+ *
54
+ * If a room grid index is provided that is outside of the grid, then an empty array will be
55
+ * returned.
56
+ *
57
+ * Note that this function does not take the shape of the room into account; it only looks at a
58
+ * single room grid index.
59
+ *
60
+ * @param roomGridIndex Optional. Default is the current room index.
61
+ */
62
+ export function getAdjacentRoomGridIndexes(roomGridIndex?: int): int[] {
63
+ const roomGridIndexToUse =
64
+ roomGridIndex === undefined ? getRoomGridIndex() : roomGridIndex;
65
+
66
+ if (!isRoomGridIndexInBounds(roomGridIndexToUse)) {
67
+ return [];
68
+ }
69
+
70
+ const adjacentRoomGridIndexes = ADJACENT_ROOM_GRID_INDEX_DELTAS.map(
71
+ (delta) => roomGridIndexToUse + delta,
72
+ );
73
+
74
+ return adjacentRoomGridIndexes.filter((adjacentRoomGridIndex) =>
75
+ isRoomGridIndexInBounds(adjacentRoomGridIndex),
76
+ );
77
+ }
78
+
79
+ /** Helper function to get the room safe grid index for every room on the entire floor. */
80
+ export function getAllRoomGridIndexes(): int[] {
81
+ const rooms = getRooms();
82
+ return rooms.map((roomDescriptor) => roomDescriptor.SafeGridIndex);
83
+ }
84
+
85
+ /**
86
+ * Helper function to pick a random valid spot on the floor to insert a brand new room. Note that
87
+ * some floors will not have any valid spots. If this is the case, this function will return
88
+ * undefined.
89
+ *
90
+ * @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
91
+ * `RNG.Next` method will be called. Default is `getRandomSeed()`.
92
+ * @returns Either a tuple of adjacent room grid index, `DoorSlot`, and new room grid index, or
93
+ * undefined.
94
+ */
95
+ export function getNewRoomCandidate(
96
+ seedOrRNG: Seed | RNG = getRandomSeed(),
97
+ ):
98
+ | [adjacentRoomGridIndex: int, doorSlot: DoorSlot, newRoomGridIndex: int]
99
+ | undefined {
100
+ const newRoomCandidatesForLevel = getNewRoomCandidatesForLevel();
101
+ if (newRoomCandidatesForLevel.length === 0) {
102
+ return undefined;
103
+ }
104
+
105
+ return getRandomArrayElement(newRoomCandidatesForLevel, seedOrRNG);
106
+ }
107
+
108
+ /**
109
+ * Helper function to iterate through the possible doors for a room and see if any of them would be
110
+ * a valid spot to insert a brand new room on the floor.
111
+ *
112
+ * @param roomGridIndex Optional. Default is the current room index.
113
+ * @returns A array of tuples of `DoorSlot` and room grid index.
114
+ */
115
+ export function getNewRoomCandidatesBesideRoom(
116
+ roomGridIndex?: int,
117
+ ): Array<[doorSlot: DoorSlot, roomGridIndex: int]> {
118
+ const roomDescriptor = getRoomDescriptor(roomGridIndex);
119
+
120
+ if (!isRoomGridIndexInBounds(roomDescriptor.SafeGridIndex)) {
121
+ return [];
122
+ }
123
+
124
+ const roomData = roomDescriptor.Data;
125
+ if (roomData === undefined) {
126
+ return [];
127
+ }
128
+
129
+ const doorSlotToRoomGridIndexes = getRoomShapeNeighborGridIndexes(
130
+ roomDescriptor.SafeGridIndex,
131
+ roomData.Shape,
132
+ );
133
+
134
+ const roomCandidates: Array<[DoorSlot, int]> = [];
135
+
136
+ for (const [
137
+ doorSlot,
138
+ neighborRoomGridIndex,
139
+ ] of doorSlotToRoomGridIndexes.entries()) {
140
+ // The "getRoomShapeNeighborGridIndexes" returns grid indexes for every possible door, but the
141
+ // real room we are examining will only have a subset of these doors. Thus, we have to exclude
142
+ // neighbor grid indexes where it would not be possible to place a door.
143
+ const doorSlotFlag = doorSlotToDoorSlotFlag(doorSlot);
144
+ if (!hasFlag(roomData.Doors, doorSlotFlag)) {
145
+ continue;
146
+ }
147
+
148
+ // If the neighboring room already exists, then it is not a possible candidate for a new room.
149
+ if (roomExists(neighborRoomGridIndex)) {
150
+ continue;
151
+ }
152
+
153
+ // Check to see if hypothetically creating a room at the given room grid index would be a dead
154
+ // end. In other words, if we created the room, we would only want it to connect to one other
155
+ // room (this one).
156
+ if (!isDeadEnd(neighborRoomGridIndex)) {
157
+ continue;
158
+ }
159
+
160
+ roomCandidates.push([doorSlot, neighborRoomGridIndex]);
161
+ }
162
+
163
+ return roomCandidates;
164
+ }
165
+
166
+ /**
167
+ * Helper function to search through all of the rooms on the floor for a spot to insert a brand new
168
+ * room.
169
+ *
170
+ * @returns A array of tuples of adjacent room grid index, `DoorSlot`, and new room grid index.
171
+ */
172
+ export function getNewRoomCandidatesForLevel(): Array<
173
+ [adjacentRoomGridIndex: int, doorSlot: DoorSlot, newRoomGridIndex: int]
174
+ > {
175
+ const rooms = getRoomsInGrid();
176
+ const normalRooms = rooms.filter(
177
+ (room) =>
178
+ room.Data !== undefined &&
179
+ room.Data.Type === RoomType.DEFAULT &&
180
+ room.Data.Subtype !== (DownpourRoomSubType.MIRROR as int) &&
181
+ room.Data.Subtype !== (MinesRoomSubType.MINESHAFT_ENTRANCE as int),
182
+ );
183
+
184
+ const newRoomCandidates: Array<[int, DoorSlot, int]> = [];
185
+
186
+ for (const room of normalRooms) {
187
+ const newRoomCandidatesBesideRoom = getNewRoomCandidatesBesideRoom(
188
+ room.SafeGridIndex,
189
+ );
190
+ for (const [doorSlot, newRoomGridIndex] of newRoomCandidatesBesideRoom) {
191
+ newRoomCandidates.push([room.SafeGridIndex, doorSlot, newRoomGridIndex]);
192
+ }
193
+ }
194
+
195
+ return newRoomCandidates;
196
+ }
197
+
198
+ /**
199
+ * Helper function to get an array of all of the safe grid indexes for rooms that match the
200
+ * specified room type.
201
+ *
202
+ * This function only searches through rooms in the current dimension.
203
+ *
204
+ * This function is variadic, meaning that you can specify N arguments to get the combined grid
205
+ * indexes for N room types.
206
+ */
207
+ export function getRoomGridIndexesForType(...roomTypes: RoomType[]): int[] {
208
+ const roomTypesSet = new Set<RoomType>([...roomTypes]);
209
+
210
+ const rooms = getRoomsInGrid();
211
+ const matchingRooms = rooms.filter(
212
+ (roomDescriptor) =>
213
+ roomDescriptor.Data !== undefined &&
214
+ roomTypesSet.has(roomDescriptor.Data.Type),
215
+ );
216
+
217
+ return matchingRooms.map((roomDescriptor) => roomDescriptor.SafeGridIndex);
218
+ }
219
+
220
+ /**
221
+ * Helper function to get the grid indexes of all the rooms connected to the given room index,
222
+ * taking the shape of the room into account. (This will only include rooms with valid data.)
223
+ *
224
+ * Returns an empty map if the provided room grid index is out of bounds or has no associated room
225
+ * data.
226
+ *
227
+ * @param roomGridIndex Optional. Default is the current room index.
228
+ * @returns A map of `DoorSlot` to the corresponding room grid index.
229
+ */
230
+ export function getRoomNeighbors(roomGridIndex?: int): Map<DoorSlot, int> {
231
+ const roomDescriptor = getRoomDescriptor(roomGridIndex);
232
+
233
+ if (!isRoomGridIndexInBounds(roomDescriptor.SafeGridIndex)) {
234
+ return new Map();
235
+ }
236
+
237
+ const roomData = roomDescriptor.Data;
238
+ if (roomData === undefined) {
239
+ return new Map();
240
+ }
241
+
242
+ const doorSlotToRoomGridIndexes = getRoomShapeNeighborGridIndexes(
243
+ roomDescriptor.SafeGridIndex,
244
+ roomData.Shape,
245
+ );
246
+
247
+ // The "getRoomShapeNeighborGridIndexes" returns grid indexes for every possible door, but the
248
+ // real room we are examining will only have a subset of these doors. However, we do not have to
249
+ // worry about filtering the map, since we perform a room existence check below.
250
+ const roomNeighbors = new Map<DoorSlot, int>();
251
+ for (const [
252
+ doorSlot,
253
+ neighborRoomGridIndex,
254
+ ] of doorSlotToRoomGridIndexes.entries()) {
255
+ if (roomExists(neighborRoomGridIndex)) {
256
+ roomNeighbors.set(doorSlot, neighborRoomGridIndex);
257
+ }
258
+ }
259
+
260
+ return roomNeighbors;
261
+ }
262
+
263
+ /**
264
+ * Helper function to get the room grid index delta that each hypothetical door in a given room
265
+ * shape would go to.
266
+ *
267
+ * This is used by the `getRoomShapeNeighborGridIndexes` function.
268
+ *
269
+ * @returns A map of `DoorSlot` to the corresponding room grid index delta.
270
+ */
271
+ export function getRoomShapeNeighborGridIndexDeltas(
272
+ roomShape: RoomShape,
273
+ ): Map<DoorSlot, int> {
274
+ return ROOM_SHAPE_TO_DOOR_SLOTS_TO_GRID_INDEX_DELTA[roomShape];
275
+ }
276
+
277
+ /**
278
+ * Helper function to get the room grid index that each hypothetical door in a given room shape
279
+ * would go to. (This will not include room grid indexes that are outside of the grid.)
280
+ *
281
+ * @param safeRoomGridIndex This must be the room safe grid index (i.e. the top-left room grid index
282
+ * for the respective room).
283
+ * @param roomShape The shape of the room.
284
+ * @returns A map of `DoorSlot` to the corresponding room grid index.
285
+ */
286
+ export function getRoomShapeNeighborGridIndexes(
287
+ safeRoomGridIndex: int,
288
+ roomShape: RoomShape,
289
+ ): Map<DoorSlot, int> {
290
+ const roomShapeNeighborGridIndexDeltas =
291
+ getRoomShapeNeighborGridIndexDeltas(roomShape);
292
+
293
+ const neighborGridIndexes = new Map<DoorSlot, int>();
294
+ for (const [doorSlot, delta] of roomShapeNeighborGridIndexDeltas.entries()) {
295
+ const roomGridIndex = safeRoomGridIndex + delta;
296
+ if (isRoomGridIndexInBounds(roomGridIndex)) {
297
+ neighborGridIndexes.set(doorSlot, roomGridIndex);
298
+ }
299
+ }
300
+
301
+ return neighborGridIndexes;
302
+ }
303
+
304
+ /**
305
+ * Helper function to check if the given room grid index is a dead end. Specifically, this is
306
+ * defined as having only one adjacent room that exists.
307
+ *
308
+ * Note that this function does not take the shape of the room into account; it only looks at a
309
+ * single room grid index.
310
+ *
311
+ * This function does not care if the given room grid index actually exists, so you can use it to
312
+ * check if a hypothetical room would be a dead end.
313
+ *
314
+ * @param roomGridIndex Optional. Default is the current room index.
315
+ */
316
+ export function isDeadEnd(roomGridIndex?: int): boolean {
317
+ const adjacentRoomGridIndexes = getAdjacentRoomGridIndexes(roomGridIndex);
318
+ const adjacentRoomData = adjacentRoomGridIndexes.map(
319
+ (adjacentRoomGridIndex) => getRoomData(adjacentRoomGridIndex),
320
+ );
321
+ const existingRoomData = adjacentRoomData.filter(
322
+ (data): data is RoomConfig => data !== undefined,
323
+ );
324
+
325
+ return existingRoomData.length === 1;
326
+ }
327
+
328
+ export function isDoorSlotValidAtGridIndex(
329
+ doorSlot: DoorSlot,
330
+ roomGridIndex: int,
331
+ ): boolean {
332
+ const allowedDoors = getRoomAllowedDoors(roomGridIndex);
333
+ return allowedDoors.has(doorSlot);
334
+ }
335
+
336
+ export function isDoorSlotValidAtGridIndexForRedRoom(
337
+ doorSlot: DoorSlot,
338
+ roomGridIndex: int,
339
+ ): boolean {
340
+ const doorSlotValidAtGridIndex = isDoorSlotValidAtGridIndex(
341
+ doorSlot,
342
+ roomGridIndex,
343
+ );
344
+ if (!doorSlotValidAtGridIndex) {
345
+ return false;
346
+ }
347
+
348
+ const roomShape = getRoomShape(roomGridIndex);
349
+ if (roomShape === undefined) {
350
+ return false;
351
+ }
352
+
353
+ const delta = getGridIndexDelta(roomShape, doorSlot);
354
+ if (delta === undefined) {
355
+ return false;
356
+ }
357
+
358
+ const redRoomGridIndex = roomGridIndex + delta;
359
+ return (
360
+ !roomExists(redRoomGridIndex) && isRoomGridIndexInBounds(redRoomGridIndex)
361
+ );
362
+ }
363
+
364
+ /**
365
+ * Helper function to detect if the provided room was created by the Red Key item. Under the hood,
366
+ * this checks for the `RoomDescriptorFlag.FLAG_RED_ROOM` flag.
367
+ *
368
+ * @param roomGridIndex Optional. Default is the current room index.
369
+ */
370
+ export function isRedKeyRoom(roomGridIndex?: int): boolean {
371
+ const roomDescriptor = getRoomDescriptor(roomGridIndex);
372
+ return hasFlag(roomDescriptor.Flags, RoomDescriptorFlag.RED_ROOM);
373
+ }
374
+
375
+ /**
376
+ * Helper function to determine if a given room grid index is inside of the normal 13x13 level grid.
377
+ *
378
+ * For example, Devil Rooms and the Mega Satan room are not considered to be inside the grid.
379
+ */
380
+ export function isRoomGridIndexInBounds(roomGridIndex: int): boolean {
381
+ return roomGridIndex >= 0 && roomGridIndex <= MAX_LEVEL_GRID_INDEX;
382
+ }
383
+
384
+ /**
385
+ * Helper function to generate a new room on the floor at a valid dead end attached to a normal
386
+ * room.
387
+ *
388
+ * Under the hood, this function uses the `Level.MakeRedRoomDoor` method to create the room.
389
+ *
390
+ * The newly created room will have data corresponding to the game's randomly generated red room. If
391
+ * you want to modify this, use the `setRoomData` helper function.
392
+ *
393
+ * @returns The room grid index of the new room or undefined if the floor had no valid dead ends to
394
+ * place a room.
395
+ */
396
+ export function newRoom(): int | undefined {
397
+ const newRoomCandidate = getNewRoomCandidate();
398
+ if (newRoomCandidate === undefined) {
399
+ return undefined;
400
+ }
401
+ const [adjacentRoomGridIndex, doorSlot, newRoomGridIndex] = newRoomCandidate;
402
+
403
+ const level = game.GetLevel();
404
+ level.MakeRedRoomDoor(adjacentRoomGridIndex, doorSlot);
405
+
406
+ // By default, the room will be a "red room" and have a red graphical tint, so we want to make it
407
+ // a normal room.
408
+ const roomDescriptor = getRoomDescriptor(newRoomGridIndex);
409
+ roomDescriptor.Flags = removeFlag(
410
+ roomDescriptor.Flags,
411
+ RoomDescriptorFlag.RED_ROOM,
412
+ );
413
+
414
+ // By default, the new room will not appear on the map, even if the player has The Mind. Thus, we
415
+ // must manually alter the `DisplayFlags` of the room descriptor.
416
+ const roomData = roomDescriptor.Data;
417
+ if (roomData !== undefined) {
418
+ const hasFullMap = level.GetStateFlag(LevelStateFlag.FULL_MAP_EFFECT);
419
+ const hasCompass = level.GetStateFlag(LevelStateFlag.COMPASS_EFFECT);
420
+ const hasBlueMap = level.GetStateFlag(LevelStateFlag.BLUE_MAP_EFFECT);
421
+ const roomType = roomData.Type;
422
+ const isSecretRoom =
423
+ roomType === RoomType.SECRET || roomType === RoomType.SUPER_SECRET;
424
+
425
+ if (hasFullMap) {
426
+ roomDescriptor.DisplayFlags = ALL_DISPLAY_FLAGS;
427
+ } else if (!isSecretRoom && hasCompass) {
428
+ roomDescriptor.DisplayFlags = addFlag(
429
+ DisplayFlag.VISIBLE,
430
+ DisplayFlag.SHOW_ICON,
431
+ );
432
+ } else if (isSecretRoom && hasBlueMap) {
433
+ roomDescriptor.DisplayFlags = addFlag(
434
+ DisplayFlag.VISIBLE,
435
+ DisplayFlag.SHOW_ICON,
436
+ );
437
+ }
438
+ }
439
+
440
+ return newRoomGridIndex;
441
+ }
442
+
443
+ /**
444
+ * Helper function to check if a room exists at the given room grid index. (A room will exist if it
445
+ * has non-undefined data in the room descriptor.)
446
+ */
447
+ export function roomExists(roomGridIndex: int): boolean {
448
+ const roomData = getRoomData(roomGridIndex);
449
+ return roomData !== undefined;
450
+ }
451
+
452
+ /**
453
+ * Helper function to get the coordinates of a given grid index. The floor is represented by a 13x13
454
+ * grid.
455
+ *
456
+ * - Since the starting room is in the center, the starting room grid index of 84 is equal to
457
+ * coordinates of (6, 6).
458
+ * - The top-left grid index of 0 is equal to coordinates of: (12, 0)
459
+ * - The top-right grid index of 12 is equal to coordinates of: (0, 0)
460
+ * - The bottom-left grid index of 156 is equal to coordinates of: (0, 12)
461
+ * - The bottom-right grid index of 168 is equal to coordinates of: (12, 12)
462
+ */
463
+ export function roomGridIndexToXY(roomGridIndex: int): [x: int, y: int] {
464
+ const x = roomGridIndex % LEVEL_GRID_ROW_WIDTH;
465
+ const y = Math.floor(roomGridIndex / LEVEL_GRID_ROW_WIDTH);
466
+
467
+ return [x, y];
468
+ }
@@ -62,7 +62,7 @@ export function getRoomDescriptor(roomGridIndex?: int): RoomDescriptor {
62
62
  * Alias for the `Level.GetCurrentRoomDesc` method. Use this to make it more clear what type of
63
63
  * `RoomDescriptor` object that you are retrieving.
64
64
  */
65
- export function getRoomDescriptorReadOnly(): ReadonlyRoomDescriptor {
65
+ export function getRoomDescriptorReadOnly(): Readonly<RoomDescriptor> {
66
66
  const level = game.GetLevel();
67
67
  return level.GetCurrentRoomDesc();
68
68
  }
@@ -198,3 +198,15 @@ export function getRoomVisitedCount(roomGridIndex?: int): int {
198
198
  const roomDescriptor = getRoomDescriptor(roomGridIndex);
199
199
  return roomDescriptor.VisitedCount;
200
200
  }
201
+
202
+ /**
203
+ * Helper function to set the data for a given room. This will change the room type, contents, and
204
+ * so on.
205
+ */
206
+ export function setRoomData(
207
+ roomGridIndex: int,
208
+ roomData: Readonly<RoomConfig>,
209
+ ): void {
210
+ const roomDescriptor = getRoomDescriptor(roomGridIndex);
211
+ roomDescriptor.Data = roomData;
212
+ }
@@ -1,3 +1,12 @@
1
+ /**
2
+ * These functions have to do with the grid index inside of a room (i.e. the grid index that grid
3
+ * entities use).
4
+ *
5
+ * For functions having to do with the room grid index of the level, see the "Level Grid" functions.
6
+ *
7
+ * @module
8
+ */
9
+
1
10
  import { RoomShape } from "isaac-typescript-definitions";
2
11
  import { L_ROOM_SHAPE_TO_RECTANGLES } from "../objects/LRoomShapeToRectangles";
3
12
  import { inRectangle } from "./math";