isaacscript-common 30.12.11 → 31.0.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.
Files changed (31) hide show
  1. package/dist/index.rollup.d.ts +141 -20
  2. package/dist/isaacscript-common.lua +157 -111
  3. package/dist/src/classes/features/other/ItemPoolDetection.lua +4 -2
  4. package/dist/src/classes/features/other/customStages/backdrop.lua +3 -3
  5. package/dist/src/functions/hex.lua +13 -7
  6. package/dist/src/functions/levelGrid.d.ts +22 -13
  7. package/dist/src/functions/levelGrid.d.ts.map +1 -1
  8. package/dist/src/functions/levelGrid.lua +46 -23
  9. package/dist/src/functions/logMisc.d.ts.map +1 -1
  10. package/dist/src/functions/logMisc.lua +3 -7
  11. package/dist/src/functions/roomData.d.ts +1 -5
  12. package/dist/src/functions/roomData.d.ts.map +1 -1
  13. package/dist/src/functions/roomGrid.lua +6 -6
  14. package/dist/src/functions/roomShape.d.ts +1 -1
  15. package/dist/src/functions/roomShape.d.ts.map +1 -1
  16. package/dist/src/functions/roomShape.lua +1 -1
  17. package/dist/src/functions/roomShapeWalls.lua +2 -2
  18. package/dist/src/functions/rooms.d.ts +98 -1
  19. package/dist/src/functions/rooms.d.ts.map +1 -1
  20. package/dist/src/functions/rooms.lua +145 -68
  21. package/package.json +2 -2
  22. package/src/classes/features/other/ItemPoolDetection.ts +6 -6
  23. package/src/classes/features/other/customStages/backdrop.ts +3 -3
  24. package/src/functions/hex.ts +8 -8
  25. package/src/functions/levelGrid.ts +51 -24
  26. package/src/functions/logMisc.ts +5 -9
  27. package/src/functions/roomData.ts +4 -0
  28. package/src/functions/roomGrid.ts +2 -2
  29. package/src/functions/roomShape.ts +1 -1
  30. package/src/functions/roomShapeWalls.ts +2 -2
  31. package/src/functions/rooms.ts +237 -118
@@ -5696,10 +5696,13 @@ export declare function getNewGlobals(): ReadonlyArray<[AnyNotNil, unknown]>;
5696
5696
  *
5697
5697
  * @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
5698
5698
  * `RNG.Next` method will be called. Default is `getRandomSeed()`.
5699
+ * @param ensureDeadEnd Optional. Whether to pick a valid dead end attached to a normal room. If
5700
+ * false, the function will randomly pick from any valid location that would
5701
+ * have a red door.
5699
5702
  * @returns Either a tuple of adjacent room grid index, `DoorSlot`, and new room grid index, or
5700
5703
  * undefined.
5701
5704
  */
5702
- export declare function getNewRoomCandidate(seedOrRNG?: Seed | RNG): {
5705
+ export declare function getNewRoomCandidate(seedOrRNG?: Seed | RNG, ensureDeadEnd?: boolean): {
5703
5706
  readonly adjacentRoomGridIndex: int;
5704
5707
  readonly doorSlot: DoorSlot;
5705
5708
  readonly newRoomGridIndex: int;
@@ -5707,25 +5710,29 @@ export declare function getNewRoomCandidate(seedOrRNG?: Seed | RNG): {
5707
5710
 
5708
5711
  /**
5709
5712
  * Helper function to iterate through the possible doors for a room and see if any of them would be
5710
- * a valid spot to insert a brand new room on the floor. (Any potential new rooms cannot be
5711
- * connected to any other existing rooms on the floor.)
5713
+ * a valid spot to insert a brand new room on the floor.
5712
5714
  *
5713
5715
  * @param roomGridIndex Optional. Default is the current room index.
5716
+ * @param ensureDeadEnd Optional. Whether to only include doors that lead to a valid dead end
5717
+ * attached to a normal room. If false, the function will include all doors
5718
+ * that would have a red door.
5714
5719
  * @returns A array of tuples of `DoorSlot` and room grid index.
5715
5720
  */
5716
- export declare function getNewRoomCandidatesBesideRoom(roomGridIndex?: int): ReadonlyArray<{
5721
+ export declare function getNewRoomCandidatesBesideRoom(roomGridIndex?: int, ensureDeadEnd?: boolean): ReadonlyArray<{
5717
5722
  readonly doorSlot: DoorSlot;
5718
5723
  readonly roomGridIndex: int;
5719
5724
  }>;
5720
5725
 
5721
5726
  /**
5722
- * Helper function to search through all of the rooms on the floor for a spot to insert a brand new
5723
- * room.
5727
+ * Helper function to get all of the spots on the floor to insert a brand new room.
5724
5728
  *
5729
+ * @param ensureDeadEnd Optional. Whether to only include spots that are a valid dead end attached
5730
+ * to a normal room. If false, the function will include all valid spots that
5731
+ * have a red door.
5725
5732
  * @returns A array of tuples containing the adjacent room grid index, the `DoorSlot`, and the new
5726
5733
  * room grid index.
5727
5734
  */
5728
- export declare function getNewRoomCandidatesForLevel(): ReadonlyArray<{
5735
+ export declare function getNewRoomCandidatesForLevel(ensureDeadEnd?: boolean): ReadonlyArray<{
5729
5736
  readonly adjacentRoomGridIndex: int;
5730
5737
  readonly doorSlot: DoorSlot;
5731
5738
  readonly newRoomGridIndex: int;
@@ -6497,11 +6504,8 @@ export declare function getRoomAdjacentGridIndexes(roomGridIndex?: int): Readonl
6497
6504
  */
6498
6505
  export declare function getRoomAllowedDoors(roomGridIndex?: int): Set<DoorSlot>;
6499
6506
 
6500
- /**
6501
- * Helper function to get the room data for the provided room.
6502
- *
6503
- * @param roomGridIndex Optional. Default is the current room index.
6504
- */
6507
+ export declare function getRoomData(): RoomConfig;
6508
+
6505
6509
  export declare function getRoomData(roomGridIndex?: int): RoomConfig | undefined;
6506
6510
 
6507
6511
  /**
@@ -7535,7 +7539,7 @@ export declare function includes<T>(array: T[], element: T): boolean;
7535
7539
  /**
7536
7540
  * Helper function for determining whether the current room is a crawl space. Use this function over
7537
7541
  * comparing to `RoomType.DUNGEON` or `GridRoom.DUNGEON_IDX` since there is a special case of the
7538
- * player being in a boss fight that take place in a dungeon.
7542
+ * player being in a boss fight that takes place in a dungeon.
7539
7543
  */
7540
7544
  export declare function inCrawlSpace(): boolean;
7541
7545
 
@@ -7567,9 +7571,14 @@ export declare function inDimension(dimension: Dimension): boolean;
7567
7571
  * This is performed by checking for the string "Double Trouble" inside of the room name. The
7568
7572
  * vanilla game uses this convention for every Double Trouble Boss Room. Note that this method might
7569
7573
  * fail for mods that add extra Double Trouble rooms but do not follow the convention.
7574
+ *
7575
+ * Internally, the game is coded to detect Double Trouble Boss Rooms by checking for the variant
7576
+ * range of 3700 through 3850. We intentionally do not use this method since it may not work as well
7577
+ * with modded rooms.
7570
7578
  */
7571
7579
  export declare function inDoubleTrouble(): boolean;
7572
7580
 
7581
+ /** Helper function to determine if the current room index is equal to `GridRoom.GENESIS`. */
7573
7582
  export declare function inGenesisRoom(): boolean;
7574
7583
 
7575
7584
  /**
@@ -7693,6 +7702,11 @@ export declare function inStartingRoom(): boolean;
7693
7702
  */
7694
7703
  export declare function iRange(start: int, end?: int, increment?: number): int[];
7695
7704
 
7705
+ /**
7706
+ * Helper function to determine if the provided room is equal to `RoomShape.1x2` or `RoomShape.2x1`.
7707
+ */
7708
+ export declare function is2x1Room(roomData: RoomConfig): boolean;
7709
+
7696
7710
  /**
7697
7711
  * Helper function to check if an instantiated Isaac API class is equal to another one of the same
7698
7712
  * type. You must provide the list of keys to check for.
@@ -7805,6 +7819,8 @@ export declare function isAllRoomsClear(onlyCheckRoomTypes?: RoomType[], include
7805
7819
 
7806
7820
  export declare function isAngelRoomDoor(door: GridEntityDoor): boolean;
7807
7821
 
7822
+ export declare function isAngelShop(roomData: RoomConfig): boolean;
7823
+
7808
7824
  /**
7809
7825
  * Since Lua uses tables for every non-primitive data structure, it is non-trivial to determine if a
7810
7826
  * particular table is being used as an array. `isArray` returns true if:
@@ -7831,6 +7847,8 @@ export declare function isArrayInArray<T>(arrayToMatch: T[] | readonly T[], pare
7831
7847
  /** For `PickupVariant.LIL_BATTERY` (90). */
7832
7848
  export declare function isBattery(pickup: EntityPickup): pickup is EntityPickupBattery;
7833
7849
 
7850
+ export declare function isBeastRoom(roomData: RoomConfig): boolean;
7851
+
7834
7852
  /**
7835
7853
  * Helper function for detecting when a player is Bethany or Tainted Bethany. This is useful if you
7836
7854
  * need to adjust UI elements to account for Bethany's soul charges or Tainted Bethany's blood
@@ -7859,6 +7877,12 @@ export declare function isBombPickup(pickup: EntityPickup): pickup is EntityPick
7859
7877
 
7860
7878
  export declare function isBoolean(variable: unknown): variable is boolean;
7861
7879
 
7880
+ /**
7881
+ * Helper function to check if the provided room is a boss room for a particular boss. This will
7882
+ * only work for bosses that have dedicated boss rooms in the "00.special rooms.stb" file.
7883
+ */
7884
+ export declare function isBossRoomOf(roomData: RoomConfig, bossID: BossID): boolean;
7885
+
7862
7886
  /**
7863
7887
  * Returns true for cards that have the following card type:
7864
7888
  * - CardType.TAROT
@@ -8050,6 +8074,13 @@ export declare function isColor(object: unknown): object is Color;
8050
8074
  */
8051
8075
  export declare function isCopyableIsaacAPIClass(object: unknown): object is CopyableIsaacAPIClass;
8052
8076
 
8077
+ /**
8078
+ * Helper function for determining whether the provided room is a crawl space. Use this function
8079
+ * over comparing to `RoomType.DUNGEON` or `GridRoom.DUNGEON_IDX` since there is a special case of
8080
+ * the player being in a boss fight that takes place in a dungeon.
8081
+ */
8082
+ export declare function isCrawlSpace(roomData: RoomConfig): boolean;
8083
+
8053
8084
  /**
8054
8085
  * Helper function to distinguish between a normal Daddy Long Legs / Triachnid and the child entity
8055
8086
  * that is spawned when the boss does the multi-stomp attack.
@@ -8086,6 +8117,11 @@ export declare function isDamageToPlayerFatal(player: EntityPlayer, amount: int,
8086
8117
  */
8087
8118
  export declare function isDeadEnd(roomGridIndex?: int): boolean;
8088
8119
 
8120
+ /**
8121
+ * Helper function to detect if the provided room is one of the rooms in the Death Certificate area.
8122
+ */
8123
+ export declare function isDeathCertificateArea(roomData: RoomConfig): boolean;
8124
+
8089
8125
  /**
8090
8126
  * Helper function to determine if a given object is a TypeScriptToLua `Map`.
8091
8127
  *
@@ -8096,6 +8132,14 @@ export declare function isDefaultMap(object: unknown): object is DefaultMap<AnyN
8096
8132
 
8097
8133
  export declare function isDevilRoomDoor(door: GridEntityDoor): boolean;
8098
8134
 
8135
+ /**
8136
+ * Helper function to detect if the provided room is a Treasure Room created when entering with a
8137
+ * Devil's Crown trinket.
8138
+ *
8139
+ * Under the hood, this checks for `RoomDescriptorFlag.DEVIL_TREASURE`.
8140
+ */
8141
+ export declare function isDevilsCrownTreasureRoom(roomDescriptor: RoomDescriptor): boolean;
8142
+
8099
8143
  /** Helper function to detect if a variable is of type `GridEntityDoor`. */
8100
8144
  export declare function isDoor(variable: unknown): variable is GridEntityDoor;
8101
8145
 
@@ -8136,6 +8180,19 @@ export declare function isDoorToMines(door: GridEntityDoor): boolean;
8136
8180
  */
8137
8181
  export declare function isDoorToMomsHeart(door: GridEntityDoor): boolean;
8138
8182
 
8183
+ /**
8184
+ * Helper function to detect if the provided room is a Double Trouble Boss Room.
8185
+ *
8186
+ * This is performed by checking for the string "Double Trouble" inside of the room name. The
8187
+ * vanilla game uses this convention for every Double Trouble Boss Room. Note that this method might
8188
+ * fail for mods that add extra Double Trouble rooms but do not follow the convention.
8189
+ *
8190
+ * Internally, the game is coded to detect Double Trouble Boss Rooms by checking for the variant
8191
+ * range of 3700 through 3850. We intentionally do not use this method since it may not work as well
8192
+ * with modded rooms.
8193
+ */
8194
+ export declare function isDoubleTrouble(roomData: RoomConfig): boolean;
8195
+
8139
8196
  /**
8140
8197
  * Helper function to detect the custom death state of a Dump. When Dumps die, they go to
8141
8198
  * `NPCState.SPECIAL`, spit out their head, and then slowly fade away while shooting a burst of
@@ -8222,6 +8279,11 @@ export declare function isFoundSoul(player: EntityPlayer): boolean;
8222
8279
 
8223
8280
  export declare function isFunction(variable: unknown): variable is Function;
8224
8281
 
8282
+ /**
8283
+ * Helper function to determine if the index of the provided room is equal to `GridRoom.GENESIS`.
8284
+ */
8285
+ export declare function isGenesisRoom(roomDescriptor: RoomDescriptor): boolean;
8286
+
8225
8287
  /**
8226
8288
  * Returns whether or not the given collectible is a "glitched" item. All items are replaced by
8227
8289
  * glitched items once a player has TMTRAINER. However, glitched items can also "naturally" appear
@@ -8268,6 +8330,14 @@ export declare function isHiddenCollectible(collectibleOrCollectibleType: Entity
8268
8330
 
8269
8331
  export declare function isHiddenSecretRoomDoor(door: GridEntityDoor): boolean;
8270
8332
 
8333
+ /**
8334
+ * Helper function to check if the provided room is either the left Home closet (behind the red
8335
+ * door) or the right Home closet (with one random pickup).
8336
+ *
8337
+ * Home closets have a unique shape that is different from any other room in the game.
8338
+ */
8339
+ export declare function isHomeCloset(roomData: RoomConfig): boolean;
8340
+
8271
8341
  export declare function isHorsePill(pillColor: PillColor): boolean;
8272
8342
 
8273
8343
  /**
@@ -8314,7 +8384,10 @@ export declare function isLaser(variable: unknown): variable is EntityLaser;
8314
8384
  /** Helper function for detecting when a player is The Lost or Tainted Lost. */
8315
8385
  export declare function isLost(player: EntityPlayer): boolean;
8316
8386
 
8317
- export declare function isLRoom(roomShape: RoomShape): boolean;
8387
+ /** Helper function to determine if the provided room is one of the four L room shapes. */
8388
+ export declare function isLRoom(roomData: RoomConfig): boolean;
8389
+
8390
+ export declare function isLRoomShape(roomShape: RoomShape): boolean;
8318
8391
 
8319
8392
  /**
8320
8393
  * Players can boot the game with an launch option called "--luadebug", which will enable additional
@@ -8333,6 +8406,29 @@ export declare function isLRoom(roomShape: RoomShape): boolean;
8333
8406
  */
8334
8407
  export declare function isLuaDebugEnabled(): boolean;
8335
8408
 
8409
+ /**
8410
+ * Helper function to determine if the index of the provided room is equal to `GridRoom.MEGA_SATAN`.
8411
+ */
8412
+ export declare function isMegaSatanRoom(roomDescriptor: RoomDescriptor): boolean;
8413
+
8414
+ /**
8415
+ * Helper function to determine if the provided room is part of the Repentance "escape sequence" in
8416
+ * the Mines/Ashpit.
8417
+ */
8418
+ export declare function isMineShaft(roomData: RoomConfig): boolean;
8419
+
8420
+ /**
8421
+ * Helper function to check if the provided room is a miniboss room for a particular miniboss. This
8422
+ * will only work for mini-bosses that have dedicated boss rooms in the "00.special rooms.stb" file.
8423
+ */
8424
+ export declare function isMinibossRoomOf(roomData: RoomConfig, minibossID: MinibossID): boolean;
8425
+
8426
+ /**
8427
+ * Helper function to check if the provided room is a "mirror room" in Downpour or Dross. (These
8428
+ * rooms are marked with a specific sub-type.)
8429
+ */
8430
+ export declare function isMirrorRoom(roomData: RoomConfig): boolean;
8431
+
8336
8432
  /** Returns true for any card or rune added by a mod. */
8337
8433
  export declare function isModdedCardType(cardType: CardType): boolean;
8338
8434
 
@@ -8527,6 +8623,13 @@ export declare function isRoomInsideGrid(roomGridIndex?: int): boolean;
8527
8623
  */
8528
8624
  export declare function isRoomShapeDoubleCharge(roomShape: RoomShape): boolean;
8529
8625
 
8626
+ /**
8627
+ * Helper function to check if the provided room matches one of the given room types.
8628
+ *
8629
+ * This function is variadic, which means you can pass as many room types as you want to match for.
8630
+ */
8631
+ export declare function isRoomType(roomData: RoomConfig, ...roomTypes: RoomType[]): boolean;
8632
+
8530
8633
  /**
8531
8634
  * Helper function to check if a given room is visible on the minimap.
8532
8635
  *
@@ -8542,6 +8645,12 @@ export declare function isRune(cardType: CardType): boolean;
8542
8645
  /** For `PickupVariant.SACK` (69). */
8543
8646
  export declare function isSack(pickup: EntityPickup): pickup is EntityPickupSack;
8544
8647
 
8648
+ /**
8649
+ * Helper function for checking if the provided room is a secret exit that leads to a Repentance
8650
+ * floor.
8651
+ */
8652
+ export declare function isSecretExit(roomDescriptor: RoomDescriptor): boolean;
8653
+
8545
8654
  /**
8546
8655
  * This refers to the hole in the wall that appears after bombing the entrance to a secret room.
8547
8656
  * Note that the door still exists before it has been bombed open. It has a sprite filename of
@@ -8558,6 +8667,16 @@ export declare function isSecretRoomDoor(door: GridEntityDoor): boolean;
8558
8667
  */
8559
8668
  export declare function isSecretRoomType(roomType: RoomType): boolean;
8560
8669
 
8670
+ /**
8671
+ * Helper function for checking if the provided room is a secret shop (from the Member Card
8672
+ * collectible).
8673
+ *
8674
+ * Secret shops are simply copies of normal shops, but with the backdrop of a secret room. In other
8675
+ * words, they will have the same room type, room variant, and room sub-type of a normal shop. Thus,
8676
+ * the only way to detect them is by using the grid index.
8677
+ */
8678
+ export declare function isSecretShop(roomDescriptor: RoomDescriptor): boolean;
8679
+
8561
8680
  /**
8562
8681
  * Helper function to determine whether damage to a player in the `ENTITY_TAKE_DMG` callback was
8563
8682
  * self-inflicted. For example, damage from a Curse Room door, a Razor, or a Blood Donation Machine
@@ -13121,23 +13240,25 @@ export declare function newReadonlyVector(x: float, y: float): Readonly<Vector>;
13121
13240
  export declare function newRNG(seed?: Seed): RNG;
13122
13241
 
13123
13242
  /**
13124
- * Helper function to generate a new room on the floor at a valid dead end attached to a normal
13125
- * room.
13243
+ * Helper function to generate a new room on the floor.
13126
13244
  *
13127
13245
  * Under the hood, this function uses the `Level.MakeRedRoomDoor` method to create the room.
13128
13246
  *
13129
- * The newly created room will have data corresponding to the game's randomly generated red room. If
13130
- * you want to modify this, use the `setRoomData` helper function.
13131
- *
13132
13247
  * @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
13133
13248
  * `RNG.Next` method will be called. Default is `Level.GetDungeonPlacementSeed`.
13134
13249
  * Note that the RNG is only used to select the random location to put the room on
13135
13250
  * the floor; it does not influence the randomly chosen room contents. (That is
13136
13251
  * performed by the game and can not be manipulated prior to its generation.)
13252
+ * @param ensureDeadEnd Optional. Whether to place the room at a valid dead end attached to a normal
13253
+ * room. If false, it will randomly appear at any valid location that would
13254
+ * have a red door.
13255
+ * @param customRoomData Optional. By default, the newly created room will have data corresponding
13256
+ * to the game's randomly generated red room. If you provide this function
13257
+ * with room data, it will be used to override the vanilla data.
13137
13258
  * @returns The room grid index of the new room or undefined if the floor had no valid dead ends to
13138
13259
  * place a room.
13139
13260
  */
13140
- export declare function newRoom(seedOrRNG?: Seed | RNG): int | undefined;
13261
+ export declare function newRoom(seedOrRNG?: Seed | RNG, ensureDeadEnd?: boolean, customRoomData?: RoomConfig): int | undefined;
13141
13262
 
13142
13263
  /**
13143
13264
  * Helper function to load a new sprite and play its default animation.