isaacscript-common 79.0.0 → 79.1.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.
@@ -110,6 +110,14 @@ export function getRoomShapeWidth(roomShape: RoomShape): int {
110
110
  return ROOM_SHAPE_TO_GRID_WIDTH[roomShape];
111
111
  }
112
112
 
113
+ /**
114
+ * Helper function to determine if the provided room is equal to `RoomShape.1x2` (4) or
115
+ * `RoomShape.2x1` (6).
116
+ */
117
+ export function is2x1RoomShape(roomShape: RoomShape): boolean {
118
+ return roomShape === RoomShape.SHAPE_1x2 || roomShape === RoomShape.SHAPE_2x1;
119
+ }
120
+
113
121
  /**
114
122
  * Helper function to detect if the provided room shape is big. Specifically, this is all 1x2 rooms,
115
123
  * 2x2 rooms, and L rooms.
@@ -118,10 +126,18 @@ export function isBigRoomShape(roomShape: RoomShape): boolean {
118
126
  return BIG_ROOM_SHAPES_SET.has(roomShape);
119
127
  }
120
128
 
129
+ /**
130
+ * Helper function to determine if the provided room is equal to `RoomShape.LTL` (9),
131
+ * `RoomShape.LTR` (10), `RoomShape.LBL` (11), or `RoomShape.LBR` (12).
132
+ */
121
133
  export function isLRoomShape(roomShape: RoomShape): boolean {
122
134
  return L_ROOM_SHAPES_SET.has(roomShape);
123
135
  }
124
136
 
137
+ /**
138
+ * Helper function to determine if the provided room is equal to `RoomShape.IH` (2), `RoomShape.IV`
139
+ * (3), `RoomShape.IIV` (5), or `RoomShape.IIH` (7).
140
+ */
125
141
  export function isNarrowRoom(roomShape: RoomShape): boolean {
126
142
  return NARROW_ROOM_SHAPES_SET.has(roomShape);
127
143
  }
@@ -3,6 +3,7 @@ import type {
3
3
  BossID,
4
4
  ItemPoolType,
5
5
  MinibossID,
6
+ RoomShape,
6
7
  } from "isaac-typescript-definitions";
7
8
  import {
8
9
  AngelRoomSubType,
@@ -15,7 +16,6 @@ import {
15
16
  HomeRoomSubType,
16
17
  ProjectileFlag,
17
18
  RoomDescriptorFlag,
18
- RoomShape,
19
19
  RoomType,
20
20
  SoundEffect,
21
21
  StageID,
@@ -46,7 +46,7 @@ import {
46
46
  getRoomDescriptorReadOnly,
47
47
  getRoomGridIndex,
48
48
  } from "./roomData";
49
- import { isBigRoomShape, isLRoomShape } from "./roomShape";
49
+ import { is2x1RoomShape, isBigRoomShape, isLRoomShape } from "./roomShape";
50
50
  import { reloadRoom } from "./roomTransition";
51
51
  import { getGotoCommand } from "./stage";
52
52
  import { asNumber } from "./types";
@@ -191,7 +191,7 @@ export function getRoomTypeName(roomType: RoomType): string {
191
191
  * Helper function to get the room descriptor for every room on the level. This includes off-grid
192
192
  * rooms, such as the Devil Room.
193
193
  *
194
- * Room descriptors without any data are assumed to be non-existent and are not included.
194
+ * Room without any data are assumed to be non-existent and are not included.
195
195
  *
196
196
  * - If you want just the rooms inside of the grid, use the `getRoomsInsideGrid` helper function.
197
197
  * - If you want just the rooms outside of the grid, use the `getRoomsOutsideGrid` helper function.
@@ -413,8 +413,8 @@ export function inDoubleTrouble(): boolean {
413
413
 
414
414
  /** Helper function to determine if the current room index is equal to `GridRoom.GENESIS`. */
415
415
  export function inGenesisRoom(): boolean {
416
- const roomDescriptor = getRoomDescriptorReadOnly();
417
- return isGenesisRoom(roomDescriptor);
416
+ const roomGridIndex = getRoomGridIndex();
417
+ return isGenesisRoom(roomGridIndex);
418
418
  }
419
419
 
420
420
  /**
@@ -436,8 +436,8 @@ export function inLRoom(): boolean {
436
436
 
437
437
  /** Helper function to determine if the current room index is equal to `GridRoom.MEGA_SATAN`. */
438
438
  export function inMegaSatanRoom(): boolean {
439
- const roomDescriptor = getRoomDescriptorReadOnly();
440
- return isMegaSatanRoom(roomDescriptor);
439
+ const roomGridIndex = getRoomGridIndex();
440
+ return isMegaSatanRoom(roomGridIndex);
441
441
  }
442
442
 
443
443
  /**
@@ -492,8 +492,8 @@ export function inRoomType(...roomTypes: RoomType[]): boolean {
492
492
  * floor.
493
493
  */
494
494
  export function inSecretExit(): boolean {
495
- const roomDescriptor = getRoomDescriptorReadOnly();
496
- return isSecretExit(roomDescriptor);
495
+ const roomGridIndex = getRoomGridIndex();
496
+ return isSecretExit(roomGridIndex);
497
497
  }
498
498
 
499
499
  /**
@@ -505,8 +505,8 @@ export function inSecretExit(): boolean {
505
505
  * the only way to detect them is by using the grid index.
506
506
  */
507
507
  export function inSecretShop(): boolean {
508
- const roomDescriptor = getRoomDescriptorReadOnly();
509
- return isSecretShop(roomDescriptor);
508
+ const roomGridIndex = getRoomGridIndex();
509
+ return isSecretShop(roomGridIndex);
510
510
  }
511
511
 
512
512
  /**
@@ -526,10 +526,7 @@ export function inStartingRoom(): boolean {
526
526
  * Helper function to determine if the provided room is equal to `RoomShape.1x2` or `RoomShape.2x1`.
527
527
  */
528
528
  export function is2x1Room(roomData: RoomConfig): boolean {
529
- return (
530
- roomData.Shape === RoomShape.SHAPE_1x2 ||
531
- roomData.Shape === RoomShape.SHAPE_2x1
532
- );
529
+ return is2x1RoomShape(roomData.Shape);
533
530
  }
534
531
 
535
532
  /**
@@ -732,8 +729,8 @@ export function isDoubleTrouble(roomData: RoomConfig): boolean {
732
729
  /**
733
730
  * Helper function to determine if the index of the provided room is equal to `GridRoom.GENESIS`.
734
731
  */
735
- export function isGenesisRoom(roomDescriptor: RoomDescriptor): boolean {
736
- return roomDescriptor.GridIndex === asNumber(GridRoom.GENESIS);
732
+ export function isGenesisRoom(roomGridIndex: int): boolean {
733
+ return roomGridIndex === asNumber(GridRoom.GENESIS);
737
734
  }
738
735
 
739
736
  /**
@@ -758,8 +755,8 @@ export function isLRoom(roomData: RoomConfig): boolean {
758
755
  /**
759
756
  * Helper function to determine if the index of the provided room is equal to `GridRoom.MEGA_SATAN`.
760
757
  */
761
- export function isMegaSatanRoom(roomDescriptor: RoomDescriptor): boolean {
762
- return roomDescriptor.GridIndex === asNumber(GridRoom.MEGA_SATAN);
758
+ export function isMegaSatanRoom(roomGridIndex: int): boolean {
759
+ return roomGridIndex === asNumber(GridRoom.MEGA_SATAN);
763
760
  }
764
761
 
765
762
  /**
@@ -868,8 +865,8 @@ export function isRoomType(
868
865
  * Helper function for checking if the provided room is a secret exit that leads to a Repentance
869
866
  * floor.
870
867
  */
871
- export function isSecretExit(roomDescriptor: RoomDescriptor): boolean {
872
- return roomDescriptor.GridIndex === asNumber(GridRoom.SECRET_EXIT);
868
+ export function isSecretExit(roomGridIndex: int): boolean {
869
+ return roomGridIndex === asNumber(GridRoom.SECRET_EXIT);
873
870
  }
874
871
 
875
872
  /**
@@ -888,8 +885,8 @@ export function isSecretRoomType(roomType: RoomType): boolean {
888
885
  * words, they will have the same room type, room variant, and room sub-type of a normal shop. Thus,
889
886
  * the only way to detect them is by using the grid index.
890
887
  */
891
- export function isSecretShop(roomDescriptor: RoomDescriptor): boolean {
892
- return roomDescriptor.GridIndex === asNumber(GridRoom.SECRET_SHOP);
888
+ export function isSecretShop(roomGridIndex: int): boolean {
889
+ return roomGridIndex === asNumber(GridRoom.SECRET_SHOP);
893
890
  }
894
891
 
895
892
  /**
@@ -603,7 +603,7 @@ export interface AddCallbackParametersCustom {
603
603
  pickup: EntityPickup,
604
604
  variant: PickupVariant,
605
605
  subType: int,
606
- ) => [PickupVariant, int] | undefined,
606
+ ) => [pickupVariant: PickupVariant, subType: int] | undefined,
607
607
  pickupVariant?: PickupVariant,
608
608
  subType?: int,
609
609
  ];