isaacscript-common 71.2.0 → 72.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 (83) hide show
  1. package/dist/index.rollup.d.ts +229 -96
  2. package/dist/isaacscript-common.lua +40 -154
  3. package/dist/src/classes/features/other/CustomItemPools.d.ts +7 -3
  4. package/dist/src/classes/features/other/CustomItemPools.d.ts.map +1 -1
  5. package/dist/src/classes/features/other/CustomItemPools.lua +1 -6
  6. package/dist/src/classes/features/other/DeployJSONRoom.d.ts +7 -3
  7. package/dist/src/classes/features/other/DeployJSONRoom.d.ts.map +1 -1
  8. package/dist/src/classes/features/other/DeployJSONRoom.lua +1 -5
  9. package/dist/src/classes/features/other/ModdedElementSets.d.ts +35 -15
  10. package/dist/src/classes/features/other/ModdedElementSets.d.ts.map +1 -1
  11. package/dist/src/classes/features/other/ModdedElementSets.lua +0 -17
  12. package/dist/src/classes/features/other/SpawnCollectible.d.ts +14 -6
  13. package/dist/src/classes/features/other/SpawnCollectible.d.ts.map +1 -1
  14. package/dist/src/classes/features/other/SpawnCollectible.lua +0 -8
  15. package/dist/src/classes/features/other/SpawnRockAltRewards.d.ts +8 -4
  16. package/dist/src/classes/features/other/SpawnRockAltRewards.d.ts.map +1 -1
  17. package/dist/src/classes/features/other/SpawnRockAltRewards.lua +0 -4
  18. package/dist/src/classes/features/other/customStages/utils.d.ts +2 -2
  19. package/dist/src/classes/features/other/customStages/utils.d.ts.map +1 -1
  20. package/dist/src/classes/features/other/customStages/utils.lua +0 -8
  21. package/dist/src/classes/features/other/extraConsoleCommands/commands.lua +2 -2
  22. package/dist/src/functions/array.d.ts +35 -15
  23. package/dist/src/functions/array.d.ts.map +1 -1
  24. package/dist/src/functions/array.lua +30 -26
  25. package/dist/src/functions/color.d.ts +8 -4
  26. package/dist/src/functions/color.d.ts.map +1 -1
  27. package/dist/src/functions/color.lua +7 -7
  28. package/dist/src/functions/enums.d.ts +6 -3
  29. package/dist/src/functions/enums.d.ts.map +1 -1
  30. package/dist/src/functions/enums.lua +5 -7
  31. package/dist/src/functions/itemPool.d.ts +8 -1
  32. package/dist/src/functions/itemPool.d.ts.map +1 -1
  33. package/dist/src/functions/itemPool.lua +9 -2
  34. package/dist/src/functions/jsonRoom.d.ts +13 -6
  35. package/dist/src/functions/jsonRoom.d.ts.map +1 -1
  36. package/dist/src/functions/jsonRoom.lua +11 -12
  37. package/dist/src/functions/kColor.d.ts +8 -4
  38. package/dist/src/functions/kColor.d.ts.map +1 -1
  39. package/dist/src/functions/kColor.lua +7 -7
  40. package/dist/src/functions/levelGrid.d.ts +12 -5
  41. package/dist/src/functions/levelGrid.d.ts.map +1 -1
  42. package/dist/src/functions/levelGrid.lua +10 -7
  43. package/dist/src/functions/nextStage.d.ts.map +1 -1
  44. package/dist/src/functions/nextStage.lua +4 -1
  45. package/dist/src/functions/random.d.ts +22 -13
  46. package/dist/src/functions/random.d.ts.map +1 -1
  47. package/dist/src/functions/random.lua +19 -20
  48. package/dist/src/functions/rng.d.ts +1 -1
  49. package/dist/src/functions/rng.lua +1 -1
  50. package/dist/src/functions/set.d.ts +7 -3
  51. package/dist/src/functions/set.d.ts.map +1 -1
  52. package/dist/src/functions/set.lua +6 -7
  53. package/dist/src/functions/spawnCollectible.d.ts +13 -5
  54. package/dist/src/functions/spawnCollectible.d.ts.map +1 -1
  55. package/dist/src/functions/spawnCollectible.lua +14 -9
  56. package/dist/src/functions/vector.d.ts +7 -3
  57. package/dist/src/functions/vector.d.ts.map +1 -1
  58. package/dist/src/functions/vector.lua +6 -6
  59. package/dist/src/functions/weighted.d.ts +18 -2
  60. package/dist/src/functions/weighted.d.ts.map +1 -1
  61. package/dist/src/functions/weighted.lua +16 -8
  62. package/package.json +1 -1
  63. package/src/classes/features/other/CustomItemPools.ts +7 -4
  64. package/src/classes/features/other/DeployJSONRoom.ts +9 -5
  65. package/src/classes/features/other/ModdedElementSets.ts +37 -16
  66. package/src/classes/features/other/SpawnCollectible.ts +14 -7
  67. package/src/classes/features/other/SpawnRockAltRewards.ts +9 -5
  68. package/src/classes/features/other/customStages/utils.ts +2 -3
  69. package/src/classes/features/other/extraConsoleCommands/commands.ts +2 -2
  70. package/src/functions/array.ts +36 -16
  71. package/src/functions/color.ts +9 -5
  72. package/src/functions/enums.ts +6 -4
  73. package/src/functions/itemPool.ts +11 -2
  74. package/src/functions/jsonRoom.ts +13 -7
  75. package/src/functions/kColor.ts +9 -5
  76. package/src/functions/levelGrid.ts +13 -6
  77. package/src/functions/nextStage.ts +6 -1
  78. package/src/functions/random.ts +23 -14
  79. package/src/functions/rng.ts +1 -1
  80. package/src/functions/set.ts +7 -4
  81. package/src/functions/spawnCollectible.ts +17 -5
  82. package/src/functions/vector.ts +8 -4
  83. package/src/functions/weighted.ts +18 -3
@@ -36,7 +36,6 @@ import {
36
36
  isPassiveOrFamiliarCollectible,
37
37
  } from "../../../functions/collectibles";
38
38
  import { getFlagName } from "../../../functions/flag";
39
- import { getRandomSeed } from "../../../functions/rng";
40
39
  import {
41
40
  copySet,
42
41
  deleteSetsFromSet,
@@ -1181,18 +1180,23 @@ export class ModdedElementSets extends Feature {
1181
1180
  * not all collectible types will necessarily be present when a mod first loads (due to mod load
1182
1181
  * order).
1183
1182
  *
1183
+ * If you want to get an unseeded collectible type, you must explicitly pass `undefined` to the
1184
+ * `seedOrRNG` parameter.
1185
+ *
1184
1186
  * In order to use this function, you must upgrade your mod with `ISCFeature.MODDED_ELEMENT_SETS`.
1185
1187
  *
1186
- * @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided,
1187
- * the `RNG.Next` method will be called. Default is `getRandomSeed()`.
1188
+ * @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
1189
+ * `RNG.Next` method will be called. If `undefined` is provided, it will default
1190
+ * to a random seed.
1188
1191
  * @param exceptions Optional. An array of runes to not select.
1189
1192
  */
1190
1193
  @Exported
1191
1194
  public getRandomEdenActiveCollectibleType(
1192
- seedOrRNG: Seed | RNG = getRandomSeed(),
1195
+ seedOrRNG: Seed | RNG | undefined,
1193
1196
  exceptions: CollectibleType[] | readonly CollectibleType[] = [],
1194
1197
  ): CollectibleType {
1195
1198
  this.lazyInit();
1199
+
1196
1200
  return getRandomSetElement(
1197
1201
  this.edenPassiveCollectibleTypesSet,
1198
1202
  seedOrRNG,
@@ -1208,18 +1212,23 @@ export class ModdedElementSets extends Feature {
1208
1212
  * not all collectible types will necessarily be present when a mod first loads (due to mod load
1209
1213
  * order).
1210
1214
  *
1215
+ * If you want to get an unseeded collectible type, you must explicitly pass `undefined` to the
1216
+ * `seedOrRNG` parameter.
1217
+ *
1211
1218
  * In order to use this function, you must upgrade your mod with `ISCFeature.MODDED_ELEMENT_SETS`.
1212
1219
  *
1213
- * @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided,
1214
- * the `RNG.Next` method will be called. Default is `getRandomSeed()`.
1220
+ * @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
1221
+ * `RNG.Next` method will be called. If `undefined` is provided, it will default
1222
+ * to a random seed.
1215
1223
  * @param exceptions Optional. An array of runes to not select.
1216
1224
  */
1217
1225
  @Exported
1218
1226
  public getRandomEdenPassiveCollectibleType(
1219
- seedOrRNG: Seed | RNG = getRandomSeed(),
1227
+ seedOrRNG: Seed | RNG | undefined,
1220
1228
  exceptions: CollectibleType[] | readonly CollectibleType[] = [],
1221
1229
  ): CollectibleType {
1222
1230
  this.lazyInit();
1231
+
1223
1232
  return getRandomSetElement(
1224
1233
  this.edenPassiveCollectibleTypesSet,
1225
1234
  seedOrRNG,
@@ -1330,18 +1339,22 @@ export class ModdedElementSets extends Feature {
1330
1339
  * This function can only be called if at least one callback has been executed. This is because
1331
1340
  * not all card types will necessarily be present when a mod first loads (due to mod load order).
1332
1341
  *
1342
+ * If you want to get an unseeded card type, you must explicitly pass `undefined` to the
1343
+ * `seedOrRNG` parameter.
1344
+ *
1333
1345
  * In order to use this function, you must upgrade your mod with `ISCFeature.MODDED_ELEMENT_SETS`.
1334
1346
  *
1335
1347
  * @param itemConfigCardType The item config card type that represents the pool of cards to select
1336
1348
  * from.
1337
- * @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided,
1338
- * the `RNG.Next` method will be called. Default is `getRandomSeed()`.
1349
+ * @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
1350
+ * `RNG.Next` method will be called. If `undefined` is provided, it will default
1351
+ * to a random seed.
1339
1352
  * @param exceptions Optional. An array of cards to not select.
1340
1353
  */
1341
1354
  @Exported
1342
1355
  public getRandomCardTypeOfType(
1343
1356
  itemConfigCardType: ItemConfigCardType,
1344
- seedOrRNG: Seed | RNG = getRandomSeed(),
1357
+ seedOrRNG: Seed | RNG | undefined,
1345
1358
  exceptions: CardType[] = [],
1346
1359
  ): CardType {
1347
1360
  const cardTypeSet = this.getCardTypesOfType(itemConfigCardType);
@@ -1358,15 +1371,19 @@ export class ModdedElementSets extends Feature {
1358
1371
  * This function can only be called if at least one callback has been executed. This is because
1359
1372
  * not all card types will necessarily be present when a mod first loads (due to mod load order).
1360
1373
  *
1374
+ * If you want to get an unseeded card type, you must explicitly pass `undefined` to the
1375
+ * `seedOrRNG` parameter.
1376
+ *
1361
1377
  * In order to use this function, you must upgrade your mod with `ISCFeature.MODDED_ELEMENT_SETS`.
1362
1378
  *
1363
- * @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided,
1364
- * the `RNG.Next` method will be called. Default is `getRandomSeed()`.
1379
+ * @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
1380
+ * `RNG.Next` method will be called. If `undefined` is provided, it will default
1381
+ * to a random seed.
1365
1382
  * @param exceptions Optional. An array of cards to not select.
1366
1383
  */
1367
1384
  @Exported
1368
1385
  public getRandomCard(
1369
- seedOrRNG: Seed | RNG = getRandomSeed(),
1386
+ seedOrRNG: Seed | RNG | undefined,
1370
1387
  exceptions: CardType[] = [],
1371
1388
  ): CardType {
1372
1389
  this.lazyInit();
@@ -1380,15 +1397,19 @@ export class ModdedElementSets extends Feature {
1380
1397
  * This function can only be called if at least one callback has been executed. This is because
1381
1398
  * not all card types will necessarily be present when a mod first loads (due to mod load order).
1382
1399
  *
1400
+ * If you want to get an unseeded card type, you must explicitly pass `undefined` to the
1401
+ * `seedOrRNG` parameter.
1402
+ *
1383
1403
  * In order to use this function, you must upgrade your mod with `ISCFeature.MODDED_ELEMENT_SETS`.
1384
1404
  *
1385
- * @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided,
1386
- * the `RNG.Next` method will be called. Default is `getRandomSeed()`.
1405
+ * @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
1406
+ * `RNG.Next` method will be called. If `undefined` is provided, it will default
1407
+ * to a random seed.
1387
1408
  * @param exceptions Optional. An array of runes to not select.
1388
1409
  */
1389
1410
  @Exported
1390
1411
  public getRandomRune(
1391
- seedOrRNG: Seed | RNG = getRandomSeed(),
1412
+ seedOrRNG: Seed | RNG | undefined,
1392
1413
  exceptions: CardType[] = [],
1393
1414
  ): CardType {
1394
1415
  const runesSet = this.getCardTypesOfType(ItemConfigCardType.RUNE);
@@ -6,7 +6,6 @@ import { game } from "../../../core/cachedClasses";
6
6
  import { Exported } from "../../../decorators";
7
7
  import { ISCFeature } from "../../../enums/ISCFeature";
8
8
  import { isQuestCollectible } from "../../../functions/collectibleTag";
9
- import { getRandomSeed } from "../../../functions/rng";
10
9
  import { spawnCollectibleUnsafe } from "../../../functions/spawnCollectible";
11
10
  import { Feature } from "../../private/Feature";
12
11
  import type { PreventCollectibleRotation } from "./PreventCollectibleRotation";
@@ -34,12 +33,16 @@ export class SpawnCollectible extends Feature {
34
33
  * to be a quest item), then you can use the `spawnCollectibleUnsafe` helper function instead
35
34
  * (which does not require an upgraded mod).
36
35
  *
36
+ * If you want to spawn an unseeded collectible, you must explicitly pass `undefined` to the
37
+ * `seedOrRNG` parameter.
38
+ *
37
39
  * In order to use this function, you must upgrade your mod with `ISCFeature.SPAWN_COLLECTIBLE`.
38
40
  *
39
41
  * @param collectibleType The collectible type to spawn.
40
42
  * @param positionOrGridIndex The position or grid index to spawn the collectible at.
41
- * @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided,
42
- * the `RNG.Next` method will be called. Default is `getRandomSeed()`.
43
+ * @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
44
+ * `RNG.Next` method will be called. If `undefined` is provided, it will default
45
+ * to a random seed.
43
46
  * @param options Optional. Set to true to make the collectible a "There's Options" style
44
47
  * collectible. Default is false.
45
48
  * @param forceFreeItem Optional. Set to true to disable the logic that gives the item a price for
@@ -50,7 +53,7 @@ export class SpawnCollectible extends Feature {
50
53
  public spawnCollectible(
51
54
  collectibleType: CollectibleType,
52
55
  positionOrGridIndex: Vector | int,
53
- seedOrRNG: Seed | RNG = getRandomSeed(),
56
+ seedOrRNG: Seed | RNG | undefined,
54
57
  options = false,
55
58
  forceFreeItem = false,
56
59
  spawner?: Entity,
@@ -81,12 +84,16 @@ export class SpawnCollectible extends Feature {
81
84
  * collectibles costing coins and preventing quest items from being rotated by Tainted Isaac's
82
85
  * rotation mechanic.
83
86
  *
87
+ * If you want to spawn an unseeded collectible, you must explicitly pass `undefined` to the
88
+ * `seedOrRNG` parameter.
89
+ *
84
90
  * In order to use this function, you must upgrade your mod with `ISCFeature.SPAWN_COLLECTIBLE`.
85
91
  *
86
92
  * @param itemPoolType The item pool to draw the collectible type from.
87
93
  * @param positionOrGridIndex The position or grid index to spawn the collectible at.
88
- * @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided,
89
- * the `RNG.Next` method will be called. Default is `getRandomSeed()`.
94
+ * @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
95
+ * `RNG.Next` method will be called. If `undefined` is provided, it will default
96
+ * to a random seed.
90
97
  * @param options Optional. Set to true to make the collectible a "There's Options" style
91
98
  * collectible. Default is false.
92
99
  * @param forceFreeItem Optional. Set to true to disable the logic that gives the item a price for
@@ -97,7 +104,7 @@ export class SpawnCollectible extends Feature {
97
104
  public spawnCollectibleFromPool(
98
105
  itemPoolType: ItemPoolType,
99
106
  positionOrGridIndex: Vector | int,
100
- seedOrRNG: Seed | RNG = getRandomSeed(),
107
+ seedOrRNG: Seed | RNG | undefined,
101
108
  options = false,
102
109
  forceFreeItem = false,
103
110
  spawner?: Entity,
@@ -28,7 +28,7 @@ import {
28
28
  } from "../../../functions/pickupsSpecific";
29
29
  import { fireProjectilesInCircle } from "../../../functions/projectiles";
30
30
  import { getRandom } from "../../../functions/random";
31
- import { getRandomSeed, isRNG, newRNG } from "../../../functions/rng";
31
+ import { isRNG, newRNG } from "../../../functions/rng";
32
32
  import { spawnCollectibleUnsafe } from "../../../functions/spawnCollectible";
33
33
  import { repeat } from "../../../functions/utils";
34
34
  import { getRandomVector, isVector } from "../../../functions/vector";
@@ -89,22 +89,26 @@ export class SpawnRockAltRewards extends Feature {
89
89
  * The logic in this function is based on the rewards listed on the wiki:
90
90
  * https://bindingofisaacrebirth.fandom.com/wiki/Rocks
91
91
  *
92
+ * If you want to spawn an unseeded reward, you must explicitly pass `undefined` to the
93
+ * `seedOrRNG` parameter.
94
+ *
92
95
  * In order to use this function, you must upgrade your mod with
93
96
  * `ISCFeature.SPAWN_ALT_ROCK_REWARDS`.
94
97
  *
95
98
  * @param positionOrGridIndex The position or grid index to spawn the reward.
96
99
  * @param rockAltType The type of reward to spawn. For example, `RockAltType.URN` will have a
97
100
  * chance at spawning coins and spiders.
98
- * @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided,
99
- * the `RNG.Next` method will be called. Default is `getRandomSeed()`. Normally,
100
- * you should pass the `InitSeed` of the grid entity that was broken.
101
+ * @param seedOrRNG The `Seed` or `RNG` object to use. Normally, you should pass the `InitSeed` of
102
+ * the grid entity that was broken. If an `RNG` object is provided, the
103
+ * `RNG.Next` method will be called. If `undefined` is provided, it will default
104
+ * to a random seed.
101
105
  * @returns Whether this function spawned something.
102
106
  */
103
107
  @Exported
104
108
  public spawnRockAltReward(
105
109
  positionOrGridIndex: Vector | int,
106
110
  rockAltType: RockAltType,
107
- seedOrRNG: Seed | RNG = getRandomSeed(),
111
+ seedOrRNG: Seed | RNG | undefined,
108
112
  ): boolean {
109
113
  const room = game.GetRoom();
110
114
  const position = isVector(positionOrGridIndex)
@@ -1,7 +1,6 @@
1
1
  import { sumArray } from "../../../../functions/array";
2
2
  import { log } from "../../../../functions/log";
3
3
  import { getRandomFloat } from "../../../../functions/random";
4
- import { getRandomSeed } from "../../../../functions/rng";
5
4
  import type {
6
5
  CustomStageBossPoolEntry,
7
6
  CustomStageRoomMetadata,
@@ -16,7 +15,7 @@ import type {
16
15
  */
17
16
  export function getRandomCustomStageRoom(
18
17
  roomsMetadata: readonly CustomStageRoomMetadata[],
19
- seedOrRNG: Seed | RNG = getRandomSeed(),
18
+ seedOrRNG: Seed | RNG | undefined,
20
19
  verbose = false,
21
20
  ): CustomStageRoomMetadata {
22
21
  const totalWeight = getTotalWeightOfCustomStageRooms(roomsMetadata);
@@ -59,7 +58,7 @@ function getCustomStageRoomWithChosenWeight(
59
58
  export function getRandomBossRoomFromPool(
60
59
  roomsMetadata: readonly CustomStageRoomMetadata[],
61
60
  bossPool: readonly CustomStageBossPoolEntry[],
62
- seedOrRNG: Seed | RNG = getRandomSeed(),
61
+ seedOrRNG: Seed | RNG | undefined,
63
62
  verbose = false,
64
63
  ): CustomStageRoomMetadata {
65
64
  const totalWeight = getTotalWeightOfBossPool(bossPool);
@@ -1470,7 +1470,7 @@ export function spawnCollectible(params: string): void {
1470
1470
 
1471
1471
  const roomClass = game.GetRoom();
1472
1472
  const centerPos = roomClass.GetCenterPos();
1473
- spawnCollectibleUnsafe(collectibleType, centerPos);
1473
+ spawnCollectibleUnsafe(collectibleType, centerPos, undefined);
1474
1474
  }
1475
1475
 
1476
1476
  /**
@@ -1515,7 +1515,7 @@ export function spawnCollectibleAt(params: string): void {
1515
1515
  }
1516
1516
 
1517
1517
  const collectibleType = asCollectibleType(collectibleTypeNumber);
1518
- spawnCollectibleUnsafe(collectibleType, gridIndex);
1518
+ spawnCollectibleUnsafe(collectibleType, gridIndex, undefined);
1519
1519
  }
1520
1520
 
1521
1521
  /** Alias for the `spawnGoldenTrinket` command. */
@@ -1,7 +1,7 @@
1
1
  import { ReadonlySet } from "../types/ReadonlySet";
2
2
  import type { WidenLiteral } from "../types/WidenLiteral";
3
3
  import { getRandomInt } from "./random";
4
- import { getRandomSeed, isRNG, newRNG } from "./rng";
4
+ import { isRNG, newRNG } from "./rng";
5
5
  import { isNumber, isTable } from "./types";
6
6
  import { assertDefined, eRange } from "./utils";
7
7
 
@@ -393,14 +393,18 @@ export function getLowestArrayElement(array: number[]): number | undefined {
393
393
  /**
394
394
  * Helper function to get a random element from the provided array.
395
395
  *
396
+ * If you want to get an unseeded element, you must explicitly pass `undefined` to the `seedOrRNG`
397
+ * parameter.
398
+ *
396
399
  * @param array The array to get an element from.
397
- * @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
398
- * `RNG.Next` method will be called. Default is `getRandomSeed()`.
400
+ * @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
401
+ * `RNG.Next` method will be called. If `undefined` is provided, it will default to
402
+ * a random seed.
399
403
  * @param exceptions Optional. An array of elements to skip over if selected.
400
404
  */
401
405
  export function getRandomArrayElement<T>(
402
406
  array: T[] | readonly T[],
403
- seedOrRNG: Seed | RNG = getRandomSeed(),
407
+ seedOrRNG: Seed | RNG | undefined,
404
408
  exceptions: T[] | readonly T[] = [],
405
409
  ): T {
406
410
  if (array.length === 0) {
@@ -425,14 +429,18 @@ export function getRandomArrayElement<T>(
425
429
  * Helper function to get a random element from the provided array. Once the random element is
426
430
  * decided, it is then removed from the array (in-place).
427
431
  *
432
+ * If you want to get an unseeded element, you must explicitly pass `undefined` to the `seedOrRNG`
433
+ * parameter.
434
+ *
428
435
  * @param array The array to get an element from.
429
- * @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
430
- * `RNG.Next` method will be called. Default is `getRandomSeed()`.
436
+ * @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
437
+ * `RNG.Next` method will be called. If `undefined` is provided, it will default to
438
+ * a random seed.
431
439
  * @param exceptions Optional. An array of elements to skip over if selected.
432
440
  */
433
441
  export function getRandomArrayElementAndRemove<T>(
434
442
  array: T[],
435
- seedOrRNG: Seed | RNG = getRandomSeed(),
443
+ seedOrRNG: Seed | RNG | undefined,
436
444
  exceptions: T[] | readonly T[] = [],
437
445
  ): T {
438
446
  const randomArrayElement = getRandomArrayElement(
@@ -447,15 +455,19 @@ export function getRandomArrayElementAndRemove<T>(
447
455
  /**
448
456
  * Helper function to get a random index from the provided array.
449
457
  *
458
+ * If you want to get an unseeded index, you must explicitly pass `undefined` to the `seedOrRNG`
459
+ * parameter.
460
+ *
450
461
  * @param array The array to get the index from.
451
- * @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
452
- * `RNG.Next` method will be called. Default is `getRandomSeed()`.
462
+ * @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
463
+ * `RNG.Next` method will be called. If `undefined` is provided, it will default to
464
+ * a random seed.
453
465
  * @param exceptions Optional. An array of indexes that will be skipped over when getting the random
454
466
  * index. Default is an empty array.
455
467
  */
456
468
  export function getRandomArrayIndex<T>(
457
469
  array: T[] | readonly T[],
458
- seedOrRNG: Seed | RNG = getRandomSeed(),
470
+ seedOrRNG: Seed | RNG | undefined,
459
471
  exceptions: int[] | readonly int[] = [],
460
472
  ): int {
461
473
  if (array.length === 0) {
@@ -570,15 +582,19 @@ export function setAllArrayElements<T>(array: T[], value: T): void {
570
582
  /**
571
583
  * Shallow copies and shuffles the array using the Fisher-Yates algorithm. Returns the copied array.
572
584
  *
585
+ * If you want an unseeded shuffle, you must explicitly pass `undefined` to the `seedOrRNG`
586
+ * parameter.
587
+ *
573
588
  * From: https://stackoverflow.com/questions/2450954/how-to-randomize-shuffle-a-javascript-array
574
589
  *
575
590
  * @param originalArray The array to shuffle.
576
- * @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
577
- * `RNG.Next` method will be called. Default is `getRandomSeed()`.
591
+ * @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
592
+ * `RNG.Next` method will be called. If `undefined` is provided, it will default to
593
+ * a random seed.
578
594
  */
579
595
  export function shuffleArray<T>(
580
596
  originalArray: T[] | readonly T[],
581
- seedOrRNG: Seed | RNG = getRandomSeed(),
597
+ seedOrRNG: Seed | RNG | undefined,
582
598
  ): T[] {
583
599
  const array = copyArray(originalArray);
584
600
  shuffleArrayInPlace(array, seedOrRNG);
@@ -589,15 +605,19 @@ export function shuffleArray<T>(
589
605
  /**
590
606
  * Shuffles the provided array in-place using the Fisher-Yates algorithm.
591
607
  *
608
+ * If you want an unseeded shuffle, you must explicitly pass `undefined` to the `seedOrRNG`
609
+ * parameter.
610
+ *
592
611
  * From: https://stackoverflow.com/questions/2450954/how-to-randomize-shuffle-a-javascript-array
593
612
  *
594
613
  * @param array The array to shuffle.
595
- * @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
596
- * `RNG.Next` method will be called. Default is `getRandomSeed()`.
614
+ * @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
615
+ * `RNG.Next` method will be called. If `undefined` is provided, it will default to
616
+ * a random seed.
597
617
  */
598
618
  export function shuffleArrayInPlace<T>(
599
619
  array: T[],
600
- seedOrRNG: Seed | RNG = getRandomSeed(),
620
+ seedOrRNG: Seed | RNG | undefined,
601
621
  ): void {
602
622
  let currentIndex = array.length;
603
623
 
@@ -2,7 +2,7 @@ import type { CopyableIsaacAPIClassType } from "isaac-typescript-definitions";
2
2
  import { SerializationBrand } from "../enums/private/SerializationBrand";
3
3
  import { isaacAPIClassEquals, isIsaacAPIClassOfType } from "./isaacAPIClass";
4
4
  import { getRandom } from "./random";
5
- import { getRandomSeed, isRNG, newRNG } from "./rng";
5
+ import { isRNG, newRNG } from "./rng";
6
6
  import {
7
7
  copyUserdataValuesToTable,
8
8
  getNumbersFromTable,
@@ -76,14 +76,18 @@ export function deserializeColor(color: SerializedColor): Color {
76
76
  }
77
77
 
78
78
  /**
79
- * Helper function to get a random color.
79
+ * Helper function to get a random `Color` object.
80
80
  *
81
- * @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
82
- * `RNG.Next` method will be called. Default is `getRandomSeed()`.
81
+ * If you want to generate an unseeded object, you must explicitly pass `undefined` to the
82
+ * `seedOrRNG` parameter.
83
+ *
84
+ * @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
85
+ * `RNG.Next` method will be called. If `undefined` is provided, it will default to
86
+ * a random seed.
83
87
  * @param alpha Optional. The alpha value to use. Default is 1.
84
88
  */
85
89
  export function getRandomColor(
86
- seedOrRNG: Seed | RNG = getRandomSeed(),
90
+ seedOrRNG: Seed | RNG | undefined,
87
91
  alpha = 1,
88
92
  ): Readonly<Color> {
89
93
  const rng = isRNG(seedOrRNG) ? seedOrRNG : newRNG(seedOrRNG);
@@ -1,6 +1,5 @@
1
1
  import { ReadonlySet } from "../types/ReadonlySet";
2
2
  import { getRandomArrayElement } from "./array";
3
- import { getRandomSeed } from "./rng";
4
3
  import { isNumber, isString } from "./types";
5
4
  import { assertDefined, iRange } from "./utils";
6
5
 
@@ -176,14 +175,17 @@ export function getLowestEnumValue<T>(transpiledEnum: T): T[keyof T] {
176
175
  /**
177
176
  * Helper function to get a random value from the provided enum.
178
177
  *
178
+ * If you want an unseeded value, you must explicitly pass `undefined` to the `seedOrRNG` parameter.
179
+ *
179
180
  * @param transpiledEnum The enum to get the value from.
180
- * @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
181
- * `RNG.Next` method will be called. Default is `getRandomSeed()`.
181
+ * @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
182
+ * `RNG.Next` method will be called. If `undefined` is provided, it will default to
183
+ * a random seed.
182
184
  * @param exceptions Optional. An array of elements to skip over if selected.
183
185
  */
184
186
  export function getRandomEnumValue<T>(
185
187
  transpiledEnum: T,
186
- seedOrRNG: Seed | RNG = getRandomSeed(),
188
+ seedOrRNG: Seed | RNG | undefined,
187
189
  exceptions: Array<T[keyof T]> | ReadonlyArray<T[keyof T]> = [],
188
190
  ): T[keyof T] {
189
191
  const enumValues = getEnumValues(transpiledEnum);
@@ -45,12 +45,21 @@ const GREED_MODE_ITEM_POOL_TYPES: readonly ItemPoolType[] = arrayRemove(
45
45
  * Helper function to get a random item pool. This is not as simple as getting a random value from
46
46
  * the `ItemPoolType` enum, since `ItemPoolType.SHELL_GAME` (7) is not a real item pool and the
47
47
  * Greed Mode item pools should be excluded if not playing in Greed Mode.
48
+ *
49
+ * If you want to get an unseeded item pool, you must explicitly pass `undefined` to the `seedOrRNG`
50
+ * parameter.
51
+ *
52
+ * @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
53
+ * `RNG.Next` method will be called. If `undefined` is provided, it will default to
54
+ * a random seed.
48
55
  */
49
- export function getRandomItemPool(): ItemPoolType {
56
+ export function getRandomItemPool(
57
+ seedOrRNG: Seed | RNG | undefined,
58
+ ): ItemPoolType {
50
59
  const itemPoolTypes = game.IsGreedMode()
51
60
  ? GREED_MODE_ITEM_POOL_TYPES
52
61
  : NORMAL_MODE_ITEM_POOL_TYPES;
53
- return getRandomArrayElement(itemPoolTypes);
62
+ return getRandomArrayElement(itemPoolTypes, seedOrRNG);
54
63
  }
55
64
 
56
65
  /**
@@ -7,7 +7,6 @@ import { isEnumValue } from "./enums";
7
7
  import { addFlag } from "./flag";
8
8
  import { log } from "./log";
9
9
  import { getRandomFloat } from "./random";
10
- import { getRandomSeed } from "./rng";
11
10
  import { assertDefined } from "./utils";
12
11
 
13
12
  /** This represents either a `JSONRoom` or a `JSONEntity`. */
@@ -141,15 +140,19 @@ export function getJSONRoomsOfSubType(
141
140
  * properly account for each room weight using the algorithm from:
142
141
  * https://stackoverflow.com/questions/1761626/weighted-random-numbers
143
142
  *
143
+ * If you want an unseeded entity, you must explicitly pass `undefined` to the `seedOrRNG`
144
+ * parameter.
145
+ *
144
146
  * @param jsonEntities The array of entities to randomly choose between.
145
- * @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
146
- * `RNG.Next` method will be called. Default is `getRandomSeed()`.
147
+ * @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
148
+ * `RNG.Next` method will be called. If `undefined` is provided, it will default to
149
+ * a random seed.
147
150
  * @param verbose Optional. If specified, will write entries to the "log.txt" file that describe
148
151
  * what the function is doing. Default is false.
149
152
  */
150
153
  export function getRandomJSONEntity(
151
154
  jsonEntities: JSONEntity[],
152
- seedOrRNG: Seed | RNG = getRandomSeed(),
155
+ seedOrRNG: Seed | RNG | undefined,
153
156
  verbose = false,
154
157
  ): JSONEntity {
155
158
  const totalWeight = getTotalWeightOfJSONObject(jsonEntities);
@@ -183,15 +186,18 @@ export function getRandomJSONEntity(
183
186
  * properly account for each room weight using the algorithm from:
184
187
  * https://stackoverflow.com/questions/1761626/weighted-random-numbers
185
188
  *
189
+ * If you want an unseeded room, you must explicitly pass `undefined` to the `seedOrRNG` parameter.
190
+ *
186
191
  * @param jsonRooms The array of rooms to randomly choose between.
187
- * @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
188
- * `RNG.Next` method will be called. Default is `getRandomSeed()`.
192
+ * @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
193
+ * `RNG.Next` method will be called. If `undefined` is provided, it will default to
194
+ * a random seed.
189
195
  * @param verbose Optional. If specified, will write entries to the "log.txt" file that describe
190
196
  * what the function is doing. Default is false.
191
197
  */
192
198
  export function getRandomJSONRoom(
193
199
  jsonRooms: JSONRoom[],
194
- seedOrRNG: Seed | RNG = getRandomSeed(),
200
+ seedOrRNG: Seed | RNG | undefined,
195
201
  verbose = false,
196
202
  ): JSONRoom {
197
203
  const totalWeight = getTotalWeightOfJSONObject(jsonRooms);
@@ -2,7 +2,7 @@ import type { CopyableIsaacAPIClassType } from "isaac-typescript-definitions";
2
2
  import { SerializationBrand } from "../enums/private/SerializationBrand";
3
3
  import { isaacAPIClassEquals, isIsaacAPIClassOfType } from "./isaacAPIClass";
4
4
  import { getRandom } from "./random";
5
- import { getRandomSeed, isRNG, newRNG } from "./rng";
5
+ import { isRNG, newRNG } from "./rng";
6
6
  import {
7
7
  copyUserdataValuesToTable,
8
8
  getNumbersFromTable,
@@ -64,14 +64,18 @@ export function deserializeKColor(kColor: SerializedKColor): KColor {
64
64
  }
65
65
 
66
66
  /**
67
- * Helper function to get a random color.
67
+ * Helper function to get a random `KColor` object (for use in fonts).
68
68
  *
69
- * @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
70
- * `RNG.Next` method will be called. Default is `getRandomSeed()`.
69
+ * If you want to generate an unseeded object, you must explicitly pass `undefined` to the
70
+ * `seedOrRNG` parameter.
71
+ *
72
+ * @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
73
+ * `RNG.Next` method will be called. If `undefined` is provided, it will default to
74
+ * a random seed.
71
75
  * @param alpha Optional. The alpha value to use. Default is 1.
72
76
  */
73
77
  export function getRandomKColor(
74
- seedOrRNG: Seed | RNG = getRandomSeed(),
78
+ seedOrRNG: Seed | RNG | undefined,
75
79
  alpha = 1,
76
80
  ): Readonly<KColor> {
77
81
  const rng = isRNG(seedOrRNG) ? seedOrRNG : newRNG(seedOrRNG);
@@ -25,7 +25,7 @@ import { getRandomArrayElement } from "./array";
25
25
  import { doorSlotToDoorSlotFlag } from "./doors";
26
26
  import { addFlag, hasFlag, removeFlag } from "./flag";
27
27
  import { copyMap } from "./map";
28
- import { getRandomSeed, isRNG, newRNG } from "./rng";
28
+ import { isRNG, newRNG } from "./rng";
29
29
  import {
30
30
  getRoomAllowedDoors,
31
31
  getRoomData,
@@ -126,8 +126,12 @@ export function getAllRoomGridIndexes(): readonly int[] {
126
126
  * some floors will not have any valid spots. If this is the case, this function will return
127
127
  * undefined.
128
128
  *
129
- * @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
130
- * `RNG.Next` method will be called. Default is `getRandomSeed()`.
129
+ * If you want to get an unseeded room, you must explicitly pass `undefined` to the `seedOrRNG`
130
+ * parameter.
131
+ *
132
+ * @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
133
+ * `RNG.Next` method will be called. If `undefined` is provided, it will default to
134
+ * a random seed.
131
135
  * @param ensureDeadEnd Optional. Whether to pick a valid dead end attached to a normal room. If
132
136
  * false, the function will randomly pick from any valid location that would
133
137
  * have a red door.
@@ -135,7 +139,7 @@ export function getAllRoomGridIndexes(): readonly int[] {
135
139
  * undefined.
136
140
  */
137
141
  export function getNewRoomCandidate(
138
- seedOrRNG: Seed | RNG = getRandomSeed(),
142
+ seedOrRNG: Seed | RNG | undefined,
139
143
  ensureDeadEnd = true,
140
144
  ):
141
145
  | {
@@ -521,9 +525,12 @@ export function isRoomInsideGrid(roomGridIndex?: int): boolean {
521
525
  /**
522
526
  * Helper function to generate a new room on the floor.
523
527
  *
528
+ * If you want to generate an unseeded room, you must explicitly pass `undefined` to the `seedOrRNG`
529
+ * parameter.
530
+ *
524
531
  * Under the hood, this function uses the `Level.MakeRedRoomDoor` method to create the room.
525
532
  *
526
- * @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
533
+ * @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
527
534
  * `RNG.Next` method will be called. Default is `Level.GetDungeonPlacementSeed`.
528
535
  * Note that the RNG is only used to select the random location to put the room on
529
536
  * the floor; it does not influence the randomly chosen room contents. (That is
@@ -538,7 +545,7 @@ export function isRoomInsideGrid(roomGridIndex?: int): boolean {
538
545
  * place a room.
539
546
  */
540
547
  export function newRoom(
541
- seedOrRNG?: Seed | RNG,
548
+ seedOrRNG: Seed | RNG | undefined,
542
549
  ensureDeadEnd = true,
543
550
  customRoomData?: RoomConfig,
544
551
  ): int | undefined {