isaacscript-common 30.12.10 → 31.0.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.
Files changed (31) hide show
  1. package/dist/index.rollup.d.ts +152 -20
  2. package/dist/isaacscript-common.lua +181 -110
  3. package/dist/src/classes/features/other/CustomStages.d.ts +11 -0
  4. package/dist/src/classes/features/other/CustomStages.d.ts.map +1 -1
  5. package/dist/src/classes/features/other/CustomStages.lua +42 -9
  6. package/dist/src/classes/features/other/customStages/backdrop.lua +3 -3
  7. package/dist/src/functions/levelGrid.d.ts +22 -13
  8. package/dist/src/functions/levelGrid.d.ts.map +1 -1
  9. package/dist/src/functions/levelGrid.lua +46 -23
  10. package/dist/src/functions/logMisc.d.ts.map +1 -1
  11. package/dist/src/functions/logMisc.lua +3 -7
  12. package/dist/src/functions/roomData.d.ts +1 -5
  13. package/dist/src/functions/roomData.d.ts.map +1 -1
  14. package/dist/src/functions/roomGrid.lua +6 -6
  15. package/dist/src/functions/roomShape.d.ts +1 -1
  16. package/dist/src/functions/roomShape.d.ts.map +1 -1
  17. package/dist/src/functions/roomShape.lua +1 -1
  18. package/dist/src/functions/roomShapeWalls.lua +2 -2
  19. package/dist/src/functions/rooms.d.ts +98 -1
  20. package/dist/src/functions/rooms.d.ts.map +1 -1
  21. package/dist/src/functions/rooms.lua +145 -68
  22. package/package.json +1 -1
  23. package/src/classes/features/other/CustomStages.ts +60 -0
  24. package/src/classes/features/other/customStages/backdrop.ts +3 -3
  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
@@ -2174,6 +2174,7 @@ declare class CustomStages extends Feature {
2174
2174
  private readonly customStagesMap;
2175
2175
  /** Indexed by room variant. */
2176
2176
  private readonly customStageCachedRoomData;
2177
+ private usingRedKey;
2177
2178
  private readonly customGridEntities;
2178
2179
  private readonly customTrapdoors;
2179
2180
  private readonly disableAllSound;
@@ -2185,8 +2186,18 @@ declare class CustomStages extends Feature {
2185
2186
  private initCustomTrapdoorDestination;
2186
2187
  private readonly goToCustomStage;
2187
2188
  private readonly postRender;
2189
+ /**
2190
+ * Fix the bug where Red Key will not work on custom floors (due to the stage being a bugged
2191
+ * value).
2192
+ */
2193
+ private readonly postUseItemRedKey;
2188
2194
  private readonly postCurseEval;
2189
2195
  private readonly getShaderParams;
2196
+ /**
2197
+ * Fix the bug where Red Key will not work on custom floors (due to the stage being a bugged
2198
+ * value).
2199
+ */
2200
+ private readonly preUseItemRedKey;
2190
2201
  private readonly postGridEntityBrokenRockAlt;
2191
2202
  private readonly postGridEntityInit;
2192
2203
  private readonly postNewRoomReordered;
@@ -5685,10 +5696,13 @@ export declare function getNewGlobals(): ReadonlyArray<[AnyNotNil, unknown]>;
5685
5696
  *
5686
5697
  * @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
5687
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.
5688
5702
  * @returns Either a tuple of adjacent room grid index, `DoorSlot`, and new room grid index, or
5689
5703
  * undefined.
5690
5704
  */
5691
- export declare function getNewRoomCandidate(seedOrRNG?: Seed | RNG): {
5705
+ export declare function getNewRoomCandidate(seedOrRNG?: Seed | RNG, ensureDeadEnd?: boolean): {
5692
5706
  readonly adjacentRoomGridIndex: int;
5693
5707
  readonly doorSlot: DoorSlot;
5694
5708
  readonly newRoomGridIndex: int;
@@ -5696,25 +5710,29 @@ export declare function getNewRoomCandidate(seedOrRNG?: Seed | RNG): {
5696
5710
 
5697
5711
  /**
5698
5712
  * Helper function to iterate through the possible doors for a room and see if any of them would be
5699
- * a valid spot to insert a brand new room on the floor. (Any potential new rooms cannot be
5700
- * connected to any other existing rooms on the floor.)
5713
+ * a valid spot to insert a brand new room on the floor.
5701
5714
  *
5702
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.
5703
5719
  * @returns A array of tuples of `DoorSlot` and room grid index.
5704
5720
  */
5705
- export declare function getNewRoomCandidatesBesideRoom(roomGridIndex?: int): ReadonlyArray<{
5721
+ export declare function getNewRoomCandidatesBesideRoom(roomGridIndex?: int, ensureDeadEnd?: boolean): ReadonlyArray<{
5706
5722
  readonly doorSlot: DoorSlot;
5707
5723
  readonly roomGridIndex: int;
5708
5724
  }>;
5709
5725
 
5710
5726
  /**
5711
- * Helper function to search through all of the rooms on the floor for a spot to insert a brand new
5712
- * room.
5727
+ * Helper function to get all of the spots on the floor to insert a brand new room.
5713
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.
5714
5732
  * @returns A array of tuples containing the adjacent room grid index, the `DoorSlot`, and the new
5715
5733
  * room grid index.
5716
5734
  */
5717
- export declare function getNewRoomCandidatesForLevel(): ReadonlyArray<{
5735
+ export declare function getNewRoomCandidatesForLevel(ensureDeadEnd?: boolean): ReadonlyArray<{
5718
5736
  readonly adjacentRoomGridIndex: int;
5719
5737
  readonly doorSlot: DoorSlot;
5720
5738
  readonly newRoomGridIndex: int;
@@ -6486,11 +6504,8 @@ export declare function getRoomAdjacentGridIndexes(roomGridIndex?: int): Readonl
6486
6504
  */
6487
6505
  export declare function getRoomAllowedDoors(roomGridIndex?: int): Set<DoorSlot>;
6488
6506
 
6489
- /**
6490
- * Helper function to get the room data for the provided room.
6491
- *
6492
- * @param roomGridIndex Optional. Default is the current room index.
6493
- */
6507
+ export declare function getRoomData(): RoomConfig;
6508
+
6494
6509
  export declare function getRoomData(roomGridIndex?: int): RoomConfig | undefined;
6495
6510
 
6496
6511
  /**
@@ -7524,7 +7539,7 @@ export declare function includes<T>(array: T[], element: T): boolean;
7524
7539
  /**
7525
7540
  * Helper function for determining whether the current room is a crawl space. Use this function over
7526
7541
  * comparing to `RoomType.DUNGEON` or `GridRoom.DUNGEON_IDX` since there is a special case of the
7527
- * 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.
7528
7543
  */
7529
7544
  export declare function inCrawlSpace(): boolean;
7530
7545
 
@@ -7556,9 +7571,14 @@ export declare function inDimension(dimension: Dimension): boolean;
7556
7571
  * This is performed by checking for the string "Double Trouble" inside of the room name. The
7557
7572
  * vanilla game uses this convention for every Double Trouble Boss Room. Note that this method might
7558
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.
7559
7578
  */
7560
7579
  export declare function inDoubleTrouble(): boolean;
7561
7580
 
7581
+ /** Helper function to determine if the current room index is equal to `GridRoom.GENESIS`. */
7562
7582
  export declare function inGenesisRoom(): boolean;
7563
7583
 
7564
7584
  /**
@@ -7682,6 +7702,11 @@ export declare function inStartingRoom(): boolean;
7682
7702
  */
7683
7703
  export declare function iRange(start: int, end?: int, increment?: number): int[];
7684
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
+
7685
7710
  /**
7686
7711
  * Helper function to check if an instantiated Isaac API class is equal to another one of the same
7687
7712
  * type. You must provide the list of keys to check for.
@@ -7794,6 +7819,8 @@ export declare function isAllRoomsClear(onlyCheckRoomTypes?: RoomType[], include
7794
7819
 
7795
7820
  export declare function isAngelRoomDoor(door: GridEntityDoor): boolean;
7796
7821
 
7822
+ export declare function isAngelShop(roomData: RoomConfig): boolean;
7823
+
7797
7824
  /**
7798
7825
  * Since Lua uses tables for every non-primitive data structure, it is non-trivial to determine if a
7799
7826
  * particular table is being used as an array. `isArray` returns true if:
@@ -7820,6 +7847,8 @@ export declare function isArrayInArray<T>(arrayToMatch: T[] | readonly T[], pare
7820
7847
  /** For `PickupVariant.LIL_BATTERY` (90). */
7821
7848
  export declare function isBattery(pickup: EntityPickup): pickup is EntityPickupBattery;
7822
7849
 
7850
+ export declare function isBeastRoom(roomData: RoomConfig): boolean;
7851
+
7823
7852
  /**
7824
7853
  * Helper function for detecting when a player is Bethany or Tainted Bethany. This is useful if you
7825
7854
  * need to adjust UI elements to account for Bethany's soul charges or Tainted Bethany's blood
@@ -7848,6 +7877,12 @@ export declare function isBombPickup(pickup: EntityPickup): pickup is EntityPick
7848
7877
 
7849
7878
  export declare function isBoolean(variable: unknown): variable is boolean;
7850
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
+
7851
7886
  /**
7852
7887
  * Returns true for cards that have the following card type:
7853
7888
  * - CardType.TAROT
@@ -8039,6 +8074,13 @@ export declare function isColor(object: unknown): object is Color;
8039
8074
  */
8040
8075
  export declare function isCopyableIsaacAPIClass(object: unknown): object is CopyableIsaacAPIClass;
8041
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
+
8042
8084
  /**
8043
8085
  * Helper function to distinguish between a normal Daddy Long Legs / Triachnid and the child entity
8044
8086
  * that is spawned when the boss does the multi-stomp attack.
@@ -8075,6 +8117,11 @@ export declare function isDamageToPlayerFatal(player: EntityPlayer, amount: int,
8075
8117
  */
8076
8118
  export declare function isDeadEnd(roomGridIndex?: int): boolean;
8077
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
+
8078
8125
  /**
8079
8126
  * Helper function to determine if a given object is a TypeScriptToLua `Map`.
8080
8127
  *
@@ -8085,6 +8132,14 @@ export declare function isDefaultMap(object: unknown): object is DefaultMap<AnyN
8085
8132
 
8086
8133
  export declare function isDevilRoomDoor(door: GridEntityDoor): boolean;
8087
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
+
8088
8143
  /** Helper function to detect if a variable is of type `GridEntityDoor`. */
8089
8144
  export declare function isDoor(variable: unknown): variable is GridEntityDoor;
8090
8145
 
@@ -8125,6 +8180,19 @@ export declare function isDoorToMines(door: GridEntityDoor): boolean;
8125
8180
  */
8126
8181
  export declare function isDoorToMomsHeart(door: GridEntityDoor): boolean;
8127
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
+
8128
8196
  /**
8129
8197
  * Helper function to detect the custom death state of a Dump. When Dumps die, they go to
8130
8198
  * `NPCState.SPECIAL`, spit out their head, and then slowly fade away while shooting a burst of
@@ -8211,6 +8279,11 @@ export declare function isFoundSoul(player: EntityPlayer): boolean;
8211
8279
 
8212
8280
  export declare function isFunction(variable: unknown): variable is Function;
8213
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
+
8214
8287
  /**
8215
8288
  * Returns whether or not the given collectible is a "glitched" item. All items are replaced by
8216
8289
  * glitched items once a player has TMTRAINER. However, glitched items can also "naturally" appear
@@ -8257,6 +8330,14 @@ export declare function isHiddenCollectible(collectibleOrCollectibleType: Entity
8257
8330
 
8258
8331
  export declare function isHiddenSecretRoomDoor(door: GridEntityDoor): boolean;
8259
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
+
8260
8341
  export declare function isHorsePill(pillColor: PillColor): boolean;
8261
8342
 
8262
8343
  /**
@@ -8303,7 +8384,10 @@ export declare function isLaser(variable: unknown): variable is EntityLaser;
8303
8384
  /** Helper function for detecting when a player is The Lost or Tainted Lost. */
8304
8385
  export declare function isLost(player: EntityPlayer): boolean;
8305
8386
 
8306
- 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;
8307
8391
 
8308
8392
  /**
8309
8393
  * Players can boot the game with an launch option called "--luadebug", which will enable additional
@@ -8322,6 +8406,29 @@ export declare function isLRoom(roomShape: RoomShape): boolean;
8322
8406
  */
8323
8407
  export declare function isLuaDebugEnabled(): boolean;
8324
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
+
8325
8432
  /** Returns true for any card or rune added by a mod. */
8326
8433
  export declare function isModdedCardType(cardType: CardType): boolean;
8327
8434
 
@@ -8516,6 +8623,13 @@ export declare function isRoomInsideGrid(roomGridIndex?: int): boolean;
8516
8623
  */
8517
8624
  export declare function isRoomShapeDoubleCharge(roomShape: RoomShape): boolean;
8518
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
+
8519
8633
  /**
8520
8634
  * Helper function to check if a given room is visible on the minimap.
8521
8635
  *
@@ -8531,6 +8645,12 @@ export declare function isRune(cardType: CardType): boolean;
8531
8645
  /** For `PickupVariant.SACK` (69). */
8532
8646
  export declare function isSack(pickup: EntityPickup): pickup is EntityPickupSack;
8533
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
+
8534
8654
  /**
8535
8655
  * This refers to the hole in the wall that appears after bombing the entrance to a secret room.
8536
8656
  * Note that the door still exists before it has been bombed open. It has a sprite filename of
@@ -8547,6 +8667,16 @@ export declare function isSecretRoomDoor(door: GridEntityDoor): boolean;
8547
8667
  */
8548
8668
  export declare function isSecretRoomType(roomType: RoomType): boolean;
8549
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
+
8550
8680
  /**
8551
8681
  * Helper function to determine whether damage to a player in the `ENTITY_TAKE_DMG` callback was
8552
8682
  * self-inflicted. For example, damage from a Curse Room door, a Razor, or a Blood Donation Machine
@@ -13110,23 +13240,25 @@ export declare function newReadonlyVector(x: float, y: float): Readonly<Vector>;
13110
13240
  export declare function newRNG(seed?: Seed): RNG;
13111
13241
 
13112
13242
  /**
13113
- * Helper function to generate a new room on the floor at a valid dead end attached to a normal
13114
- * room.
13243
+ * Helper function to generate a new room on the floor.
13115
13244
  *
13116
13245
  * Under the hood, this function uses the `Level.MakeRedRoomDoor` method to create the room.
13117
13246
  *
13118
- * The newly created room will have data corresponding to the game's randomly generated red room. If
13119
- * you want to modify this, use the `setRoomData` helper function.
13120
- *
13121
13247
  * @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
13122
13248
  * `RNG.Next` method will be called. Default is `Level.GetDungeonPlacementSeed`.
13123
13249
  * Note that the RNG is only used to select the random location to put the room on
13124
13250
  * the floor; it does not influence the randomly chosen room contents. (That is
13125
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.
13126
13258
  * @returns The room grid index of the new room or undefined if the floor had no valid dead ends to
13127
13259
  * place a room.
13128
13260
  */
13129
- export declare function newRoom(seedOrRNG?: Seed | RNG): int | undefined;
13261
+ export declare function newRoom(seedOrRNG?: Seed | RNG, ensureDeadEnd?: boolean, customRoomData?: RoomConfig): int | undefined;
13130
13262
 
13131
13263
  /**
13132
13264
  * Helper function to load a new sprite and play its default animation.