isaacscript-common 71.2.1 → 72.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 (83) hide show
  1. package/dist/index.rollup.d.ts +229 -96
  2. package/dist/isaacscript-common.lua +13 -128
  3. package/dist/src/classes/callbacks/PostHolyMantleRemoved.d.ts.map +1 -1
  4. package/dist/src/classes/callbacks/PostHolyMantleRemoved.lua +3 -1
  5. package/dist/src/classes/features/other/CustomItemPools.d.ts +7 -3
  6. package/dist/src/classes/features/other/CustomItemPools.d.ts.map +1 -1
  7. package/dist/src/classes/features/other/CustomItemPools.lua +1 -6
  8. package/dist/src/classes/features/other/DeployJSONRoom.d.ts +7 -3
  9. package/dist/src/classes/features/other/DeployJSONRoom.d.ts.map +1 -1
  10. package/dist/src/classes/features/other/DeployJSONRoom.lua +1 -5
  11. package/dist/src/classes/features/other/ModdedElementSets.d.ts +35 -15
  12. package/dist/src/classes/features/other/ModdedElementSets.d.ts.map +1 -1
  13. package/dist/src/classes/features/other/ModdedElementSets.lua +0 -17
  14. package/dist/src/classes/features/other/SpawnCollectible.d.ts +14 -6
  15. package/dist/src/classes/features/other/SpawnCollectible.d.ts.map +1 -1
  16. package/dist/src/classes/features/other/SpawnCollectible.lua +0 -8
  17. package/dist/src/classes/features/other/SpawnRockAltRewards.d.ts +8 -4
  18. package/dist/src/classes/features/other/SpawnRockAltRewards.d.ts.map +1 -1
  19. package/dist/src/classes/features/other/SpawnRockAltRewards.lua +0 -4
  20. package/dist/src/classes/features/other/customStages/utils.d.ts +2 -2
  21. package/dist/src/classes/features/other/customStages/utils.d.ts.map +1 -1
  22. package/dist/src/classes/features/other/customStages/utils.lua +0 -8
  23. package/dist/src/classes/features/other/extraConsoleCommands/commands.lua +2 -2
  24. package/dist/src/functions/array.d.ts +35 -15
  25. package/dist/src/functions/array.d.ts.map +1 -1
  26. package/dist/src/functions/array.lua +30 -26
  27. package/dist/src/functions/color.d.ts +8 -4
  28. package/dist/src/functions/color.d.ts.map +1 -1
  29. package/dist/src/functions/color.lua +7 -7
  30. package/dist/src/functions/enums.d.ts +6 -3
  31. package/dist/src/functions/enums.d.ts.map +1 -1
  32. package/dist/src/functions/enums.lua +5 -7
  33. package/dist/src/functions/itemPool.d.ts +8 -1
  34. package/dist/src/functions/itemPool.d.ts.map +1 -1
  35. package/dist/src/functions/itemPool.lua +9 -2
  36. package/dist/src/functions/jsonRoom.d.ts +13 -6
  37. package/dist/src/functions/jsonRoom.d.ts.map +1 -1
  38. package/dist/src/functions/jsonRoom.lua +11 -12
  39. package/dist/src/functions/kColor.d.ts +8 -4
  40. package/dist/src/functions/kColor.d.ts.map +1 -1
  41. package/dist/src/functions/kColor.lua +7 -7
  42. package/dist/src/functions/levelGrid.d.ts +12 -5
  43. package/dist/src/functions/levelGrid.d.ts.map +1 -1
  44. package/dist/src/functions/levelGrid.lua +10 -7
  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/callbacks/PostHolyMantleRemoved.ts +6 -1
  64. package/src/classes/features/other/CustomItemPools.ts +7 -4
  65. package/src/classes/features/other/DeployJSONRoom.ts +9 -5
  66. package/src/classes/features/other/ModdedElementSets.ts +37 -16
  67. package/src/classes/features/other/SpawnCollectible.ts +14 -7
  68. package/src/classes/features/other/SpawnRockAltRewards.ts +9 -5
  69. package/src/classes/features/other/customStages/utils.ts +2 -3
  70. package/src/classes/features/other/extraConsoleCommands/commands.ts +2 -2
  71. package/src/functions/array.ts +36 -16
  72. package/src/functions/color.ts +9 -5
  73. package/src/functions/enums.ts +6 -4
  74. package/src/functions/itemPool.ts +11 -2
  75. package/src/functions/jsonRoom.ts +13 -7
  76. package/src/functions/kColor.ts +9 -5
  77. package/src/functions/levelGrid.ts +13 -6
  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
@@ -1,17 +1,24 @@
1
1
  import type { WeightedArray } from "../types/WeightedArray";
2
2
  import { sumArray } from "./array";
3
3
  import { getRandomFloat } from "./random";
4
- import { getRandomSeed } from "./rng";
5
4
  import { assertDefined } from "./utils";
6
5
 
7
6
  /**
8
7
  * Get a random value from a `WeightedArray`. (A `WeightedArray` is an array of tuples, where the
9
8
  * first element in the tuple is a value, and the second element in the tuple is a float
10
9
  * corresponding to the value's weight.)
10
+ *
11
+ * If you want to get an unseeded element, you must explicitly pass `undefined` to the `seedOrRNG`
12
+ * parameter.
13
+ *
14
+ * @param weightedArray The array to pick from.
15
+ * @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
16
+ * `RNG.Next` method will be called. If `undefined` is provided, it will default to
17
+ * a random seed.
11
18
  */
12
19
  export function getRandomFromWeightedArray<T>(
13
20
  weightedArray: WeightedArray<T>,
14
- seedOrRNG: Seed | RNG = getRandomSeed(),
21
+ seedOrRNG: Seed | RNG | undefined,
15
22
  ): T {
16
23
  const randomIndex = getRandomIndexFromWeightedArray(weightedArray, seedOrRNG);
17
24
 
@@ -28,10 +35,18 @@ export function getRandomFromWeightedArray<T>(
28
35
  * Get a random index from a `WeightedArray`. (A `WeightedArray` is an array of tuples, where the
29
36
  * first element in the tuple is a value, and the second element in the tuple is a float
30
37
  * corresponding to the value's weight.)
38
+ *
39
+ * If you want to get an unseeded index, you must explicitly pass `undefined` to the `seedOrRNG`
40
+ * parameter.
41
+ *
42
+ * @param weightedArray The array to pick from.
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 to
45
+ * a random seed.
31
46
  */
32
47
  export function getRandomIndexFromWeightedArray<T>(
33
48
  weightedArray: WeightedArray<T>,
34
- seedOrRNG: Seed | RNG = getRandomSeed(),
49
+ seedOrRNG: Seed | RNG | undefined,
35
50
  ): int {
36
51
  if (weightedArray.length === 0) {
37
52
  error(