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.
- package/dist/index.rollup.d.ts +229 -96
- package/dist/isaacscript-common.lua +13 -128
- package/dist/src/classes/callbacks/PostHolyMantleRemoved.d.ts.map +1 -1
- package/dist/src/classes/callbacks/PostHolyMantleRemoved.lua +3 -1
- 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/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/callbacks/PostHolyMantleRemoved.ts +6 -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/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
|
@@ -13,13 +13,17 @@ export declare function copyColor(color: Color): Color;
|
|
|
13
13
|
*/
|
|
14
14
|
export declare function deserializeColor(color: SerializedColor): Color;
|
|
15
15
|
/**
|
|
16
|
-
* Helper function to get a random
|
|
16
|
+
* Helper function to get a random `Color` object.
|
|
17
17
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
18
|
+
* If you want to generate an unseeded object, you must explicitly pass `undefined` to the
|
|
19
|
+
* `seedOrRNG` parameter.
|
|
20
|
+
*
|
|
21
|
+
* @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
22
|
+
* `RNG.Next` method will be called. If `undefined` is provided, it will default to
|
|
23
|
+
* a random seed.
|
|
20
24
|
* @param alpha Optional. The alpha value to use. Default is 1.
|
|
21
25
|
*/
|
|
22
|
-
export declare function getRandomColor(seedOrRNG
|
|
26
|
+
export declare function getRandomColor(seedOrRNG: Seed | RNG | undefined, alpha?: number): Readonly<Color>;
|
|
23
27
|
/** Helper function to check if something is an instantiated `Color` object. */
|
|
24
28
|
export declare function isColor(object: unknown): object is Color;
|
|
25
29
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../../src/functions/color.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAa9E,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,E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AC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,eAAe,CAM5E;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,eAAe,CAW5D"}
|
|
@@ -8,7 +8,6 @@ local isIsaacAPIClassOfType = ____isaacAPIClass.isIsaacAPIClassOfType
|
|
|
8
8
|
local ____random = require("src.functions.random")
|
|
9
9
|
local getRandom = ____random.getRandom
|
|
10
10
|
local ____rng = require("src.functions.rng")
|
|
11
|
-
local getRandomSeed = ____rng.getRandomSeed
|
|
12
11
|
local isRNG = ____rng.isRNG
|
|
13
12
|
local newRNG = ____rng.newRNG
|
|
14
13
|
local ____table = require("src.functions.table")
|
|
@@ -76,15 +75,16 @@ function ____exports.deserializeColor(self, color)
|
|
|
76
75
|
bo
|
|
77
76
|
)
|
|
78
77
|
end
|
|
79
|
-
--- Helper function to get a random
|
|
78
|
+
--- Helper function to get a random `Color` object.
|
|
80
79
|
--
|
|
81
|
-
--
|
|
82
|
-
-- `
|
|
80
|
+
-- If you want to generate an unseeded object, you must explicitly pass `undefined` to the
|
|
81
|
+
-- `seedOrRNG` parameter.
|
|
82
|
+
--
|
|
83
|
+
-- @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
84
|
+
-- `RNG.Next` method will be called. If `undefined` is provided, it will default to
|
|
85
|
+
-- a random seed.
|
|
83
86
|
-- @param alpha Optional. The alpha value to use. Default is 1.
|
|
84
87
|
function ____exports.getRandomColor(self, seedOrRNG, alpha)
|
|
85
|
-
if seedOrRNG == nil then
|
|
86
|
-
seedOrRNG = getRandomSeed(nil)
|
|
87
|
-
end
|
|
88
88
|
if alpha == nil then
|
|
89
89
|
alpha = 1
|
|
90
90
|
end
|
|
@@ -97,12 +97,15 @@ export declare function getLowestEnumValue<T>(transpiledEnum: T): T[keyof T];
|
|
|
97
97
|
/**
|
|
98
98
|
* Helper function to get a random value from the provided enum.
|
|
99
99
|
*
|
|
100
|
+
* If you want an unseeded value, you must explicitly pass `undefined` to the `seedOrRNG` parameter.
|
|
101
|
+
*
|
|
100
102
|
* @param transpiledEnum The enum to get the value from.
|
|
101
|
-
* @param seedOrRNG
|
|
102
|
-
* `RNG.Next` method will be called.
|
|
103
|
+
* @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
104
|
+
* `RNG.Next` method will be called. If `undefined` is provided, it will default to
|
|
105
|
+
* a random seed.
|
|
103
106
|
* @param exceptions Optional. An array of elements to skip over if selected.
|
|
104
107
|
*/
|
|
105
|
-
export declare function getRandomEnumValue<T>(transpiledEnum: T, seedOrRNG
|
|
108
|
+
export declare function getRandomEnumValue<T>(transpiledEnum: T, seedOrRNG: Seed | RNG | undefined, exceptions?: Array<T[keyof T]> | ReadonlyArray<T[keyof T]>): T[keyof T];
|
|
106
109
|
/** Helper function to validate that a particular value exists inside of an enum. */
|
|
107
110
|
export declare function isEnumValue<T extends Record<string, number | string>>(value: number | string, transpiledEnum: T): value is T[keyof T];
|
|
108
111
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../../../src/functions/enums.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../../../src/functions/enums.ts"],"names":[],"mappings":";;;AAKA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAC9B,cAAc,EAAE,CAAC,GAChB,KAAK,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAmBzC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,WAAW,CACzB,cAAc,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,GACvD,MAAM,EAAE,CAGV;AAED,sEAAsE;AACtE,wBAAgB,aAAa,CAC3B,cAAc,EAAE,MAA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CAQN;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,EACtC,kBAAkB,EAAE,MAAM,EAC1B,cAAc,EAAE,CAAC,GAChB,IAAI,CAsBN;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,4BAA4B,CAE1C,CAAC,SAAS,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,EAC/B,IAAI,SAAS,MAAM,GAAG,MAAM,KACzB,IAAI,CAAG"}
|
|
@@ -9,8 +9,6 @@ local ____ReadonlySet = require("src.types.ReadonlySet")
|
|
|
9
9
|
local ReadonlySet = ____ReadonlySet.ReadonlySet
|
|
10
10
|
local ____array = require("src.functions.array")
|
|
11
11
|
local getRandomArrayElement = ____array.getRandomArrayElement
|
|
12
|
-
local ____rng = require("src.functions.rng")
|
|
13
|
-
local getRandomSeed = ____rng.getRandomSeed
|
|
14
12
|
local ____types = require("src.functions.types")
|
|
15
13
|
local isNumber = ____types.isNumber
|
|
16
14
|
local isString = ____types.isString
|
|
@@ -164,14 +162,14 @@ function ____exports.getLowestEnumValue(self, transpiledEnum)
|
|
|
164
162
|
end
|
|
165
163
|
--- Helper function to get a random value from the provided enum.
|
|
166
164
|
--
|
|
165
|
+
-- If you want an unseeded value, you must explicitly pass `undefined` to the `seedOrRNG` parameter.
|
|
166
|
+
--
|
|
167
167
|
-- @param transpiledEnum The enum to get the value from.
|
|
168
|
-
-- @param seedOrRNG
|
|
169
|
-
-- `RNG.Next` method will be called.
|
|
168
|
+
-- @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
169
|
+
-- `RNG.Next` method will be called. If `undefined` is provided, it will default to
|
|
170
|
+
-- a random seed.
|
|
170
171
|
-- @param exceptions Optional. An array of elements to skip over if selected.
|
|
171
172
|
function ____exports.getRandomEnumValue(self, transpiledEnum, seedOrRNG, exceptions)
|
|
172
|
-
if seedOrRNG == nil then
|
|
173
|
-
seedOrRNG = getRandomSeed(nil)
|
|
174
|
-
end
|
|
175
173
|
if exceptions == nil then
|
|
176
174
|
exceptions = {}
|
|
177
175
|
end
|
|
@@ -4,8 +4,15 @@ import { ItemPoolType } from "isaac-typescript-definitions";
|
|
|
4
4
|
* Helper function to get a random item pool. This is not as simple as getting a random value from
|
|
5
5
|
* the `ItemPoolType` enum, since `ItemPoolType.SHELL_GAME` (7) is not a real item pool and the
|
|
6
6
|
* Greed Mode item pools should be excluded if not playing in Greed Mode.
|
|
7
|
+
*
|
|
8
|
+
* If you want to get an unseeded item pool, you must explicitly pass `undefined` to the `seedOrRNG`
|
|
9
|
+
* 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.
|
|
7
14
|
*/
|
|
8
|
-
export declare function getRandomItemPool(): ItemPoolType;
|
|
15
|
+
export declare function getRandomItemPool(seedOrRNG: Seed | RNG | undefined): ItemPoolType;
|
|
9
16
|
/**
|
|
10
17
|
* Helper function to remove one or more collectibles from all item pools.
|
|
11
18
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"itemPool.d.ts","sourceRoot":"","sources":["../../../src/functions/itemPool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,WAAW,EACZ,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAuC5D
|
|
1
|
+
{"version":3,"file":"itemPool.d.ts","sourceRoot":"","sources":["../../../src/functions/itemPool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,WAAW,EACZ,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAuC5D;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,IAAI,GAAG,GAAG,GAAG,SAAS,GAChC,YAAY,CAKd;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,GAAG,gBAAgB,EAAE,eAAe,EAAE,GACrC,IAAI,CAMN;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,YAAY,EAAE,WAAW,EAAE,GAAG,IAAI,CAM3E"}
|
|
@@ -56,9 +56,16 @@ local GREED_MODE_ITEM_POOL_TYPES = ____arrayRemove_3(__TS__SparseArraySpread(___
|
|
|
56
56
|
--- Helper function to get a random item pool. This is not as simple as getting a random value from
|
|
57
57
|
-- the `ItemPoolType` enum, since `ItemPoolType.SHELL_GAME` (7) is not a real item pool and the
|
|
58
58
|
-- Greed Mode item pools should be excluded if not playing in Greed Mode.
|
|
59
|
-
|
|
59
|
+
--
|
|
60
|
+
-- If you want to get an unseeded item pool, you must explicitly pass `undefined` to the `seedOrRNG`
|
|
61
|
+
-- parameter.
|
|
62
|
+
--
|
|
63
|
+
-- @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
64
|
+
-- `RNG.Next` method will be called. If `undefined` is provided, it will default to
|
|
65
|
+
-- a random seed.
|
|
66
|
+
function ____exports.getRandomItemPool(self, seedOrRNG)
|
|
60
67
|
local itemPoolTypes = game:IsGreedMode() and GREED_MODE_ITEM_POOL_TYPES or NORMAL_MODE_ITEM_POOL_TYPES
|
|
61
|
-
return getRandomArrayElement(nil, itemPoolTypes)
|
|
68
|
+
return getRandomArrayElement(nil, itemPoolTypes, seedOrRNG)
|
|
62
69
|
end
|
|
63
70
|
--- Helper function to remove one or more collectibles from all item pools.
|
|
64
71
|
--
|
|
@@ -36,13 +36,17 @@ export declare function getJSONRoomsOfSubType(jsonRooms: JSONRoom[] | readonly J
|
|
|
36
36
|
* properly account for each room weight using the algorithm from:
|
|
37
37
|
* https://stackoverflow.com/questions/1761626/weighted-random-numbers
|
|
38
38
|
*
|
|
39
|
+
* If you want an unseeded entity, you must explicitly pass `undefined` to the `seedOrRNG`
|
|
40
|
+
* parameter.
|
|
41
|
+
*
|
|
39
42
|
* @param jsonEntities The array of entities to randomly choose between.
|
|
40
|
-
* @param seedOrRNG
|
|
41
|
-
* `RNG.Next` method will be called.
|
|
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.
|
|
42
46
|
* @param verbose Optional. If specified, will write entries to the "log.txt" file that describe
|
|
43
47
|
* what the function is doing. Default is false.
|
|
44
48
|
*/
|
|
45
|
-
export declare function getRandomJSONEntity(jsonEntities: JSONEntity[], seedOrRNG
|
|
49
|
+
export declare function getRandomJSONEntity(jsonEntities: JSONEntity[], seedOrRNG: Seed | RNG | undefined, verbose?: boolean): JSONEntity;
|
|
46
50
|
/**
|
|
47
51
|
* Helper function to get a random JSON room from an array of JSON rooms.
|
|
48
52
|
*
|
|
@@ -52,11 +56,14 @@ export declare function getRandomJSONEntity(jsonEntities: JSONEntity[], seedOrRN
|
|
|
52
56
|
* properly account for each room weight using the algorithm from:
|
|
53
57
|
* https://stackoverflow.com/questions/1761626/weighted-random-numbers
|
|
54
58
|
*
|
|
59
|
+
* If you want an unseeded room, you must explicitly pass `undefined` to the `seedOrRNG` parameter.
|
|
60
|
+
*
|
|
55
61
|
* @param jsonRooms The array of rooms to randomly choose between.
|
|
56
|
-
* @param seedOrRNG
|
|
57
|
-
* `RNG.Next` method will be called.
|
|
62
|
+
* @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
63
|
+
* `RNG.Next` method will be called. If `undefined` is provided, it will default to
|
|
64
|
+
* a random seed.
|
|
58
65
|
* @param verbose Optional. If specified, will write entries to the "log.txt" file that describe
|
|
59
66
|
* what the function is doing. Default is false.
|
|
60
67
|
*/
|
|
61
|
-
export declare function getRandomJSONRoom(jsonRooms: JSONRoom[], seedOrRNG
|
|
68
|
+
export declare function getRandomJSONRoom(jsonRooms: JSONRoom[], seedOrRNG: Seed | RNG | undefined, verbose?: boolean): JSONRoom;
|
|
62
69
|
//# sourceMappingURL=jsonRoom.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonRoom.d.ts","sourceRoot":"","sources":["../../../src/functions/jsonRoom.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"jsonRoom.d.ts","sourceRoot":"","sources":["../../../src/functions/jsonRoom.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAcxE;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,QAAQ,GACjB,QAAQ,CAAC,YAAY,CAAC,CAqDxB;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,QAAQ,EAAE,GAAG,SAAS,QAAQ,EAAE,EAC3C,OAAO,EAAE,GAAG,GACX,QAAQ,GAAG,SAAS,CAoBtB;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,QAAQ,EAAE,GAAG,SAAS,QAAQ,EAAE,EAC3C,OAAO,EAAE,GAAG,GACX,QAAQ,EAAE,CAMZ;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,UAAU,EAAE,EAC1B,SAAS,EAAE,IAAI,GAAG,GAAG,GAAG,SAAS,EACjC,OAAO,UAAQ,GACd,UAAU,CAqBZ;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,QAAQ,EAAE,EACrB,SAAS,EAAE,IAAI,GAAG,GAAG,GAAG,SAAS,EACjC,OAAO,UAAQ,GACd,QAAQ,CAkBV"}
|
|
@@ -19,8 +19,6 @@ local ____log = require("src.functions.log")
|
|
|
19
19
|
local log = ____log.log
|
|
20
20
|
local ____random = require("src.functions.random")
|
|
21
21
|
local getRandomFloat = ____random.getRandomFloat
|
|
22
|
-
local ____rng = require("src.functions.rng")
|
|
23
|
-
local getRandomSeed = ____rng.getRandomSeed
|
|
24
22
|
local ____utils = require("src.functions.utils")
|
|
25
23
|
local assertDefined = ____utils.assertDefined
|
|
26
24
|
function getTotalWeightOfJSONObject(self, jsonOjectArray)
|
|
@@ -145,15 +143,16 @@ end
|
|
|
145
143
|
-- properly account for each room weight using the algorithm from:
|
|
146
144
|
-- https://stackoverflow.com/questions/1761626/weighted-random-numbers
|
|
147
145
|
--
|
|
146
|
+
-- If you want an unseeded entity, you must explicitly pass `undefined` to the `seedOrRNG`
|
|
147
|
+
-- parameter.
|
|
148
|
+
--
|
|
148
149
|
-- @param jsonEntities The array of entities to randomly choose between.
|
|
149
|
-
-- @param seedOrRNG
|
|
150
|
-
-- `RNG.Next` method will be called.
|
|
150
|
+
-- @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
151
|
+
-- `RNG.Next` method will be called. If `undefined` is provided, it will default to
|
|
152
|
+
-- a random seed.
|
|
151
153
|
-- @param verbose Optional. If specified, will write entries to the "log.txt" file that describe
|
|
152
154
|
-- what the function is doing. Default is false.
|
|
153
155
|
function ____exports.getRandomJSONEntity(self, jsonEntities, seedOrRNG, verbose)
|
|
154
|
-
if seedOrRNG == nil then
|
|
155
|
-
seedOrRNG = getRandomSeed(nil)
|
|
156
|
-
end
|
|
157
156
|
if verbose == nil then
|
|
158
157
|
verbose = false
|
|
159
158
|
end
|
|
@@ -181,15 +180,15 @@ end
|
|
|
181
180
|
-- properly account for each room weight using the algorithm from:
|
|
182
181
|
-- https://stackoverflow.com/questions/1761626/weighted-random-numbers
|
|
183
182
|
--
|
|
183
|
+
-- If you want an unseeded room, you must explicitly pass `undefined` to the `seedOrRNG` parameter.
|
|
184
|
+
--
|
|
184
185
|
-- @param jsonRooms The array of rooms to randomly choose between.
|
|
185
|
-
-- @param seedOrRNG
|
|
186
|
-
-- `RNG.Next` method will be called.
|
|
186
|
+
-- @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
187
|
+
-- `RNG.Next` method will be called. If `undefined` is provided, it will default to
|
|
188
|
+
-- a random seed.
|
|
187
189
|
-- @param verbose Optional. If specified, will write entries to the "log.txt" file that describe
|
|
188
190
|
-- what the function is doing. Default is false.
|
|
189
191
|
function ____exports.getRandomJSONRoom(self, jsonRooms, seedOrRNG, verbose)
|
|
190
|
-
if seedOrRNG == nil then
|
|
191
|
-
seedOrRNG = getRandomSeed(nil)
|
|
192
|
-
end
|
|
193
192
|
if verbose == nil then
|
|
194
193
|
verbose = false
|
|
195
194
|
end
|
|
@@ -12,13 +12,17 @@ export declare function copyKColor(kColor: KColor): KColor;
|
|
|
12
12
|
*/
|
|
13
13
|
export declare function deserializeKColor(kColor: SerializedKColor): KColor;
|
|
14
14
|
/**
|
|
15
|
-
* Helper function to get a random
|
|
15
|
+
* Helper function to get a random `KColor` object (for use in fonts).
|
|
16
16
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
17
|
+
* If you want to generate an unseeded object, you must explicitly pass `undefined` to the
|
|
18
|
+
* `seedOrRNG` parameter.
|
|
19
|
+
*
|
|
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.
|
|
19
23
|
* @param alpha Optional. The alpha value to use. Default is 1.
|
|
20
24
|
*/
|
|
21
|
-
export declare function getRandomKColor(seedOrRNG
|
|
25
|
+
export declare function getRandomKColor(seedOrRNG: Seed | RNG | undefined, alpha?: number): Readonly<KColor>;
|
|
22
26
|
/** Helper function to check if something is an instantiated `KColor` object. */
|
|
23
27
|
export declare function isKColor(object: unknown): object is KColor;
|
|
24
28
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kColor.d.ts","sourceRoot":"","sources":["../../../src/functions/kColor.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAa9E,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,OAAO,CAAC;CACpD,CAAC;AAKF,0DAA0D;AAC1D,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAQjD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CA2BlE;AAED
|
|
1
|
+
{"version":3,"file":"kColor.d.ts","sourceRoot":"","sources":["../../../src/functions/kColor.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAa9E,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,OAAO,CAAC;CACpD,CAAC;AAKF,0DAA0D;AAC1D,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAQjD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CA2BlE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,IAAI,GAAG,GAAG,GAAG,SAAS,EACjC,KAAK,SAAI,GACR,QAAQ,CAAC,MAAM,CAAC,CAQlB;AAED,gFAAgF;AAChF,wBAAgB,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,MAAM,CAE1D;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,OAAO,GACd,MAAM,IAAI,gBAAgB,CAQ5B;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAEtE;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,CAWhE"}
|
|
@@ -8,7 +8,6 @@ local isIsaacAPIClassOfType = ____isaacAPIClass.isIsaacAPIClassOfType
|
|
|
8
8
|
local ____random = require("src.functions.random")
|
|
9
9
|
local getRandom = ____random.getRandom
|
|
10
10
|
local ____rng = require("src.functions.rng")
|
|
11
|
-
local getRandomSeed = ____rng.getRandomSeed
|
|
12
11
|
local isRNG = ____rng.isRNG
|
|
13
12
|
local newRNG = ____rng.newRNG
|
|
14
13
|
local ____table = require("src.functions.table")
|
|
@@ -50,15 +49,16 @@ function ____exports.deserializeKColor(self, kColor)
|
|
|
50
49
|
assertDefined(nil, a, ("Failed to deserialize a " .. OBJECT_NAME) .. " object since the provided object did not have a value for: Alpha")
|
|
51
50
|
return KColor(r, g, b, a)
|
|
52
51
|
end
|
|
53
|
-
--- Helper function to get a random
|
|
52
|
+
--- Helper function to get a random `KColor` object (for use in fonts).
|
|
54
53
|
--
|
|
55
|
-
--
|
|
56
|
-
-- `
|
|
54
|
+
-- If you want to generate an unseeded object, you must explicitly pass `undefined` to the
|
|
55
|
+
-- `seedOrRNG` parameter.
|
|
56
|
+
--
|
|
57
|
+
-- @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
58
|
+
-- `RNG.Next` method will be called. If `undefined` is provided, it will default to
|
|
59
|
+
-- a random seed.
|
|
57
60
|
-- @param alpha Optional. The alpha value to use. Default is 1.
|
|
58
61
|
function ____exports.getRandomKColor(self, seedOrRNG, alpha)
|
|
59
|
-
if seedOrRNG == nil then
|
|
60
|
-
seedOrRNG = getRandomSeed(nil)
|
|
61
|
-
end
|
|
62
62
|
if alpha == nil then
|
|
63
63
|
alpha = 1
|
|
64
64
|
end
|
|
@@ -48,15 +48,19 @@ export declare function getAllRoomGridIndexes(): readonly int[];
|
|
|
48
48
|
* some floors will not have any valid spots. If this is the case, this function will return
|
|
49
49
|
* undefined.
|
|
50
50
|
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
51
|
+
* If you want to get an unseeded room, you must explicitly pass `undefined` to the `seedOrRNG`
|
|
52
|
+
* parameter.
|
|
53
|
+
*
|
|
54
|
+
* @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
55
|
+
* `RNG.Next` method will be called. If `undefined` is provided, it will default to
|
|
56
|
+
* a random seed.
|
|
53
57
|
* @param ensureDeadEnd Optional. Whether to pick a valid dead end attached to a normal room. If
|
|
54
58
|
* false, the function will randomly pick from any valid location that would
|
|
55
59
|
* have a red door.
|
|
56
60
|
* @returns Either a tuple of adjacent room grid index, `DoorSlot`, and new room grid index, or
|
|
57
61
|
* undefined.
|
|
58
62
|
*/
|
|
59
|
-
export declare function getNewRoomCandidate(seedOrRNG
|
|
63
|
+
export declare function getNewRoomCandidate(seedOrRNG: Seed | RNG | undefined, ensureDeadEnd?: boolean): {
|
|
60
64
|
readonly adjacentRoomGridIndex: int;
|
|
61
65
|
readonly doorSlot: DoorSlot;
|
|
62
66
|
readonly newRoomGridIndex: int;
|
|
@@ -195,9 +199,12 @@ export declare function isRoomInsideGrid(roomGridIndex?: int): boolean;
|
|
|
195
199
|
/**
|
|
196
200
|
* Helper function to generate a new room on the floor.
|
|
197
201
|
*
|
|
202
|
+
* If you want to generate an unseeded room, you must explicitly pass `undefined` to the `seedOrRNG`
|
|
203
|
+
* parameter.
|
|
204
|
+
*
|
|
198
205
|
* Under the hood, this function uses the `Level.MakeRedRoomDoor` method to create the room.
|
|
199
206
|
*
|
|
200
|
-
* @param seedOrRNG
|
|
207
|
+
* @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
201
208
|
* `RNG.Next` method will be called. Default is `Level.GetDungeonPlacementSeed`.
|
|
202
209
|
* Note that the RNG is only used to select the random location to put the room on
|
|
203
210
|
* the floor; it does not influence the randomly chosen room contents. (That is
|
|
@@ -211,7 +218,7 @@ export declare function isRoomInsideGrid(roomGridIndex?: int): boolean;
|
|
|
211
218
|
* @returns The room grid index of the new room or undefined if the floor had no valid dead ends to
|
|
212
219
|
* place a room.
|
|
213
220
|
*/
|
|
214
|
-
export declare function newRoom(seedOrRNG
|
|
221
|
+
export declare function newRoom(seedOrRNG: Seed | RNG | undefined, ensureDeadEnd?: boolean, customRoomData?: RoomConfig): int | undefined;
|
|
215
222
|
/**
|
|
216
223
|
* Helper function to check if a room exists at the given room grid index. (A room will exist if it
|
|
217
224
|
* 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,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAIL,QAAQ,EACT,MAAM,8BAA8B,CAAC;AAoCtC;;;;;;;GAOG;AACH,wBAAgB,kCAAkC,CAChD,aAAa,CAAC,EAAE,GAAG,GAClB,SAAS,GAAG,EAAE,CAKhB;AAED;;;;;;GAMG;AACH,wBAAgB,qCAAqC,CACnD,aAAa,CAAC,EAAE,GAAG,GAClB,SAAS,GAAG,EAAE,CAKhB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,0BAA0B,CACxC,aAAa,CAAC,EAAE,GAAG,GAClB,SAAS,GAAG,EAAE,CAchB;AAED,0FAA0F;AAC1F,wBAAgB,qBAAqB,IAAI,SAAS,GAAG,EAAE,C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AED,wBAAgB,oCAAoC,CAClD,QAAQ,EAAE,QAAQ,EAClB,aAAa,EAAE,GAAG,GACjB,OAAO,CAqBT;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,aAAa,EAAE,GAAG,GAAG,OAAO,CAGxD;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,aAAa,CAAC,EAAE,GAAG,GAAG,OAAO,CAM7D;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,OAAO,CACrB,SAAS,EAAE,IAAI,GAAG,GAAG,GAAG,SAAS,EACjC,aAAa,UAAO,EACpB,cAAc,CAAC,EAAE,UAAU,GAC1B,GAAG,GAAG,SAAS,CAuDjB;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,aAAa,EAAE,GAAG,GAAG,OAAO,CAGtD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,GAAG,GAAG,QAAQ,CAAC,MAAM,CAAC,CAK1E;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAE7D"}
|
|
@@ -31,7 +31,6 @@ local removeFlag = ____flag.removeFlag
|
|
|
31
31
|
local ____map = require("src.functions.map")
|
|
32
32
|
local copyMap = ____map.copyMap
|
|
33
33
|
local ____rng = require("src.functions.rng")
|
|
34
|
-
local getRandomSeed = ____rng.getRandomSeed
|
|
35
34
|
local isRNG = ____rng.isRNG
|
|
36
35
|
local newRNG = ____rng.newRNG
|
|
37
36
|
local ____roomData = require("src.functions.roomData")
|
|
@@ -293,17 +292,18 @@ end
|
|
|
293
292
|
-- some floors will not have any valid spots. If this is the case, this function will return
|
|
294
293
|
-- undefined.
|
|
295
294
|
--
|
|
296
|
-
--
|
|
297
|
-
--
|
|
295
|
+
-- If you want to get an unseeded room, you must explicitly pass `undefined` to the `seedOrRNG`
|
|
296
|
+
-- parameter.
|
|
297
|
+
--
|
|
298
|
+
-- @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
299
|
+
-- `RNG.Next` method will be called. If `undefined` is provided, it will default to
|
|
300
|
+
-- a random seed.
|
|
298
301
|
-- @param ensureDeadEnd Optional. Whether to pick a valid dead end attached to a normal room. If
|
|
299
302
|
-- false, the function will randomly pick from any valid location that would
|
|
300
303
|
-- have a red door.
|
|
301
304
|
-- @returns Either a tuple of adjacent room grid index, `DoorSlot`, and new room grid index, or
|
|
302
305
|
-- undefined.
|
|
303
306
|
function ____exports.getNewRoomCandidate(self, seedOrRNG, ensureDeadEnd)
|
|
304
|
-
if seedOrRNG == nil then
|
|
305
|
-
seedOrRNG = getRandomSeed(nil)
|
|
306
|
-
end
|
|
307
307
|
if ensureDeadEnd == nil then
|
|
308
308
|
ensureDeadEnd = true
|
|
309
309
|
end
|
|
@@ -391,9 +391,12 @@ function ____exports.isDoorSlotValidAtGridIndexForRedRoom(self, doorSlot, roomGr
|
|
|
391
391
|
end
|
|
392
392
|
--- Helper function to generate a new room on the floor.
|
|
393
393
|
--
|
|
394
|
+
-- If you want to generate an unseeded room, you must explicitly pass `undefined` to the `seedOrRNG`
|
|
395
|
+
-- parameter.
|
|
396
|
+
--
|
|
394
397
|
-- Under the hood, this function uses the `Level.MakeRedRoomDoor` method to create the room.
|
|
395
398
|
--
|
|
396
|
-
-- @param seedOrRNG
|
|
399
|
+
-- @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
397
400
|
-- `RNG.Next` method will be called. Default is `Level.GetDungeonPlacementSeed`.
|
|
398
401
|
-- Note that the RNG is only used to select the random location to put the room on
|
|
399
402
|
-- the floor; it does not influence the randomly chosen room contents. (That is
|
|
@@ -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)
|