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.
- package/dist/index.rollup.d.ts +229 -96
- package/dist/isaacscript-common.lua +40 -154
- package/dist/src/classes/features/other/CustomItemPools.d.ts +7 -3
- package/dist/src/classes/features/other/CustomItemPools.d.ts.map +1 -1
- package/dist/src/classes/features/other/CustomItemPools.lua +1 -6
- package/dist/src/classes/features/other/DeployJSONRoom.d.ts +7 -3
- package/dist/src/classes/features/other/DeployJSONRoom.d.ts.map +1 -1
- package/dist/src/classes/features/other/DeployJSONRoom.lua +1 -5
- package/dist/src/classes/features/other/ModdedElementSets.d.ts +35 -15
- package/dist/src/classes/features/other/ModdedElementSets.d.ts.map +1 -1
- package/dist/src/classes/features/other/ModdedElementSets.lua +0 -17
- package/dist/src/classes/features/other/SpawnCollectible.d.ts +14 -6
- package/dist/src/classes/features/other/SpawnCollectible.d.ts.map +1 -1
- package/dist/src/classes/features/other/SpawnCollectible.lua +0 -8
- package/dist/src/classes/features/other/SpawnRockAltRewards.d.ts +8 -4
- package/dist/src/classes/features/other/SpawnRockAltRewards.d.ts.map +1 -1
- package/dist/src/classes/features/other/SpawnRockAltRewards.lua +0 -4
- package/dist/src/classes/features/other/customStages/utils.d.ts +2 -2
- package/dist/src/classes/features/other/customStages/utils.d.ts.map +1 -1
- package/dist/src/classes/features/other/customStages/utils.lua +0 -8
- package/dist/src/classes/features/other/extraConsoleCommands/commands.lua +2 -2
- package/dist/src/functions/array.d.ts +35 -15
- package/dist/src/functions/array.d.ts.map +1 -1
- package/dist/src/functions/array.lua +30 -26
- package/dist/src/functions/color.d.ts +8 -4
- package/dist/src/functions/color.d.ts.map +1 -1
- package/dist/src/functions/color.lua +7 -7
- package/dist/src/functions/enums.d.ts +6 -3
- package/dist/src/functions/enums.d.ts.map +1 -1
- package/dist/src/functions/enums.lua +5 -7
- package/dist/src/functions/itemPool.d.ts +8 -1
- package/dist/src/functions/itemPool.d.ts.map +1 -1
- package/dist/src/functions/itemPool.lua +9 -2
- package/dist/src/functions/jsonRoom.d.ts +13 -6
- package/dist/src/functions/jsonRoom.d.ts.map +1 -1
- package/dist/src/functions/jsonRoom.lua +11 -12
- package/dist/src/functions/kColor.d.ts +8 -4
- package/dist/src/functions/kColor.d.ts.map +1 -1
- package/dist/src/functions/kColor.lua +7 -7
- package/dist/src/functions/levelGrid.d.ts +12 -5
- package/dist/src/functions/levelGrid.d.ts.map +1 -1
- package/dist/src/functions/levelGrid.lua +10 -7
- package/dist/src/functions/nextStage.d.ts.map +1 -1
- package/dist/src/functions/nextStage.lua +4 -1
- package/dist/src/functions/random.d.ts +22 -13
- package/dist/src/functions/random.d.ts.map +1 -1
- package/dist/src/functions/random.lua +19 -20
- package/dist/src/functions/rng.d.ts +1 -1
- package/dist/src/functions/rng.lua +1 -1
- package/dist/src/functions/set.d.ts +7 -3
- package/dist/src/functions/set.d.ts.map +1 -1
- package/dist/src/functions/set.lua +6 -7
- package/dist/src/functions/spawnCollectible.d.ts +13 -5
- package/dist/src/functions/spawnCollectible.d.ts.map +1 -1
- package/dist/src/functions/spawnCollectible.lua +14 -9
- package/dist/src/functions/vector.d.ts +7 -3
- package/dist/src/functions/vector.d.ts.map +1 -1
- package/dist/src/functions/vector.lua +6 -6
- package/dist/src/functions/weighted.d.ts +18 -2
- package/dist/src/functions/weighted.d.ts.map +1 -1
- package/dist/src/functions/weighted.lua +16 -8
- package/package.json +1 -1
- package/src/classes/features/other/CustomItemPools.ts +7 -4
- package/src/classes/features/other/DeployJSONRoom.ts +9 -5
- package/src/classes/features/other/ModdedElementSets.ts +37 -16
- package/src/classes/features/other/SpawnCollectible.ts +14 -7
- package/src/classes/features/other/SpawnRockAltRewards.ts +9 -5
- package/src/classes/features/other/customStages/utils.ts +2 -3
- package/src/classes/features/other/extraConsoleCommands/commands.ts +2 -2
- package/src/functions/array.ts +36 -16
- package/src/functions/color.ts +9 -5
- package/src/functions/enums.ts +6 -4
- package/src/functions/itemPool.ts +11 -2
- package/src/functions/jsonRoom.ts +13 -7
- package/src/functions/kColor.ts +9 -5
- package/src/functions/levelGrid.ts +13 -6
- package/src/functions/nextStage.ts +6 -1
- package/src/functions/random.ts +23 -14
- package/src/functions/rng.ts +1 -1
- package/src/functions/set.ts +7 -4
- package/src/functions/spawnCollectible.ts +17 -5
- package/src/functions/vector.ts +8 -4
- package/src/functions/weighted.ts +18 -3
|
@@ -5,45 +5,54 @@
|
|
|
5
5
|
* Returns a random float between 0 and 1. It is inclusive on the low end, but exclusive on the high
|
|
6
6
|
* end. (This is because the `RNG.RandomFloat` method will never return a value of exactly 1.)
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
8
|
+
* If you want to generate an unseeded number, you must explicitly pass `undefined` to the
|
|
9
|
+
* `seedOrRNG` parameter.
|
|
10
|
+
*
|
|
11
|
+
* @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
12
|
+
* `RNG.Next` method will be called. If `undefined` is provided, it will default to
|
|
13
|
+
* a random seed.
|
|
10
14
|
*/
|
|
11
|
-
export declare function getRandom(seedOrRNG
|
|
15
|
+
export declare function getRandom(seedOrRNG: Seed | RNG | undefined): float;
|
|
12
16
|
/**
|
|
13
17
|
* Returns a random float between min and max.
|
|
14
18
|
*
|
|
15
19
|
* For example:
|
|
16
20
|
*
|
|
17
21
|
* ```ts
|
|
18
|
-
* const realNumberBetweenOneAndThree = getRandomFloat(1, 3);
|
|
22
|
+
* const realNumberBetweenOneAndThree = getRandomFloat(1, 3, undefined);
|
|
19
23
|
* ```
|
|
20
24
|
*
|
|
25
|
+
* If you want to generate an unseeded number, you must explicitly pass `undefined` to the
|
|
26
|
+
* `seedOrRNG` parameter.
|
|
27
|
+
*
|
|
21
28
|
* @param min The lower bound for the random number (inclusive).
|
|
22
29
|
* @param max The upper bound for the random number (exclusive).
|
|
23
|
-
* @param seedOrRNG
|
|
24
|
-
* `RNG.Next` method will be called.
|
|
30
|
+
* @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
31
|
+
* `RNG.Next` method will be called. If `undefined` is provided, it will default to
|
|
32
|
+
* a random seed.
|
|
25
33
|
*/
|
|
26
|
-
export declare function getRandomFloat(min: int, max: int, seedOrRNG
|
|
34
|
+
export declare function getRandomFloat(min: int, max: int, seedOrRNG: Seed | RNG | undefined): float;
|
|
27
35
|
/**
|
|
28
36
|
* Returns a random integer between min and max. It is inclusive on both ends.
|
|
29
37
|
*
|
|
30
|
-
* Note that this function will run the `Next` method on the `RNG` object before returning the
|
|
31
|
-
* random number.
|
|
32
|
-
*
|
|
33
38
|
* For example:
|
|
34
39
|
*
|
|
35
40
|
* ```ts
|
|
36
41
|
* const oneTwoOrThree = getRandomInt(1, 3);
|
|
37
42
|
* ```
|
|
38
43
|
*
|
|
44
|
+
* If you want to generate an unseeded number, you must explicitly pass `undefined` to the
|
|
45
|
+
* `seedOrRNG` parameter.
|
|
46
|
+
*
|
|
39
47
|
* @param min The lower bound for the random number (inclusive).
|
|
40
48
|
* @param max The upper bound for the random number (inclusive).
|
|
41
|
-
* @param seedOrRNG
|
|
42
|
-
* `RNG.Next` method will be called.
|
|
49
|
+
* @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
50
|
+
* `RNG.Next` method will be called. If `undefined` is provided, it will default to
|
|
51
|
+
* a random seed.
|
|
43
52
|
* @param exceptions Optional. An array of elements that will be skipped over when getting the
|
|
44
53
|
* random integer. For example, a min of 1, a max of 4, and an exceptions array of
|
|
45
54
|
* `[2]` would cause the function to return either 1, 3, or 4. Default is an empty
|
|
46
55
|
* array.
|
|
47
56
|
*/
|
|
48
|
-
export declare function getRandomInt(min: int, max: int, seedOrRNG
|
|
57
|
+
export declare function getRandomInt(min: int, max: int, seedOrRNG: Seed | RNG | undefined, exceptions?: int[] | readonly int[]): int;
|
|
49
58
|
//# sourceMappingURL=random.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"random.d.ts","sourceRoot":"","sources":["../../../src/functions/random.ts"],"names":[],"mappings":";;;AAGA
|
|
1
|
+
{"version":3,"file":"random.d.ts","sourceRoot":"","sources":["../../../src/functions/random.ts"],"names":[],"mappings":";;;AAGA;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,SAAS,EAAE,IAAI,GAAG,GAAG,GAAG,SAAS,GAAG,KAAK,CAGlE;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,IAAI,GAAG,GAAG,GAAG,SAAS,GAChC,KAAK,CAUP;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,IAAI,GAAG,GAAG,GAAG,SAAS,EACjC,UAAU,GAAE,GAAG,EAAE,GAAG,SAAS,GAAG,EAAO,GACtC,GAAG,CAqBL"}
|
|
@@ -4,18 +4,18 @@ local ____exports = {}
|
|
|
4
4
|
local ____ReadonlySet = require("src.types.ReadonlySet")
|
|
5
5
|
local ReadonlySet = ____ReadonlySet.ReadonlySet
|
|
6
6
|
local ____rng = require("src.functions.rng")
|
|
7
|
-
local getRandomSeed = ____rng.getRandomSeed
|
|
8
7
|
local isRNG = ____rng.isRNG
|
|
9
8
|
local newRNG = ____rng.newRNG
|
|
10
9
|
--- Returns a random float between 0 and 1. It is inclusive on the low end, but exclusive on the high
|
|
11
10
|
-- end. (This is because the `RNG.RandomFloat` method will never return a value of exactly 1.)
|
|
12
11
|
--
|
|
13
|
-
--
|
|
14
|
-
-- `
|
|
12
|
+
-- If you want to generate an unseeded number, you must explicitly pass `undefined` to the
|
|
13
|
+
-- `seedOrRNG` parameter.
|
|
14
|
+
--
|
|
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.
|
|
15
18
|
function ____exports.getRandom(self, seedOrRNG)
|
|
16
|
-
if seedOrRNG == nil then
|
|
17
|
-
seedOrRNG = getRandomSeed(nil)
|
|
18
|
-
end
|
|
19
19
|
local rng = isRNG(nil, seedOrRNG) and seedOrRNG or newRNG(nil, seedOrRNG)
|
|
20
20
|
return rng:RandomFloat()
|
|
21
21
|
end
|
|
@@ -24,17 +24,18 @@ end
|
|
|
24
24
|
-- For example:
|
|
25
25
|
--
|
|
26
26
|
-- ```ts
|
|
27
|
-
-- const realNumberBetweenOneAndThree = getRandomFloat(1, 3);
|
|
27
|
+
-- const realNumberBetweenOneAndThree = getRandomFloat(1, 3, undefined);
|
|
28
28
|
-- ```
|
|
29
29
|
--
|
|
30
|
+
-- If you want to generate an unseeded number, you must explicitly pass `undefined` to the
|
|
31
|
+
-- `seedOrRNG` parameter.
|
|
32
|
+
--
|
|
30
33
|
-- @param min The lower bound for the random number (inclusive).
|
|
31
34
|
-- @param max The upper bound for the random number (exclusive).
|
|
32
|
-
-- @param seedOrRNG
|
|
33
|
-
-- `RNG.Next` method will be called.
|
|
35
|
+
-- @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
36
|
+
-- `RNG.Next` method will be called. If `undefined` is provided, it will default to
|
|
37
|
+
-- a random seed.
|
|
34
38
|
function ____exports.getRandomFloat(self, min, max, seedOrRNG)
|
|
35
|
-
if seedOrRNG == nil then
|
|
36
|
-
seedOrRNG = getRandomSeed(nil)
|
|
37
|
-
end
|
|
38
39
|
if min > max then
|
|
39
40
|
local oldMin = min
|
|
40
41
|
local oldMax = max
|
|
@@ -45,27 +46,25 @@ function ____exports.getRandomFloat(self, min, max, seedOrRNG)
|
|
|
45
46
|
end
|
|
46
47
|
--- Returns a random integer between min and max. It is inclusive on both ends.
|
|
47
48
|
--
|
|
48
|
-
-- Note that this function will run the `Next` method on the `RNG` object before returning the
|
|
49
|
-
-- random number.
|
|
50
|
-
--
|
|
51
49
|
-- For example:
|
|
52
50
|
--
|
|
53
51
|
-- ```ts
|
|
54
52
|
-- const oneTwoOrThree = getRandomInt(1, 3);
|
|
55
53
|
-- ```
|
|
56
54
|
--
|
|
55
|
+
-- If you want to generate an unseeded number, you must explicitly pass `undefined` to the
|
|
56
|
+
-- `seedOrRNG` parameter.
|
|
57
|
+
--
|
|
57
58
|
-- @param min The lower bound for the random number (inclusive).
|
|
58
59
|
-- @param max The upper bound for the random number (inclusive).
|
|
59
|
-
-- @param seedOrRNG
|
|
60
|
-
-- `RNG.Next` method will be called.
|
|
60
|
+
-- @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
61
|
+
-- `RNG.Next` method will be called. If `undefined` is provided, it will default to
|
|
62
|
+
-- a random seed.
|
|
61
63
|
-- @param exceptions Optional. An array of elements that will be skipped over when getting the
|
|
62
64
|
-- random integer. For example, a min of 1, a max of 4, and an exceptions array of
|
|
63
65
|
-- `[2]` would cause the function to return either 1, 3, or 4. Default is an empty
|
|
64
66
|
-- array.
|
|
65
67
|
function ____exports.getRandomInt(self, min, max, seedOrRNG, exceptions)
|
|
66
|
-
if seedOrRNG == nil then
|
|
67
|
-
seedOrRNG = getRandomSeed(nil)
|
|
68
|
-
end
|
|
69
68
|
if exceptions == nil then
|
|
70
69
|
exceptions = {}
|
|
71
70
|
end
|
|
@@ -27,7 +27,7 @@ export declare function isSerializedRNG(object: unknown): object is SerializedRN
|
|
|
27
27
|
/**
|
|
28
28
|
* Helper function to initialize a new RNG object using Blade's recommended shift index.
|
|
29
29
|
*
|
|
30
|
-
* @param seed The seed to initialize it with. Default is
|
|
30
|
+
* @param seed Optional. The seed to initialize it with. Default is a random seed.
|
|
31
31
|
*/
|
|
32
32
|
export declare function newRNG(seed?: Seed): RNG;
|
|
33
33
|
export declare function rngEquals(rng1: RNG, rng2: RNG): boolean;
|
|
@@ -32,7 +32,7 @@ function ____exports.isRNG(self, object)
|
|
|
32
32
|
end
|
|
33
33
|
--- Helper function to initialize a new RNG object using Blade's recommended shift index.
|
|
34
34
|
--
|
|
35
|
-
-- @param seed The seed to initialize it with. Default is
|
|
35
|
+
-- @param seed Optional. The seed to initialize it with. Default is a random seed.
|
|
36
36
|
function ____exports.newRNG(self, seed)
|
|
37
37
|
if seed == nil then
|
|
38
38
|
seed = ____exports.getRandomSeed(nil)
|
|
@@ -25,12 +25,16 @@ export declare function deleteSetsFromSet<T>(mainSet: Set<T>, ...setsToRemove: A
|
|
|
25
25
|
/**
|
|
26
26
|
* Helper function to get a random element from the provided set.
|
|
27
27
|
*
|
|
28
|
+
* If you want to get an unseeded element, you must explicitly pass `undefined` to the `seedOrRNG`
|
|
29
|
+
* parameter.
|
|
30
|
+
*
|
|
28
31
|
* @param set The set to get an element from.
|
|
29
|
-
* @param seedOrRNG
|
|
30
|
-
* `RNG.Next` method will be called.
|
|
32
|
+
* @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
33
|
+
* `RNG.Next` method will be called. If `undefined` is provided, it will default to
|
|
34
|
+
* a random seed.
|
|
31
35
|
* @param exceptions Optional. An array of elements to skip over if selected.
|
|
32
36
|
*/
|
|
33
|
-
export declare function getRandomSetElement<T>(set: Set<T> | ReadonlySet<T>, seedOrRNG
|
|
37
|
+
export declare function getRandomSetElement<T>(set: Set<T> | ReadonlySet<T>, seedOrRNG: Seed | RNG | undefined, exceptions?: T[] | readonly T[]): T;
|
|
34
38
|
/**
|
|
35
39
|
* Helper function to get all possible combinations of the given set. This includes the combination
|
|
36
40
|
* of an empty set.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set.d.ts","sourceRoot":"","sources":["../../../src/functions/set.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"set.d.ts","sourceRoot":"","sources":["../../../src/functions/set.ts"],"names":[],"mappings":";;AAIA;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAC5B,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,EACf,GAAG,SAAS,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,GAC3C,IAAI,CAMN;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,GAAG,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,GACtC,GAAG,CAAC,CAAC,CAAC,CASR;AAED,mGAAmG;AACnG,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAOlE;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,EACf,GAAG,YAAY,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,GAC9C,IAAI,CAMN;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EACnC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,EAC5B,SAAS,EAAE,IAAI,GAAG,GAAG,GAAG,SAAS,EACjC,UAAU,GAAE,CAAC,EAAE,GAAG,SAAS,CAAC,EAAO,GAClC,CAAC,CAGH;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,EAC5B,iBAAiB,EAAE,OAAO,GACzB,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAK/B;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAkBvE;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,QAAQ,EAAE,CAAC,EAAE,GAAG,IAAI,CAI7D;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,CAAC,EACtB,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,EAC5B,GAAG,QAAQ,EAAE,CAAC,EAAE,GACf,OAAO,CAET;AAED,4DAA4D;AAC5D,wBAAgB,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,GAAG,MAAM,CAGrE"}
|
|
@@ -13,8 +13,6 @@ local ____array = require("src.functions.array")
|
|
|
13
13
|
local getArrayCombinations = ____array.getArrayCombinations
|
|
14
14
|
local getRandomArrayElement = ____array.getRandomArrayElement
|
|
15
15
|
local sumArray = ____array.sumArray
|
|
16
|
-
local ____rng = require("src.functions.rng")
|
|
17
|
-
local getRandomSeed = ____rng.getRandomSeed
|
|
18
16
|
local ____types = require("src.functions.types")
|
|
19
17
|
local isPrimitive = ____types.isPrimitive
|
|
20
18
|
--- Helper function to get a sorted array based on the contents of a set.
|
|
@@ -81,14 +79,15 @@ function ____exports.deleteSetsFromSet(self, mainSet, ...)
|
|
|
81
79
|
end
|
|
82
80
|
--- Helper function to get a random element from the provided set.
|
|
83
81
|
--
|
|
82
|
+
-- If you want to get an unseeded element, you must explicitly pass `undefined` to the `seedOrRNG`
|
|
83
|
+
-- parameter.
|
|
84
|
+
--
|
|
84
85
|
-- @param set The set to get an element from.
|
|
85
|
-
-- @param seedOrRNG
|
|
86
|
-
-- `RNG.Next` method will be called.
|
|
86
|
+
-- @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
87
|
+
-- `RNG.Next` method will be called. If `undefined` is provided, it will default to
|
|
88
|
+
-- a random seed.
|
|
87
89
|
-- @param exceptions Optional. An array of elements to skip over if selected.
|
|
88
90
|
function ____exports.getRandomSetElement(self, set, seedOrRNG, exceptions)
|
|
89
|
-
if seedOrRNG == nil then
|
|
90
|
-
seedOrRNG = getRandomSeed(nil)
|
|
91
|
-
end
|
|
92
91
|
if exceptions == nil then
|
|
93
92
|
exceptions = {}
|
|
94
93
|
end
|
|
@@ -9,17 +9,21 @@ import { CollectibleType } from "isaac-typescript-definitions";
|
|
|
9
9
|
* Isaac's rotation mechanic. To handle that, use the `spawnCollectible` helper function instead
|
|
10
10
|
* (which is provided by `ISCFeature.SPAWN_COLLECTIBLE`).
|
|
11
11
|
*
|
|
12
|
+
* If you want to spawn an unseeded collectible, you must explicitly pass `undefined` to the
|
|
13
|
+
* `seedOrRNG` parameter.
|
|
14
|
+
*
|
|
12
15
|
* @param collectibleType The collectible type to spawn.
|
|
13
16
|
* @param positionOrGridIndex The position or grid index to spawn the collectible at.
|
|
14
|
-
* @param seedOrRNG
|
|
15
|
-
* `RNG.Next` method will be called.
|
|
17
|
+
* @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
18
|
+
* `RNG.Next` method will be called. If `undefined` is provided, it will default to
|
|
19
|
+
* a random seed.
|
|
16
20
|
* @param options Optional. Set to true to make the collectible a "There's Options" style
|
|
17
21
|
* collectible. Default is false.
|
|
18
22
|
* @param forceFreeItem Optional. Set to true to disable the logic that gives the item a price for
|
|
19
23
|
* Tainted Keeper. Default is false.
|
|
20
24
|
* @param spawner Optional.
|
|
21
25
|
*/
|
|
22
|
-
export declare function spawnCollectibleUnsafe(collectibleType: CollectibleType, positionOrGridIndex: Vector | int, seedOrRNG
|
|
26
|
+
export declare function spawnCollectibleUnsafe(collectibleType: CollectibleType, positionOrGridIndex: Vector | int, seedOrRNG: Seed | RNG | undefined, options?: boolean, forceFreeItem?: boolean, spawner?: Entity): EntityPickupCollectible;
|
|
23
27
|
/**
|
|
24
28
|
* Helper function to spawn an empty collectible. Doing this is tricky since spawning a collectible
|
|
25
29
|
* with `CollectibleType.NULL` will result in spawning a collectible with a random type from the
|
|
@@ -30,9 +34,13 @@ export declare function spawnCollectibleUnsafe(collectibleType: CollectibleType,
|
|
|
30
34
|
* Onion because it is a quest collectible and quest collectibles will prevent Damocles from
|
|
31
35
|
* duplicating the pedestal.)
|
|
32
36
|
*
|
|
37
|
+
* If you want to spawn an unseeded collectible, you must explicitly pass `undefined` to the
|
|
38
|
+
* `seedOrRNG` parameter.
|
|
39
|
+
*
|
|
33
40
|
* @param positionOrGridIndex The position or grid index to spawn the empty collectible at.
|
|
34
41
|
* @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
35
|
-
* `RNG.Next` method will be called.
|
|
42
|
+
* `RNG.Next` method will be called. If `undefined` is provided, it will default to
|
|
43
|
+
* a random seed.
|
|
36
44
|
*/
|
|
37
|
-
export declare function spawnEmptyCollectible(positionOrGridIndex: Vector | int, seedOrRNG
|
|
45
|
+
export declare function spawnEmptyCollectible(positionOrGridIndex: Vector | int, seedOrRNG: Seed | RNG | undefined): EntityPickup;
|
|
38
46
|
//# sourceMappingURL=spawnCollectible.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spawnCollectible.d.ts","sourceRoot":"","sources":["../../../src/functions/spawnCollectible.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAGhB,MAAM,8BAA8B,CAAC;AAQtC
|
|
1
|
+
{"version":3,"file":"spawnCollectible.d.ts","sourceRoot":"","sources":["../../../src/functions/spawnCollectible.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAGhB,MAAM,8BAA8B,CAAC;AAQtC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,sBAAsB,CACpC,eAAe,EAAE,eAAe,EAChC,mBAAmB,EAAE,MAAM,GAAG,GAAG,EACjC,SAAS,EAAE,IAAI,GAAG,GAAG,GAAG,SAAS,EACjC,OAAO,UAAQ,EACf,aAAa,UAAQ,EACrB,OAAO,CAAC,EAAE,MAAM,GACf,uBAAuB,CAqCzB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,qBAAqB,CACnC,mBAAmB,EAAE,MAAM,GAAG,GAAG,EACjC,SAAS,EAAE,IAAI,GAAG,GAAG,GAAG,SAAS,GAChC,YAAY,CAWd"}
|
|
@@ -25,25 +25,29 @@ local isRNG = ____rng.isRNG
|
|
|
25
25
|
-- Isaac's rotation mechanic. To handle that, use the `spawnCollectible` helper function instead
|
|
26
26
|
-- (which is provided by `ISCFeature.SPAWN_COLLECTIBLE`).
|
|
27
27
|
--
|
|
28
|
+
-- If you want to spawn an unseeded collectible, you must explicitly pass `undefined` to the
|
|
29
|
+
-- `seedOrRNG` parameter.
|
|
30
|
+
--
|
|
28
31
|
-- @param collectibleType The collectible type to spawn.
|
|
29
32
|
-- @param positionOrGridIndex The position or grid index to spawn the collectible at.
|
|
30
|
-
-- @param seedOrRNG
|
|
31
|
-
-- `RNG.Next` method will be called.
|
|
33
|
+
-- @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
34
|
+
-- `RNG.Next` method will be called. If `undefined` is provided, it will default to
|
|
35
|
+
-- a random seed.
|
|
32
36
|
-- @param options Optional. Set to true to make the collectible a "There's Options" style
|
|
33
37
|
-- collectible. Default is false.
|
|
34
38
|
-- @param forceFreeItem Optional. Set to true to disable the logic that gives the item a price for
|
|
35
39
|
-- Tainted Keeper. Default is false.
|
|
36
40
|
-- @param spawner Optional.
|
|
37
41
|
function ____exports.spawnCollectibleUnsafe(self, collectibleType, positionOrGridIndex, seedOrRNG, options, forceFreeItem, spawner)
|
|
38
|
-
if seedOrRNG == nil then
|
|
39
|
-
seedOrRNG = getRandomSeed(nil)
|
|
40
|
-
end
|
|
41
42
|
if options == nil then
|
|
42
43
|
options = false
|
|
43
44
|
end
|
|
44
45
|
if forceFreeItem == nil then
|
|
45
46
|
forceFreeItem = false
|
|
46
47
|
end
|
|
48
|
+
if seedOrRNG == nil then
|
|
49
|
+
seedOrRNG = getRandomSeed(nil)
|
|
50
|
+
end
|
|
47
51
|
local seed = isRNG(nil, seedOrRNG) and seedOrRNG:Next() or seedOrRNG
|
|
48
52
|
local collectible = spawnPickupWithSeed(
|
|
49
53
|
nil,
|
|
@@ -72,13 +76,14 @@ end
|
|
|
72
76
|
-- Onion because it is a quest collectible and quest collectibles will prevent Damocles from
|
|
73
77
|
-- duplicating the pedestal.)
|
|
74
78
|
--
|
|
79
|
+
-- If you want to spawn an unseeded collectible, you must explicitly pass `undefined` to the
|
|
80
|
+
-- `seedOrRNG` parameter.
|
|
81
|
+
--
|
|
75
82
|
-- @param positionOrGridIndex The position or grid index to spawn the empty collectible at.
|
|
76
83
|
-- @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
77
|
-
-- `RNG.Next` method will be called.
|
|
84
|
+
-- `RNG.Next` method will be called. If `undefined` is provided, it will default to
|
|
85
|
+
-- a random seed.
|
|
78
86
|
function ____exports.spawnEmptyCollectible(self, positionOrGridIndex, seedOrRNG)
|
|
79
|
-
if seedOrRNG == nil then
|
|
80
|
-
seedOrRNG = getRandomSeed(nil)
|
|
81
|
-
end
|
|
82
87
|
local collectible = ____exports.spawnCollectibleUnsafe(
|
|
83
88
|
nil,
|
|
84
89
|
CollectibleType.BROKEN_SHOVEL_1,
|
|
@@ -38,10 +38,14 @@ export declare function getClosestVectorTo(referenceVector: Vector, vectors: Vec
|
|
|
38
38
|
*
|
|
39
39
|
* Use this over the `RandomVector` function when you need the vector to be seeded.
|
|
40
40
|
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
41
|
+
* If you want to generate an unseeded vector, you must explicitly pass `undefined` to the
|
|
42
|
+
* `seedOrRNG` parameter.
|
|
43
|
+
*
|
|
44
|
+
* @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
45
|
+
* `RNG.Next` method will be called. If `undefined` is provided, it will default to
|
|
46
|
+
* a random seed.
|
|
43
47
|
*/
|
|
44
|
-
export declare function getRandomVector(seedOrRNG
|
|
48
|
+
export declare function getRandomVector(seedOrRNG: Seed | RNG | undefined): Readonly<Vector>;
|
|
45
49
|
/**
|
|
46
50
|
* Used to determine is the given table is a serialized `Vector` object created by the `deepCopy`
|
|
47
51
|
* function.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vector.d.ts","sourceRoot":"","sources":["../../../src/functions/vector.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,SAAS,EACV,MAAM,8BAA8B,CAAC;AActC,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IACvD,QAAQ,CAAC,uBAAuB,EAAE,MAAM,CAAC;IACzC,QAAQ,CAAC,MAAM,EAAE,yBAAyB,CAAC,MAAM,CAAC;CACnD,CAAC;AAKF,0DAA0D;AAC1D,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAQjD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAmBlE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,MAAM,EACd,SAAS,SAAO,GACf,OAAO,CAET;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,eAAe,EAAE,MAAM,EACvB,OAAO,EAAE,MAAM,EAAE,GAChB,MAAM,GAAG,SAAS,CAapB;AAED
|
|
1
|
+
{"version":3,"file":"vector.d.ts","sourceRoot":"","sources":["../../../src/functions/vector.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,SAAS,EACV,MAAM,8BAA8B,CAAC;AActC,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IACvD,QAAQ,CAAC,uBAAuB,EAAE,MAAM,CAAC;IACzC,QAAQ,CAAC,MAAM,EAAE,yBAAyB,CAAC,MAAM,CAAC;CACnD,CAAC;AAKF,0DAA0D;AAC1D,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAQjD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAmBlE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,MAAM,EACd,SAAS,SAAO,GACf,OAAO,CAET;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,eAAe,EAAE,MAAM,EACvB,OAAO,EAAE,MAAM,EAAE,GAChB,MAAM,GAAG,SAAS,CAapB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,IAAI,GAAG,GAAG,GAAG,SAAS,GAChC,QAAQ,CAAC,MAAM,CAAC,CAOlB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,OAAO,GACd,MAAM,IAAI,gBAAgB,CAM5B;AAED,gFAAgF;AAChF,wBAAgB,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,MAAM,CAE1D;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,CAWhE;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAEtE;AAED,sEAAsE;AACtE,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAG3D;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,UAAQ,GAAG,MAAM,CAIpE"}
|
|
@@ -10,7 +10,6 @@ local isaacAPIClassEquals = ____isaacAPIClass.isaacAPIClassEquals
|
|
|
10
10
|
local ____random = require("src.functions.random")
|
|
11
11
|
local getRandomFloat = ____random.getRandomFloat
|
|
12
12
|
local ____rng = require("src.functions.rng")
|
|
13
|
-
local getRandomSeed = ____rng.getRandomSeed
|
|
14
13
|
local isRNG = ____rng.isRNG
|
|
15
14
|
local newRNG = ____rng.newRNG
|
|
16
15
|
local ____table = require("src.functions.table")
|
|
@@ -88,12 +87,13 @@ end
|
|
|
88
87
|
--
|
|
89
88
|
-- Use this over the `RandomVector` function when you need the vector to be seeded.
|
|
90
89
|
--
|
|
91
|
-
--
|
|
92
|
-
-- `
|
|
90
|
+
-- If you want to generate an unseeded vector, you must explicitly pass `undefined` to the
|
|
91
|
+
-- `seedOrRNG` parameter.
|
|
92
|
+
--
|
|
93
|
+
-- @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
94
|
+
-- `RNG.Next` method will be called. If `undefined` is provided, it will default to
|
|
95
|
+
-- a random seed.
|
|
93
96
|
function ____exports.getRandomVector(self, seedOrRNG)
|
|
94
|
-
if seedOrRNG == nil then
|
|
95
|
-
seedOrRNG = getRandomSeed(nil)
|
|
96
|
-
end
|
|
97
97
|
local rng = isRNG(nil, seedOrRNG) and seedOrRNG or newRNG(nil, seedOrRNG)
|
|
98
98
|
local x = getRandomFloat(nil, -1, 1, rng)
|
|
99
99
|
local y = getRandomFloat(nil, -1, 1, rng)
|
|
@@ -6,12 +6,28 @@ import type { WeightedArray } from "../types/WeightedArray";
|
|
|
6
6
|
* Get a random value from a `WeightedArray`. (A `WeightedArray` is an array of tuples, where the
|
|
7
7
|
* first element in the tuple is a value, and the second element in the tuple is a float
|
|
8
8
|
* corresponding to the value's weight.)
|
|
9
|
+
*
|
|
10
|
+
* If you want to get an unseeded element, you must explicitly pass `undefined` to the `seedOrRNG`
|
|
11
|
+
* parameter.
|
|
12
|
+
*
|
|
13
|
+
* @param weightedArray The array to pick from.
|
|
14
|
+
* @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
15
|
+
* `RNG.Next` method will be called. If `undefined` is provided, it will default to
|
|
16
|
+
* a random seed.
|
|
9
17
|
*/
|
|
10
|
-
export declare function getRandomFromWeightedArray<T>(weightedArray: WeightedArray<T>, seedOrRNG
|
|
18
|
+
export declare function getRandomFromWeightedArray<T>(weightedArray: WeightedArray<T>, seedOrRNG: Seed | RNG | undefined): T;
|
|
11
19
|
/**
|
|
12
20
|
* Get a random index from a `WeightedArray`. (A `WeightedArray` is an array of tuples, where the
|
|
13
21
|
* first element in the tuple is a value, and the second element in the tuple is a float
|
|
14
22
|
* corresponding to the value's weight.)
|
|
23
|
+
*
|
|
24
|
+
* If you want to get an unseeded index, you must explicitly pass `undefined` to the `seedOrRNG`
|
|
25
|
+
* parameter.
|
|
26
|
+
*
|
|
27
|
+
* @param weightedArray The array to pick from.
|
|
28
|
+
* @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
29
|
+
* `RNG.Next` method will be called. If `undefined` is provided, it will default to
|
|
30
|
+
* a random seed.
|
|
15
31
|
*/
|
|
16
|
-
export declare function getRandomIndexFromWeightedArray<T>(weightedArray: WeightedArray<T>, seedOrRNG
|
|
32
|
+
export declare function getRandomIndexFromWeightedArray<T>(weightedArray: WeightedArray<T>, seedOrRNG: Seed | RNG | undefined): int;
|
|
17
33
|
//# sourceMappingURL=weighted.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"weighted.d.ts","sourceRoot":"","sources":["../../../src/functions/weighted.ts"],"names":[],"mappings":";;;AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"weighted.d.ts","sourceRoot":"","sources":["../../../src/functions/weighted.ts"],"names":[],"mappings":";;;AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAK5D;;;;;;;;;;;;GAYG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,EAC1C,aAAa,EAAE,aAAa,CAAC,CAAC,CAAC,EAC/B,SAAS,EAAE,IAAI,GAAG,GAAG,GAAG,SAAS,GAChC,CAAC,CAUH;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,+BAA+B,CAAC,CAAC,EAC/C,aAAa,EAAE,aAAa,CAAC,CAAC,CAAC,EAC/B,SAAS,EAAE,IAAI,GAAG,GAAG,GAAG,SAAS,GAChC,GAAG,CAsBL"}
|
|
@@ -7,17 +7,20 @@ local ____array = require("src.functions.array")
|
|
|
7
7
|
local sumArray = ____array.sumArray
|
|
8
8
|
local ____random = require("src.functions.random")
|
|
9
9
|
local getRandomFloat = ____random.getRandomFloat
|
|
10
|
-
local ____rng = require("src.functions.rng")
|
|
11
|
-
local getRandomSeed = ____rng.getRandomSeed
|
|
12
10
|
local ____utils = require("src.functions.utils")
|
|
13
11
|
local assertDefined = ____utils.assertDefined
|
|
14
12
|
--- Get a random index from a `WeightedArray`. (A `WeightedArray` is an array of tuples, where the
|
|
15
13
|
-- first element in the tuple is a value, and the second element in the tuple is a float
|
|
16
14
|
-- corresponding to the value's weight.)
|
|
15
|
+
--
|
|
16
|
+
-- If you want to get an unseeded index, you must explicitly pass `undefined` to the `seedOrRNG`
|
|
17
|
+
-- parameter.
|
|
18
|
+
--
|
|
19
|
+
-- @param weightedArray The array to pick from.
|
|
20
|
+
-- @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
21
|
+
-- `RNG.Next` method will be called. If `undefined` is provided, it will default to
|
|
22
|
+
-- a random seed.
|
|
17
23
|
function ____exports.getRandomIndexFromWeightedArray(self, weightedArray, seedOrRNG)
|
|
18
|
-
if seedOrRNG == nil then
|
|
19
|
-
seedOrRNG = getRandomSeed(nil)
|
|
20
|
-
end
|
|
21
24
|
if #weightedArray == 0 then
|
|
22
25
|
error("Failed to get a random index from a weighted array since the provided array was empty.")
|
|
23
26
|
end
|
|
@@ -42,10 +45,15 @@ end
|
|
|
42
45
|
--- Get a random value from a `WeightedArray`. (A `WeightedArray` is an array of tuples, where the
|
|
43
46
|
-- first element in the tuple is a value, and the second element in the tuple is a float
|
|
44
47
|
-- corresponding to the value's weight.)
|
|
48
|
+
--
|
|
49
|
+
-- If you want to get an unseeded element, you must explicitly pass `undefined` to the `seedOrRNG`
|
|
50
|
+
-- parameter.
|
|
51
|
+
--
|
|
52
|
+
-- @param weightedArray The array to pick from.
|
|
53
|
+
-- @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
54
|
+
-- `RNG.Next` method will be called. If `undefined` is provided, it will default to
|
|
55
|
+
-- a random seed.
|
|
45
56
|
function ____exports.getRandomFromWeightedArray(self, weightedArray, seedOrRNG)
|
|
46
|
-
if seedOrRNG == nil then
|
|
47
|
-
seedOrRNG = getRandomSeed(nil)
|
|
48
|
-
end
|
|
49
57
|
local randomIndex = ____exports.getRandomIndexFromWeightedArray(nil, weightedArray, seedOrRNG)
|
|
50
58
|
local randomElement = weightedArray[randomIndex + 1]
|
|
51
59
|
assertDefined(
|
package/package.json
CHANGED
|
@@ -4,7 +4,6 @@ import { Exported } from "../../../decorators";
|
|
|
4
4
|
import { ModCallbackCustom } from "../../../enums/ModCallbackCustom";
|
|
5
5
|
import { arrayRemoveIndexInPlace } from "../../../functions/array";
|
|
6
6
|
import { copyMap } from "../../../functions/map";
|
|
7
|
-
import { getRandomSeed } from "../../../functions/rng";
|
|
8
7
|
import { assertDefined } from "../../../functions/utils";
|
|
9
8
|
import { getRandomIndexFromWeightedArray } from "../../../functions/weighted";
|
|
10
9
|
import type { WeightedArray } from "../../../types/WeightedArray";
|
|
@@ -99,21 +98,25 @@ export class CustomItemPools extends Feature {
|
|
|
99
98
|
* By default, a collectible will not be removed from the pool once it is selected, unless the
|
|
100
99
|
* `decrease` argument is set to true (similar to how a vanilla item pool works).
|
|
101
100
|
*
|
|
101
|
+
* If you want to get an unseeded collectible type, you must explicitly pass `undefined` to the
|
|
102
|
+
* `seedOrRNG` parameter.
|
|
103
|
+
*
|
|
102
104
|
* In order to use this function, you must upgrade your mod with `ISCFeature.CUSTOM_ITEM_POOLS`.
|
|
103
105
|
*
|
|
104
106
|
* @param itemPoolTypeCustom An integer representing the custom item pool to use.
|
|
107
|
+
* @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
108
|
+
* `RNG.Next` method will be called. If `undefined` is provided, it will default
|
|
109
|
+
* to a random seed.
|
|
105
110
|
* @param decrease Optional. Whether to remove the selected collectible from the item pool.
|
|
106
111
|
* Default is true.
|
|
107
|
-
* @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided,
|
|
108
|
-
* the `RNG.Next` method will be called. Default is `getRandomSeed()`.
|
|
109
112
|
* @param defaultItem Optional. The collectible to return if the item pool is depleted. Default is
|
|
110
113
|
* `CollectibleType.NULL`.
|
|
111
114
|
*/
|
|
112
115
|
@Exported
|
|
113
116
|
public getCustomItemPoolCollectible(
|
|
114
117
|
itemPoolTypeCustom: ItemPoolType,
|
|
118
|
+
seedOrRNG: Seed | RNG | undefined,
|
|
115
119
|
decrease = false,
|
|
116
|
-
seedOrRNG: Seed | RNG = getRandomSeed(),
|
|
117
120
|
defaultItem = CollectibleType.NULL,
|
|
118
121
|
): CollectibleType {
|
|
119
122
|
const customItemPool = v.run.customItemPools.get(itemPoolTypeCustom);
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
} from "../../../functions/gridEntities";
|
|
25
25
|
import { getRandomJSONEntity } from "../../../functions/jsonRoom";
|
|
26
26
|
import { log } from "../../../functions/log";
|
|
27
|
-
import {
|
|
27
|
+
import { isRNG, newRNG } from "../../../functions/rng";
|
|
28
28
|
import { gridCoordinatesToWorldPosition } from "../../../functions/roomGrid";
|
|
29
29
|
import { setRoomCleared, setRoomUncleared } from "../../../functions/rooms";
|
|
30
30
|
import { asCollectibleType, asNumber } from "../../../functions/types";
|
|
@@ -81,7 +81,7 @@ export class DeployJSONRoom extends Feature {
|
|
|
81
81
|
`Failed to convert the following y coordinate to a number (for a spawn): ${yString}`,
|
|
82
82
|
);
|
|
83
83
|
|
|
84
|
-
const jsonEntity = getRandomJSONEntity(jsonSpawn.entity);
|
|
84
|
+
const jsonEntity = getRandomJSONEntity(jsonSpawn.entity, rng);
|
|
85
85
|
|
|
86
86
|
const entityTypeString = jsonEntity.$.type;
|
|
87
87
|
const entityTypeNumber = tonumber(entityTypeString);
|
|
@@ -219,18 +219,22 @@ export class DeployJSONRoom extends Feature {
|
|
|
219
219
|
* }
|
|
220
220
|
* ```
|
|
221
221
|
*
|
|
222
|
+
* If you want to deploy an unseeded room, you must explicitly pass `undefined` to the `seedOrRNG`
|
|
223
|
+
* parameter.
|
|
224
|
+
*
|
|
222
225
|
* In order to use this function, you must upgrade your mod with `ISCFeature.DEPLOY_JSON_ROOM`.
|
|
223
226
|
*
|
|
224
227
|
* @param jsonRoom The JSON room to deploy.
|
|
225
|
-
* @param seedOrRNG
|
|
226
|
-
*
|
|
228
|
+
* @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
229
|
+
* `RNG.Next` method will be called. If `undefined` is provided, it will default
|
|
230
|
+
* to a random seed.
|
|
227
231
|
* @param verbose Optional. If specified, will write entries to the "log.txt" file that describe
|
|
228
232
|
* what the function is doing. Default is false.
|
|
229
233
|
*/
|
|
230
234
|
@Exported
|
|
231
235
|
public deployJSONRoom(
|
|
232
236
|
jsonRoom: JSONRoom | Readonly<JSONRoom>,
|
|
233
|
-
seedOrRNG: Seed | RNG
|
|
237
|
+
seedOrRNG: Seed | RNG | undefined,
|
|
234
238
|
verbose = false,
|
|
235
239
|
): void {
|
|
236
240
|
const rng = isRNG(seedOrRNG) ? seedOrRNG : newRNG(seedOrRNG);
|