isaacscript-common 9.13.3 → 9.13.4

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.
@@ -165,10 +165,12 @@ export declare function isRoomInsideGrid(roomGridIndex?: int): boolean;
165
165
  * The newly created room will have data corresponding to the game's randomly generated red room. If
166
166
  * you want to modify this, use the `setRoomData` helper function.
167
167
  *
168
+ * @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
169
+ * `RNG.Next` method will be called. Default is `Level.GetDungeonPlacementSeed`.
168
170
  * @returns The room grid index of the new room or undefined if the floor had no valid dead ends to
169
171
  * place a room.
170
172
  */
171
- export declare function newRoom(): int | undefined;
173
+ export declare function newRoom(seedOrRNG?: Seed | RNG): int | undefined;
172
174
  /**
173
175
  * Helper function to check if a room exists at the given room grid index. (A room will exist if it
174
176
  * has non-undefined data in the room descriptor.)
@@ -1 +1 @@
1
- {"version":3,"file":"levelGrid.d.ts","sourceRoot":"","sources":["../../src/functions/levelGrid.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAEL,QAAQ,EAKR,SAAS,EACT,QAAQ,EACT,MAAM,8BAA8B,CAAC;AA8BtC;;;;;GAKG;AACH,wBAAgB,kCAAkC,CAAC,aAAa,CAAC,EAAE,GAAG,GAAG,GAAG,EAAE,CAK7E;AAED;;;;;;GAMG;AACH,wBAAgB,qCAAqC,CACnD,aAAa,CAAC,EAAE,GAAG,GAClB,GAAG,EAAE,CAKP;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,0BAA0B,CAAC,aAAa,CAAC,EAAE,GAAG,GAAG,GAAG,EAAE,CAerE;AAED,0FAA0F;AAC1F,wBAAgB,qBAAqB,IAAI,GAAG,EAAE,CAG7C;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,GAAE,IAAI,GAAG,GAAqB,GAErC,CAAC,qBAAqB,EAAE,GAAG,EAAE,QAAQ,EAA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gB,SAAS,CAAC,aAAa,CAAC,EAAE,GAAG,GAAG,OAAO,CAKtD;AAED,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,QAAQ,EAClB,aAAa,EAAE,GAAG,GACjB,OAAO,CAGT;AAED,wBAAgB,oCAAoC,CAClD,QAAQ,EAAE,QAAQ,EAClB,aAAa,EAAE,GAAG,GACjB,OAAO,CAqBT;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,aAAa,CAAC,EAAE,GAAG,GAAG,OAAO,CAGzD;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,aAAa,CAAC,EAAE,GAAG,GAAG,OAAO,CAM7D;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,OAAO,CAAC,SAAS,CAAC,EAAE,IAAI,GAAG,GAAG,GAAG,GAAG,GAAG,SAAS,CAmD/D;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,aAAa,EAAE,GAAG,GAAG,OAAO,CAGtD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,GAAG,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,CAKtE"}
@@ -32,6 +32,8 @@ local hasFlag = ____flag.hasFlag
32
32
  local removeFlag = ____flag.removeFlag
33
33
  local ____rng = require("functions.rng")
34
34
  local getRandomSeed = ____rng.getRandomSeed
35
+ local isRNG = ____rng.isRNG
36
+ local newRNG = ____rng.newRNG
35
37
  local ____roomData = require("functions.roomData")
36
38
  local getRoomAllowedDoors = ____roomData.getRoomAllowedDoors
37
39
  local getRoomData = ____roomData.getRoomData
@@ -348,15 +350,21 @@ end
348
350
  -- The newly created room will have data corresponding to the game's randomly generated red room. If
349
351
  -- you want to modify this, use the `setRoomData` helper function.
350
352
  --
353
+ -- @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
354
+ -- `RNG.Next` method will be called. Default is `Level.GetDungeonPlacementSeed`.
351
355
  -- @returns The room grid index of the new room or undefined if the floor had no valid dead ends to
352
356
  -- place a room.
353
- function ____exports.newRoom(self)
354
- local newRoomCandidate = ____exports.getNewRoomCandidate(nil)
357
+ function ____exports.newRoom(self, seedOrRNG)
358
+ local level = game:GetLevel()
359
+ if seedOrRNG == nil then
360
+ seedOrRNG = level:GetDungeonPlacementSeed()
361
+ end
362
+ local rng = isRNG(nil, seedOrRNG) and seedOrRNG or newRNG(nil, seedOrRNG)
363
+ local newRoomCandidate = ____exports.getNewRoomCandidate(nil, rng)
355
364
  if newRoomCandidate == nil then
356
365
  return nil
357
366
  end
358
367
  local adjacentRoomGridIndex, doorSlot, newRoomGridIndex = table.unpack(newRoomCandidate)
359
- local level = game:GetLevel()
360
368
  level:MakeRedRoomDoor(adjacentRoomGridIndex, doorSlot)
361
369
  local roomDescriptor = getRoomDescriptor(nil, newRoomGridIndex)
362
370
  roomDescriptor.Flags = removeFlag(nil, roomDescriptor.Flags, RoomDescriptorFlag.RED_ROOM)
package/dist/index.d.ts CHANGED
@@ -8329,10 +8329,12 @@ export declare function newRNG(seed?: Seed): RNG;
8329
8329
  * The newly created room will have data corresponding to the game's randomly generated red room. If
8330
8330
  * you want to modify this, use the `setRoomData` helper function.
8331
8331
  *
8332
+ * @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
8333
+ * `RNG.Next` method will be called. Default is `Level.GetDungeonPlacementSeed`.
8332
8334
  * @returns The room grid index of the new room or undefined if the floor had no valid dead ends to
8333
8335
  * place a room.
8334
8336
  */
8335
- export declare function newRoom(): int | undefined;
8337
+ export declare function newRoom(seedOrRNG?: Seed | RNG): int | undefined;
8336
8338
 
8337
8339
  /**
8338
8340
  * Helper function to generate a new sprite based on a collectible. If the provided collectible type
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "9.13.3",
3
+ "version": "9.13.4",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -27,7 +27,7 @@ import { ROOM_SHAPE_TO_DOOR_SLOTS_TO_GRID_INDEX_DELTA } from "../objects/roomSha
27
27
  import { getRandomArrayElement } from "./array";
28
28
  import { doorSlotToDoorSlotFlag } from "./doors";
29
29
  import { addFlag, hasFlag, removeFlag } from "./flag";
30
- import { getRandomSeed } from "./rng";
30
+ import { getRandomSeed, isRNG, newRNG } from "./rng";
31
31
  import {
32
32
  getRoomAllowedDoors,
33
33
  getRoomData,
@@ -460,17 +460,25 @@ export function isRoomInsideGrid(roomGridIndex?: int): boolean {
460
460
  * The newly created room will have data corresponding to the game's randomly generated red room. If
461
461
  * you want to modify this, use the `setRoomData` helper function.
462
462
  *
463
+ * @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
464
+ * `RNG.Next` method will be called. Default is `Level.GetDungeonPlacementSeed`.
463
465
  * @returns The room grid index of the new room or undefined if the floor had no valid dead ends to
464
466
  * place a room.
465
467
  */
466
- export function newRoom(): int | undefined {
467
- const newRoomCandidate = getNewRoomCandidate();
468
+ export function newRoom(seedOrRNG?: Seed | RNG): int | undefined {
469
+ const level = game.GetLevel();
470
+
471
+ if (seedOrRNG === undefined) {
472
+ seedOrRNG = level.GetDungeonPlacementSeed();
473
+ }
474
+ const rng = isRNG(seedOrRNG) ? seedOrRNG : newRNG(seedOrRNG);
475
+
476
+ const newRoomCandidate = getNewRoomCandidate(rng);
468
477
  if (newRoomCandidate === undefined) {
469
478
  return undefined;
470
479
  }
471
480
  const [adjacentRoomGridIndex, doorSlot, newRoomGridIndex] = newRoomCandidate;
472
481
 
473
- const level = game.GetLevel();
474
482
  level.MakeRedRoomDoor(adjacentRoomGridIndex, doorSlot);
475
483
 
476
484
  // By default, the room will be a "red room" and have a red graphical tint, so we want to make it