isaacscript-common 8.4.3 → 8.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/functions/collectibleSet.d.ts +0 -6
- package/dist/functions/collectibleSet.d.ts.map +1 -1
- package/dist/functions/collectibleSet.lua +35 -46
- package/dist/functions/collectibles.d.ts +2 -1
- package/dist/functions/collectibles.d.ts.map +1 -1
- package/dist/functions/collectibles.lua +2 -1
- package/dist/functions/trinketSet.d.ts +0 -6
- package/dist/functions/trinketSet.d.ts.map +1 -1
- package/dist/functions/trinketSet.lua +35 -46
- package/dist/index.d.ts +2 -13
- package/package.json +1 -1
- package/src/functions/collectibleSet.ts +38 -45
- package/src/functions/collectibles.ts +2 -1
- package/src/functions/trinketSet.ts +38 -45
|
@@ -45,9 +45,6 @@ export declare function getModdedCollectibleSet(): ReadonlySet<CollectibleType>;
|
|
|
45
45
|
*
|
|
46
46
|
* Use this if you need to iterate over the collectibles in order. If you need to do O(1) lookups,
|
|
47
47
|
* then use the `getVanillaCollectibleSet` helper function instead.
|
|
48
|
-
*
|
|
49
|
-
* This function can only be called if at least one callback has been executed. This is because not
|
|
50
|
-
* all collectibles will necessarily be present when a mod first loads (due to mod load order).
|
|
51
48
|
*/
|
|
52
49
|
export declare function getVanillaCollectibleArray(): readonly CollectibleType[];
|
|
53
50
|
/**
|
|
@@ -55,9 +52,6 @@ export declare function getVanillaCollectibleArray(): readonly CollectibleType[]
|
|
|
55
52
|
*
|
|
56
53
|
* Use this if you need to do O(1) lookups. If you need to iterate over the collectibles in order,
|
|
57
54
|
* then use the `getVanillaCollectibleArray` helper function instead.
|
|
58
|
-
*
|
|
59
|
-
* This function can only be called if at least one callback has been executed. This is because not
|
|
60
|
-
* all collectibles will necessarily be present when a mod first loads (due to mod load order).
|
|
61
55
|
*/
|
|
62
56
|
export declare function getVanillaCollectibleSet(): ReadonlySet<CollectibleType>;
|
|
63
57
|
//# sourceMappingURL=collectibleSet.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collectibleSet.d.ts","sourceRoot":"","sources":["../../src/functions/collectibleSet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"collectibleSet.d.ts","sourceRoot":"","sources":["../../src/functions/collectibleSet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAwD/D;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,IAAI,SAAS,eAAe,EAAE,CAGhE;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,IAAI,WAAW,CAAC,eAAe,CAAC,CAGhE;AAED;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,IAAI,SAAS,eAAe,EAAE,CAGtE;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,IAAI,WAAW,CAAC,eAAe,CAAC,CAGtE;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,IAAI,SAAS,eAAe,EAAE,CAGvE;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,IAAI,WAAW,CAAC,eAAe,CAAC,CAGvE"}
|
|
@@ -1,55 +1,50 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
2
|
local Set = ____lualib.Set
|
|
3
3
|
local __TS__New = ____lualib.__TS__New
|
|
4
|
-
local __TS__ArraySort = ____lualib.__TS__ArraySort
|
|
5
4
|
local ____exports = {}
|
|
6
5
|
local ____cachedClasses = require("core.cachedClasses")
|
|
7
6
|
local itemConfig = ____cachedClasses.itemConfig
|
|
8
|
-
local ____constantsFirstLast = require("core.constantsFirstLast")
|
|
9
|
-
local FIRST_COLLECTIBLE_TYPE = ____constantsFirstLast.FIRST_COLLECTIBLE_TYPE
|
|
10
|
-
local LAST_VANILLA_COLLECTIBLE_TYPE = ____constantsFirstLast.LAST_VANILLA_COLLECTIBLE_TYPE
|
|
11
7
|
local ____firstLast = require("features.firstLast")
|
|
12
|
-
local
|
|
13
|
-
local
|
|
14
|
-
local
|
|
8
|
+
local getModdedCollectibleTypes = ____firstLast.getModdedCollectibleTypes
|
|
9
|
+
local ____collectibles = require("functions.collectibles")
|
|
10
|
+
local getVanillaCollectibleTypeRange = ____collectibles.getVanillaCollectibleTypeRange
|
|
15
11
|
local ALL_COLLECTIBLES_ARRAY = {}
|
|
16
|
-
local VANILLA_COLLECTIBLES_ARRAY = {}
|
|
17
|
-
local MODDED_COLLECTIBLES_ARRAY = {}
|
|
18
12
|
local ALL_COLLECTIBLES_SET = __TS__New(Set)
|
|
13
|
+
local VANILLA_COLLECTIBLES_ARRAY = {}
|
|
19
14
|
local VANILLA_COLLECTIBLES_SET = __TS__New(Set)
|
|
15
|
+
local MODDED_COLLECTIBLES_ARRAY = {}
|
|
20
16
|
local MODDED_COLLECTIBLES_SET = __TS__New(Set)
|
|
21
|
-
local function
|
|
22
|
-
if #
|
|
17
|
+
local function lazyInitVanillaCollectibles(self)
|
|
18
|
+
if #VANILLA_COLLECTIBLES_ARRAY > 0 then
|
|
23
19
|
return
|
|
24
20
|
end
|
|
25
|
-
local
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
goto __continue4
|
|
32
|
-
end
|
|
33
|
-
ALL_COLLECTIBLES_ARRAY[#ALL_COLLECTIBLES_ARRAY + 1] = collectibleType
|
|
34
|
-
if collectibleType <= LAST_VANILLA_COLLECTIBLE_TYPE then
|
|
35
|
-
VANILLA_COLLECTIBLES_ARRAY[#VANILLA_COLLECTIBLES_ARRAY + 1] = collectibleType
|
|
36
|
-
else
|
|
37
|
-
MODDED_COLLECTIBLES_ARRAY[#MODDED_COLLECTIBLES_ARRAY + 1] = collectibleType
|
|
38
|
-
end
|
|
21
|
+
local vanillaCollectibleTypeRange = getVanillaCollectibleTypeRange(nil)
|
|
22
|
+
for ____, collectibleType in ipairs(vanillaCollectibleTypeRange) do
|
|
23
|
+
local itemConfigItem = itemConfig:GetCollectible(collectibleType)
|
|
24
|
+
if itemConfigItem ~= nil then
|
|
25
|
+
VANILLA_COLLECTIBLES_ARRAY[#VANILLA_COLLECTIBLES_ARRAY + 1] = collectibleType
|
|
26
|
+
VANILLA_COLLECTIBLES_SET:add(collectibleType)
|
|
39
27
|
end
|
|
40
|
-
::__continue4::
|
|
41
28
|
end
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
29
|
+
end
|
|
30
|
+
local function lazyInitModdedCollectibles(self)
|
|
31
|
+
if #MODDED_COLLECTIBLES_ARRAY > 0 then
|
|
32
|
+
return
|
|
45
33
|
end
|
|
46
|
-
|
|
34
|
+
lazyInitVanillaCollectibles(nil)
|
|
47
35
|
for ____, collectibleType in ipairs(VANILLA_COLLECTIBLES_ARRAY) do
|
|
48
|
-
|
|
36
|
+
ALL_COLLECTIBLES_ARRAY[#ALL_COLLECTIBLES_ARRAY + 1] = collectibleType
|
|
37
|
+
ALL_COLLECTIBLES_SET:add(collectibleType)
|
|
49
38
|
end
|
|
50
|
-
|
|
51
|
-
for ____, collectibleType in ipairs(
|
|
52
|
-
|
|
39
|
+
local moddedCollectibleTypes = getModdedCollectibleTypes(nil)
|
|
40
|
+
for ____, collectibleType in ipairs(moddedCollectibleTypes) do
|
|
41
|
+
local itemConfigItem = itemConfig:GetCollectible(collectibleType)
|
|
42
|
+
if itemConfigItem ~= nil then
|
|
43
|
+
MODDED_COLLECTIBLES_ARRAY[#MODDED_COLLECTIBLES_ARRAY + 1] = collectibleType
|
|
44
|
+
MODDED_COLLECTIBLES_SET:add(collectibleType)
|
|
45
|
+
ALL_COLLECTIBLES_ARRAY[#ALL_COLLECTIBLES_ARRAY + 1] = collectibleType
|
|
46
|
+
ALL_COLLECTIBLES_SET:add(collectibleType)
|
|
47
|
+
end
|
|
53
48
|
end
|
|
54
49
|
end
|
|
55
50
|
--- Returns an array containing every valid collectible type in the game, including modded
|
|
@@ -61,7 +56,7 @@ end
|
|
|
61
56
|
-- This function can only be called if at least one callback has been executed. This is because not
|
|
62
57
|
-- all collectibles will necessarily be present when a mod first loads (due to mod load order).
|
|
63
58
|
function ____exports.getCollectibleArray(self)
|
|
64
|
-
|
|
59
|
+
lazyInitModdedCollectibles(nil)
|
|
65
60
|
return ALL_COLLECTIBLES_ARRAY
|
|
66
61
|
end
|
|
67
62
|
--- Returns a set containing every valid collectible type in the game, including modded collectibles.
|
|
@@ -72,7 +67,7 @@ end
|
|
|
72
67
|
-- This function can only be called if at least one callback has been executed. This is because not
|
|
73
68
|
-- all collectibles will necessarily be present when a mod first loads (due to mod load order).
|
|
74
69
|
function ____exports.getCollectibleSet(self)
|
|
75
|
-
|
|
70
|
+
lazyInitModdedCollectibles(nil)
|
|
76
71
|
return ALL_COLLECTIBLES_SET
|
|
77
72
|
end
|
|
78
73
|
--- Returns an array containing every modded collectible type in the game.
|
|
@@ -83,7 +78,7 @@ end
|
|
|
83
78
|
-- This function can only be called if at least one callback has been executed. This is because not
|
|
84
79
|
-- all collectibles will necessarily be present when a mod first loads (due to mod load order).
|
|
85
80
|
function ____exports.getModdedCollectibleArray(self)
|
|
86
|
-
|
|
81
|
+
lazyInitModdedCollectibles(nil)
|
|
87
82
|
return MODDED_COLLECTIBLES_ARRAY
|
|
88
83
|
end
|
|
89
84
|
--- Returns a set containing every modded collectible type in the game.
|
|
@@ -94,29 +89,23 @@ end
|
|
|
94
89
|
-- This function can only be called if at least one callback has been executed. This is because not
|
|
95
90
|
-- all collectibles will necessarily be present when a mod first loads (due to mod load order).
|
|
96
91
|
function ____exports.getModdedCollectibleSet(self)
|
|
97
|
-
|
|
92
|
+
lazyInitModdedCollectibles(nil)
|
|
98
93
|
return MODDED_COLLECTIBLES_SET
|
|
99
94
|
end
|
|
100
95
|
--- Returns an array containing every valid vanilla collectible type in the game.
|
|
101
96
|
--
|
|
102
97
|
-- Use this if you need to iterate over the collectibles in order. If you need to do O(1) lookups,
|
|
103
98
|
-- then use the `getVanillaCollectibleSet` helper function instead.
|
|
104
|
-
--
|
|
105
|
-
-- This function can only be called if at least one callback has been executed. This is because not
|
|
106
|
-
-- all collectibles will necessarily be present when a mod first loads (due to mod load order).
|
|
107
99
|
function ____exports.getVanillaCollectibleArray(self)
|
|
108
|
-
|
|
100
|
+
lazyInitVanillaCollectibles(nil)
|
|
109
101
|
return VANILLA_COLLECTIBLES_ARRAY
|
|
110
102
|
end
|
|
111
103
|
--- Returns a set containing every valid vanilla collectible type in the game.
|
|
112
104
|
--
|
|
113
105
|
-- Use this if you need to do O(1) lookups. If you need to iterate over the collectibles in order,
|
|
114
106
|
-- then use the `getVanillaCollectibleArray` helper function instead.
|
|
115
|
-
--
|
|
116
|
-
-- This function can only be called if at least one callback has been executed. This is because not
|
|
117
|
-
-- all collectibles will necessarily be present when a mod first loads (due to mod load order).
|
|
118
107
|
function ____exports.getVanillaCollectibleSet(self)
|
|
119
|
-
|
|
108
|
+
lazyInitVanillaCollectibles(nil)
|
|
120
109
|
return VANILLA_COLLECTIBLES_SET
|
|
121
110
|
end
|
|
122
111
|
return ____exports
|
|
@@ -129,7 +129,8 @@ export declare function getCollectibleTags(collectibleType: CollectibleType): Bi
|
|
|
129
129
|
* collectible types.
|
|
130
130
|
*
|
|
131
131
|
* This function is only useful when building collectible type objects. For most purposes, you
|
|
132
|
-
* should use the `getVanillaCollectibleSet` helper
|
|
132
|
+
* should use the `getVanillaCollectibleArray` or `getVanillaCollectibleSet` helper functions
|
|
133
|
+
* instead.
|
|
133
134
|
*/
|
|
134
135
|
export declare function getVanillaCollectibleTypeRange(): CollectibleType[];
|
|
135
136
|
/** Returns true if the item type in the item config is equal to `ItemType.ITEM_ACTIVE`. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collectibles.d.ts","sourceRoot":"","sources":["../../src/functions/collectibles.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,eAAe,EAEf,aAAa,EAEb,QAAQ,EACR,WA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5E;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,YAAY,GAAG,IAAI,CASnE;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,YAAY,GAAG,IAAI,CAUnE;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,YAAY,GAAG,IAAI,CAuBtE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,YAAY,EACzB,OAAO,EAAE,MAAM,GAAG,SAAS,GAC1B,IAAI,CAeN;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,YAAY,EACzB,kBAAkB,EAAE,eAAe,GAClC,IAAI,CA2BN;AAED;;;GAGG;AACH,wBAAgB,qCAAqC,IAAI,IAAI,CAK5D"}
|
|
@@ -332,7 +332,8 @@ end
|
|
|
332
332
|
-- collectible types.
|
|
333
333
|
--
|
|
334
334
|
-- This function is only useful when building collectible type objects. For most purposes, you
|
|
335
|
-
-- should use the `getVanillaCollectibleSet` helper
|
|
335
|
+
-- should use the `getVanillaCollectibleArray` or `getVanillaCollectibleSet` helper functions
|
|
336
|
+
-- instead.
|
|
336
337
|
function ____exports.getVanillaCollectibleTypeRange(self)
|
|
337
338
|
return irange(nil, FIRST_COLLECTIBLE_TYPE, LAST_VANILLA_COLLECTIBLE_TYPE)
|
|
338
339
|
end
|
|
@@ -44,9 +44,6 @@ export declare function getTrinketSet(): ReadonlySet<TrinketType>;
|
|
|
44
44
|
*
|
|
45
45
|
* Use this if you need to iterate over the trinkets in order. If you need to do O(1) lookups, then
|
|
46
46
|
* use the `getVanillaTrinketSet` helper function instead.
|
|
47
|
-
*
|
|
48
|
-
* This function can only be called if at least one callback has been executed. This is because not
|
|
49
|
-
* all trinkets will necessarily be present when a mod first loads (due to mod load order).
|
|
50
47
|
*/
|
|
51
48
|
export declare function getVanillaTrinketArray(): readonly TrinketType[];
|
|
52
49
|
/**
|
|
@@ -54,9 +51,6 @@ export declare function getVanillaTrinketArray(): readonly TrinketType[];
|
|
|
54
51
|
*
|
|
55
52
|
* Use this if you need to do O(1) lookups. If you need to iterate over the trinkets in order, then
|
|
56
53
|
* use the `getVanillaTrinketArray` helper function instead.
|
|
57
|
-
*
|
|
58
|
-
* This function can only be called if at least one callback has been executed. This is because not
|
|
59
|
-
* all trinkets will necessarily be present when a mod first loads (due to mod load order).
|
|
60
54
|
*/
|
|
61
55
|
export declare function getVanillaTrinketSet(): ReadonlySet<TrinketType>;
|
|
62
56
|
//# sourceMappingURL=trinketSet.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trinketSet.d.ts","sourceRoot":"","sources":["../../src/functions/trinketSet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"trinketSet.d.ts","sourceRoot":"","sources":["../../src/functions/trinketSet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAwD3D;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,IAAI,SAAS,WAAW,EAAE,CAG9D;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,IAAI,WAAW,CAAC,WAAW,CAAC,CAG9D;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,IAAI,SAAS,WAAW,EAAE,CAGxD;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,IAAI,WAAW,CAAC,WAAW,CAAC,CAGxD;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,IAAI,SAAS,WAAW,EAAE,CAG/D;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,IAAI,WAAW,CAAC,WAAW,CAAC,CAG/D"}
|
|
@@ -1,55 +1,50 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
2
|
local Set = ____lualib.Set
|
|
3
3
|
local __TS__New = ____lualib.__TS__New
|
|
4
|
-
local __TS__ArraySort = ____lualib.__TS__ArraySort
|
|
5
4
|
local ____exports = {}
|
|
6
5
|
local ____cachedClasses = require("core.cachedClasses")
|
|
7
6
|
local itemConfig = ____cachedClasses.itemConfig
|
|
8
|
-
local ____constantsFirstLast = require("core.constantsFirstLast")
|
|
9
|
-
local FIRST_TRINKET_TYPE = ____constantsFirstLast.FIRST_TRINKET_TYPE
|
|
10
|
-
local LAST_VANILLA_TRINKET_TYPE = ____constantsFirstLast.LAST_VANILLA_TRINKET_TYPE
|
|
11
7
|
local ____firstLast = require("features.firstLast")
|
|
12
|
-
local
|
|
13
|
-
local
|
|
14
|
-
local
|
|
8
|
+
local getModdedTrinketTypes = ____firstLast.getModdedTrinketTypes
|
|
9
|
+
local ____trinkets = require("functions.trinkets")
|
|
10
|
+
local getVanillaTrinketTypes = ____trinkets.getVanillaTrinketTypes
|
|
15
11
|
local ALL_TRINKETS_ARRAY = {}
|
|
16
|
-
local VANILLA_TRINKETS_ARRAY = {}
|
|
17
|
-
local MODDED_TRINKETS_ARRAY = {}
|
|
18
12
|
local ALL_TRINKETS_SET = __TS__New(Set)
|
|
13
|
+
local VANILLA_TRINKETS_ARRAY = {}
|
|
19
14
|
local VANILLA_TRINKETS_SET = __TS__New(Set)
|
|
15
|
+
local MODDED_TRINKETS_ARRAY = {}
|
|
20
16
|
local MODDED_TRINKETS_SET = __TS__New(Set)
|
|
21
|
-
local function
|
|
22
|
-
if #
|
|
17
|
+
local function lazyInitVanillaTrinkets(self)
|
|
18
|
+
if #VANILLA_TRINKETS_ARRAY > 0 then
|
|
23
19
|
return
|
|
24
20
|
end
|
|
25
|
-
local
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
goto __continue4
|
|
32
|
-
end
|
|
33
|
-
ALL_TRINKETS_ARRAY[#ALL_TRINKETS_ARRAY + 1] = trinketType
|
|
34
|
-
if trinketType <= LAST_VANILLA_TRINKET_TYPE then
|
|
35
|
-
VANILLA_TRINKETS_ARRAY[#VANILLA_TRINKETS_ARRAY + 1] = trinketType
|
|
36
|
-
else
|
|
37
|
-
MODDED_TRINKETS_ARRAY[#MODDED_TRINKETS_ARRAY + 1] = trinketType
|
|
38
|
-
end
|
|
21
|
+
local vanillaTrinketTypes = getVanillaTrinketTypes(nil)
|
|
22
|
+
for ____, trinketType in ipairs(vanillaTrinketTypes) do
|
|
23
|
+
local itemConfigItem = itemConfig:GetTrinket(trinketType)
|
|
24
|
+
if itemConfigItem ~= nil then
|
|
25
|
+
VANILLA_TRINKETS_ARRAY[#VANILLA_TRINKETS_ARRAY + 1] = trinketType
|
|
26
|
+
VANILLA_TRINKETS_SET:add(trinketType)
|
|
39
27
|
end
|
|
40
|
-
::__continue4::
|
|
41
28
|
end
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
29
|
+
end
|
|
30
|
+
local function lazyInitModdedTrinkets(self)
|
|
31
|
+
if #MODDED_TRINKETS_ARRAY > 0 then
|
|
32
|
+
return
|
|
45
33
|
end
|
|
46
|
-
|
|
34
|
+
lazyInitVanillaTrinkets(nil)
|
|
47
35
|
for ____, trinketType in ipairs(VANILLA_TRINKETS_ARRAY) do
|
|
48
|
-
|
|
36
|
+
ALL_TRINKETS_ARRAY[#ALL_TRINKETS_ARRAY + 1] = trinketType
|
|
37
|
+
ALL_TRINKETS_SET:add(trinketType)
|
|
49
38
|
end
|
|
50
|
-
|
|
51
|
-
for ____, trinketType in ipairs(
|
|
52
|
-
|
|
39
|
+
local moddedTrinketTypes = getModdedTrinketTypes(nil)
|
|
40
|
+
for ____, trinketType in ipairs(moddedTrinketTypes) do
|
|
41
|
+
local itemConfigItem = itemConfig:GetTrinket(trinketType)
|
|
42
|
+
if itemConfigItem ~= nil then
|
|
43
|
+
MODDED_TRINKETS_ARRAY[#MODDED_TRINKETS_ARRAY + 1] = trinketType
|
|
44
|
+
MODDED_TRINKETS_SET:add(trinketType)
|
|
45
|
+
ALL_TRINKETS_ARRAY[#ALL_TRINKETS_ARRAY + 1] = trinketType
|
|
46
|
+
ALL_TRINKETS_SET:add(trinketType)
|
|
47
|
+
end
|
|
53
48
|
end
|
|
54
49
|
end
|
|
55
50
|
--- Returns an array containing every valid trinket type in the game, including modded trinkets.
|
|
@@ -60,7 +55,7 @@ end
|
|
|
60
55
|
-- This function can only be called if at least one callback has been executed. This is because not
|
|
61
56
|
-- all trinkets will necessarily be present when a mod first loads (due to mod load order).
|
|
62
57
|
function ____exports.getModdedTrinketArray(self)
|
|
63
|
-
|
|
58
|
+
lazyInitModdedTrinkets(nil)
|
|
64
59
|
return MODDED_TRINKETS_ARRAY
|
|
65
60
|
end
|
|
66
61
|
--- Returns a set containing every valid trinket type in the game, including modded trinkets.
|
|
@@ -71,7 +66,7 @@ end
|
|
|
71
66
|
-- This function can only be called if at least one callback has been executed. This is because not
|
|
72
67
|
-- all trinkets will necessarily be present when a mod first loads (due to mod load order).
|
|
73
68
|
function ____exports.getModdedTrinketSet(self)
|
|
74
|
-
|
|
69
|
+
lazyInitModdedTrinkets(nil)
|
|
75
70
|
return MODDED_TRINKETS_SET
|
|
76
71
|
end
|
|
77
72
|
--- Returns an array containing every modded trinket type in the game.
|
|
@@ -82,7 +77,7 @@ end
|
|
|
82
77
|
-- This function can only be called if at least one callback has been executed. This is because not
|
|
83
78
|
-- all trinkets will necessarily be present when a mod first loads (due to mod load order).
|
|
84
79
|
function ____exports.getTrinketArray(self)
|
|
85
|
-
|
|
80
|
+
lazyInitModdedTrinkets(nil)
|
|
86
81
|
return ALL_TRINKETS_ARRAY
|
|
87
82
|
end
|
|
88
83
|
--- Returns a set containing every modded trinket type in the game.
|
|
@@ -93,29 +88,23 @@ end
|
|
|
93
88
|
-- This function can only be called if at least one callback has been executed. This is because not
|
|
94
89
|
-- all trinkets will necessarily be present when a mod first loads (due to mod load order).
|
|
95
90
|
function ____exports.getTrinketSet(self)
|
|
96
|
-
|
|
91
|
+
lazyInitModdedTrinkets(nil)
|
|
97
92
|
return ALL_TRINKETS_SET
|
|
98
93
|
end
|
|
99
94
|
--- Returns an array containing every valid vanilla trinket type in the game.
|
|
100
95
|
--
|
|
101
96
|
-- Use this if you need to iterate over the trinkets in order. If you need to do O(1) lookups, then
|
|
102
97
|
-- use the `getVanillaTrinketSet` helper function instead.
|
|
103
|
-
--
|
|
104
|
-
-- This function can only be called if at least one callback has been executed. This is because not
|
|
105
|
-
-- all trinkets will necessarily be present when a mod first loads (due to mod load order).
|
|
106
98
|
function ____exports.getVanillaTrinketArray(self)
|
|
107
|
-
|
|
99
|
+
lazyInitVanillaTrinkets(nil)
|
|
108
100
|
return VANILLA_TRINKETS_ARRAY
|
|
109
101
|
end
|
|
110
102
|
--- Returns a set containing every valid vanilla trinket type in the game.
|
|
111
103
|
--
|
|
112
104
|
-- Use this if you need to do O(1) lookups. If you need to iterate over the trinkets in order, then
|
|
113
105
|
-- use the `getVanillaTrinketArray` helper function instead.
|
|
114
|
-
--
|
|
115
|
-
-- This function can only be called if at least one callback has been executed. This is because not
|
|
116
|
-
-- all trinkets will necessarily be present when a mod first loads (due to mod load order).
|
|
117
106
|
function ____exports.getVanillaTrinketSet(self)
|
|
118
|
-
|
|
107
|
+
lazyInitVanillaTrinkets(nil)
|
|
119
108
|
return VANILLA_TRINKETS_SET
|
|
120
109
|
end
|
|
121
110
|
return ____exports
|
package/dist/index.d.ts
CHANGED
|
@@ -5098,9 +5098,6 @@ export declare function getVanillaCards(): Card[];
|
|
|
5098
5098
|
*
|
|
5099
5099
|
* Use this if you need to iterate over the collectibles in order. If you need to do O(1) lookups,
|
|
5100
5100
|
* then use the `getVanillaCollectibleSet` helper function instead.
|
|
5101
|
-
*
|
|
5102
|
-
* This function can only be called if at least one callback has been executed. This is because not
|
|
5103
|
-
* all collectibles will necessarily be present when a mod first loads (due to mod load order).
|
|
5104
5101
|
*/
|
|
5105
5102
|
export declare function getVanillaCollectibleArray(): readonly CollectibleType[];
|
|
5106
5103
|
|
|
@@ -5109,9 +5106,6 @@ export declare function getVanillaCollectibleArray(): readonly CollectibleType[]
|
|
|
5109
5106
|
*
|
|
5110
5107
|
* Use this if you need to do O(1) lookups. If you need to iterate over the collectibles in order,
|
|
5111
5108
|
* then use the `getVanillaCollectibleArray` helper function instead.
|
|
5112
|
-
*
|
|
5113
|
-
* This function can only be called if at least one callback has been executed. This is because not
|
|
5114
|
-
* all collectibles will necessarily be present when a mod first loads (due to mod load order).
|
|
5115
5109
|
*/
|
|
5116
5110
|
export declare function getVanillaCollectibleSet(): ReadonlySet<CollectibleType>;
|
|
5117
5111
|
|
|
@@ -5121,7 +5115,8 @@ export declare function getVanillaCollectibleSet(): ReadonlySet<CollectibleType>
|
|
|
5121
5115
|
* collectible types.
|
|
5122
5116
|
*
|
|
5123
5117
|
* This function is only useful when building collectible type objects. For most purposes, you
|
|
5124
|
-
* should use the `getVanillaCollectibleSet` helper
|
|
5118
|
+
* should use the `getVanillaCollectibleArray` or `getVanillaCollectibleSet` helper functions
|
|
5119
|
+
* instead.
|
|
5125
5120
|
*/
|
|
5126
5121
|
export declare function getVanillaCollectibleTypeRange(): CollectibleType[];
|
|
5127
5122
|
|
|
@@ -5133,9 +5128,6 @@ export declare function getVanillaPillEffects(): PillEffect[];
|
|
|
5133
5128
|
*
|
|
5134
5129
|
* Use this if you need to iterate over the trinkets in order. If you need to do O(1) lookups, then
|
|
5135
5130
|
* use the `getVanillaTrinketSet` helper function instead.
|
|
5136
|
-
*
|
|
5137
|
-
* This function can only be called if at least one callback has been executed. This is because not
|
|
5138
|
-
* all trinkets will necessarily be present when a mod first loads (due to mod load order).
|
|
5139
5131
|
*/
|
|
5140
5132
|
export declare function getVanillaTrinketArray(): readonly TrinketType[];
|
|
5141
5133
|
|
|
@@ -5144,9 +5136,6 @@ export declare function getVanillaTrinketArray(): readonly TrinketType[];
|
|
|
5144
5136
|
*
|
|
5145
5137
|
* Use this if you need to do O(1) lookups. If you need to iterate over the trinkets in order, then
|
|
5146
5138
|
* use the `getVanillaTrinketArray` helper function instead.
|
|
5147
|
-
*
|
|
5148
|
-
* This function can only be called if at least one callback has been executed. This is because not
|
|
5149
|
-
* all trinkets will necessarily be present when a mod first loads (due to mod load order).
|
|
5150
5139
|
*/
|
|
5151
5140
|
export declare function getVanillaTrinketSet(): ReadonlySet<TrinketType>;
|
|
5152
5141
|
|
package/package.json
CHANGED
|
@@ -1,57 +1,56 @@
|
|
|
1
1
|
import { CollectibleType } from "isaac-typescript-definitions";
|
|
2
2
|
import { itemConfig } from "../core/cachedClasses";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
LAST_VANILLA_COLLECTIBLE_TYPE,
|
|
6
|
-
} from "../core/constantsFirstLast";
|
|
7
|
-
import { getLastCollectibleType } from "../features/firstLast";
|
|
8
|
-
import { irange } from "./utils";
|
|
3
|
+
import { getModdedCollectibleTypes } from "../features/firstLast";
|
|
4
|
+
import { getVanillaCollectibleTypeRange } from "./collectibles";
|
|
9
5
|
|
|
10
6
|
const ALL_COLLECTIBLES_ARRAY: CollectibleType[] = [];
|
|
11
|
-
const VANILLA_COLLECTIBLES_ARRAY: CollectibleType[] = [];
|
|
12
|
-
const MODDED_COLLECTIBLES_ARRAY: CollectibleType[] = [];
|
|
13
|
-
|
|
14
7
|
const ALL_COLLECTIBLES_SET = new Set<CollectibleType>();
|
|
8
|
+
|
|
9
|
+
const VANILLA_COLLECTIBLES_ARRAY: CollectibleType[] = [];
|
|
15
10
|
const VANILLA_COLLECTIBLES_SET = new Set<CollectibleType>();
|
|
11
|
+
|
|
12
|
+
const MODDED_COLLECTIBLES_ARRAY: CollectibleType[] = [];
|
|
16
13
|
const MODDED_COLLECTIBLES_SET = new Set<CollectibleType>();
|
|
17
14
|
|
|
18
|
-
function
|
|
19
|
-
if (
|
|
15
|
+
function lazyInitVanillaCollectibles() {
|
|
16
|
+
if (VANILLA_COLLECTIBLES_ARRAY.length > 0) {
|
|
20
17
|
return;
|
|
21
18
|
}
|
|
22
19
|
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
lastCollectibleType,
|
|
27
|
-
) as CollectibleType[];
|
|
28
|
-
for (const collectibleType of collectibleTypeRange) {
|
|
20
|
+
const vanillaCollectibleTypeRange = getVanillaCollectibleTypeRange();
|
|
21
|
+
for (const collectibleType of vanillaCollectibleTypeRange) {
|
|
22
|
+
// Vanilla collectible types are not contiguous, so we must check every value.
|
|
29
23
|
const itemConfigItem = itemConfig.GetCollectible(collectibleType);
|
|
30
|
-
if (itemConfigItem
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
ALL_COLLECTIBLES_ARRAY.push(collectibleType);
|
|
35
|
-
if (collectibleType <= LAST_VANILLA_COLLECTIBLE_TYPE) {
|
|
24
|
+
if (itemConfigItem !== undefined) {
|
|
36
25
|
VANILLA_COLLECTIBLES_ARRAY.push(collectibleType);
|
|
37
|
-
|
|
38
|
-
MODDED_COLLECTIBLES_ARRAY.push(collectibleType);
|
|
26
|
+
VANILLA_COLLECTIBLES_SET.add(collectibleType);
|
|
39
27
|
}
|
|
40
28
|
}
|
|
29
|
+
}
|
|
41
30
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
31
|
+
function lazyInitModdedCollectibles() {
|
|
32
|
+
if (MODDED_COLLECTIBLES_ARRAY.length > 0) {
|
|
33
|
+
return;
|
|
45
34
|
}
|
|
46
35
|
|
|
47
|
-
|
|
36
|
+
lazyInitVanillaCollectibles();
|
|
37
|
+
|
|
48
38
|
for (const collectibleType of VANILLA_COLLECTIBLES_ARRAY) {
|
|
49
|
-
|
|
39
|
+
ALL_COLLECTIBLES_ARRAY.push(collectibleType);
|
|
40
|
+
ALL_COLLECTIBLES_SET.add(collectibleType);
|
|
50
41
|
}
|
|
51
42
|
|
|
52
|
-
|
|
53
|
-
for (const collectibleType of
|
|
54
|
-
|
|
43
|
+
const moddedCollectibleTypes = getModdedCollectibleTypes();
|
|
44
|
+
for (const collectibleType of moddedCollectibleTypes) {
|
|
45
|
+
// Modded collectible types are contiguous, but we check every value just in case.
|
|
46
|
+
const itemConfigItem = itemConfig.GetCollectible(collectibleType);
|
|
47
|
+
if (itemConfigItem !== undefined) {
|
|
48
|
+
MODDED_COLLECTIBLES_ARRAY.push(collectibleType);
|
|
49
|
+
MODDED_COLLECTIBLES_SET.add(collectibleType);
|
|
50
|
+
|
|
51
|
+
ALL_COLLECTIBLES_ARRAY.push(collectibleType);
|
|
52
|
+
ALL_COLLECTIBLES_SET.add(collectibleType);
|
|
53
|
+
}
|
|
55
54
|
}
|
|
56
55
|
}
|
|
57
56
|
|
|
@@ -66,7 +65,7 @@ function lazyInitCollectibleArraysAndSets() {
|
|
|
66
65
|
* all collectibles will necessarily be present when a mod first loads (due to mod load order).
|
|
67
66
|
*/
|
|
68
67
|
export function getCollectibleArray(): readonly CollectibleType[] {
|
|
69
|
-
|
|
68
|
+
lazyInitModdedCollectibles();
|
|
70
69
|
return ALL_COLLECTIBLES_ARRAY;
|
|
71
70
|
}
|
|
72
71
|
|
|
@@ -80,7 +79,7 @@ export function getCollectibleArray(): readonly CollectibleType[] {
|
|
|
80
79
|
* all collectibles will necessarily be present when a mod first loads (due to mod load order).
|
|
81
80
|
*/
|
|
82
81
|
export function getCollectibleSet(): ReadonlySet<CollectibleType> {
|
|
83
|
-
|
|
82
|
+
lazyInitModdedCollectibles();
|
|
84
83
|
return ALL_COLLECTIBLES_SET;
|
|
85
84
|
}
|
|
86
85
|
|
|
@@ -94,7 +93,7 @@ export function getCollectibleSet(): ReadonlySet<CollectibleType> {
|
|
|
94
93
|
* all collectibles will necessarily be present when a mod first loads (due to mod load order).
|
|
95
94
|
*/
|
|
96
95
|
export function getModdedCollectibleArray(): readonly CollectibleType[] {
|
|
97
|
-
|
|
96
|
+
lazyInitModdedCollectibles();
|
|
98
97
|
return MODDED_COLLECTIBLES_ARRAY;
|
|
99
98
|
}
|
|
100
99
|
|
|
@@ -108,7 +107,7 @@ export function getModdedCollectibleArray(): readonly CollectibleType[] {
|
|
|
108
107
|
* all collectibles will necessarily be present when a mod first loads (due to mod load order).
|
|
109
108
|
*/
|
|
110
109
|
export function getModdedCollectibleSet(): ReadonlySet<CollectibleType> {
|
|
111
|
-
|
|
110
|
+
lazyInitModdedCollectibles();
|
|
112
111
|
return MODDED_COLLECTIBLES_SET;
|
|
113
112
|
}
|
|
114
113
|
|
|
@@ -117,12 +116,9 @@ export function getModdedCollectibleSet(): ReadonlySet<CollectibleType> {
|
|
|
117
116
|
*
|
|
118
117
|
* Use this if you need to iterate over the collectibles in order. If you need to do O(1) lookups,
|
|
119
118
|
* then use the `getVanillaCollectibleSet` helper function instead.
|
|
120
|
-
*
|
|
121
|
-
* This function can only be called if at least one callback has been executed. This is because not
|
|
122
|
-
* all collectibles will necessarily be present when a mod first loads (due to mod load order).
|
|
123
119
|
*/
|
|
124
120
|
export function getVanillaCollectibleArray(): readonly CollectibleType[] {
|
|
125
|
-
|
|
121
|
+
lazyInitVanillaCollectibles();
|
|
126
122
|
return VANILLA_COLLECTIBLES_ARRAY;
|
|
127
123
|
}
|
|
128
124
|
|
|
@@ -131,11 +127,8 @@ export function getVanillaCollectibleArray(): readonly CollectibleType[] {
|
|
|
131
127
|
*
|
|
132
128
|
* Use this if you need to do O(1) lookups. If you need to iterate over the collectibles in order,
|
|
133
129
|
* then use the `getVanillaCollectibleArray` helper function instead.
|
|
134
|
-
*
|
|
135
|
-
* This function can only be called if at least one callback has been executed. This is because not
|
|
136
|
-
* all collectibles will necessarily be present when a mod first loads (due to mod load order).
|
|
137
130
|
*/
|
|
138
131
|
export function getVanillaCollectibleSet(): ReadonlySet<CollectibleType> {
|
|
139
|
-
|
|
132
|
+
lazyInitVanillaCollectibles();
|
|
140
133
|
return VANILLA_COLLECTIBLES_SET;
|
|
141
134
|
}
|
|
@@ -376,7 +376,8 @@ export function getCollectibleTags(
|
|
|
376
376
|
* collectible types.
|
|
377
377
|
*
|
|
378
378
|
* This function is only useful when building collectible type objects. For most purposes, you
|
|
379
|
-
* should use the `getVanillaCollectibleSet` helper
|
|
379
|
+
* should use the `getVanillaCollectibleArray` or `getVanillaCollectibleSet` helper functions
|
|
380
|
+
* instead.
|
|
380
381
|
*/
|
|
381
382
|
export function getVanillaCollectibleTypeRange(): CollectibleType[] {
|
|
382
383
|
return irange(FIRST_COLLECTIBLE_TYPE, LAST_VANILLA_COLLECTIBLE_TYPE);
|
|
@@ -1,57 +1,56 @@
|
|
|
1
1
|
import { TrinketType } from "isaac-typescript-definitions";
|
|
2
2
|
import { itemConfig } from "../core/cachedClasses";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
LAST_VANILLA_TRINKET_TYPE,
|
|
6
|
-
} from "../core/constantsFirstLast";
|
|
7
|
-
import { getLastTrinketType } from "../features/firstLast";
|
|
8
|
-
import { irange } from "./utils";
|
|
3
|
+
import { getModdedTrinketTypes } from "../features/firstLast";
|
|
4
|
+
import { getVanillaTrinketTypes } from "./trinkets";
|
|
9
5
|
|
|
10
6
|
const ALL_TRINKETS_ARRAY: TrinketType[] = [];
|
|
11
|
-
const VANILLA_TRINKETS_ARRAY: TrinketType[] = [];
|
|
12
|
-
const MODDED_TRINKETS_ARRAY: TrinketType[] = [];
|
|
13
|
-
|
|
14
7
|
const ALL_TRINKETS_SET = new Set<TrinketType>();
|
|
8
|
+
|
|
9
|
+
const VANILLA_TRINKETS_ARRAY: TrinketType[] = [];
|
|
15
10
|
const VANILLA_TRINKETS_SET = new Set<TrinketType>();
|
|
11
|
+
|
|
12
|
+
const MODDED_TRINKETS_ARRAY: TrinketType[] = [];
|
|
16
13
|
const MODDED_TRINKETS_SET = new Set<TrinketType>();
|
|
17
14
|
|
|
18
|
-
function
|
|
19
|
-
if (
|
|
15
|
+
function lazyInitVanillaTrinkets() {
|
|
16
|
+
if (VANILLA_TRINKETS_ARRAY.length > 0) {
|
|
20
17
|
return;
|
|
21
18
|
}
|
|
22
19
|
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
lastTrinketType,
|
|
27
|
-
) as TrinketType[];
|
|
28
|
-
for (const trinketType of trinketTypeRange) {
|
|
20
|
+
const vanillaTrinketTypes = getVanillaTrinketTypes();
|
|
21
|
+
for (const trinketType of vanillaTrinketTypes) {
|
|
22
|
+
// Vanilla trinket types are contiguous, but we check every value just in case.
|
|
29
23
|
const itemConfigItem = itemConfig.GetTrinket(trinketType);
|
|
30
|
-
if (itemConfigItem
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
ALL_TRINKETS_ARRAY.push(trinketType);
|
|
35
|
-
if (trinketType <= LAST_VANILLA_TRINKET_TYPE) {
|
|
24
|
+
if (itemConfigItem !== undefined) {
|
|
36
25
|
VANILLA_TRINKETS_ARRAY.push(trinketType);
|
|
37
|
-
|
|
38
|
-
MODDED_TRINKETS_ARRAY.push(trinketType);
|
|
26
|
+
VANILLA_TRINKETS_SET.add(trinketType);
|
|
39
27
|
}
|
|
40
28
|
}
|
|
29
|
+
}
|
|
41
30
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
31
|
+
function lazyInitModdedTrinkets() {
|
|
32
|
+
if (MODDED_TRINKETS_ARRAY.length > 0) {
|
|
33
|
+
return;
|
|
45
34
|
}
|
|
46
35
|
|
|
47
|
-
|
|
36
|
+
lazyInitVanillaTrinkets();
|
|
37
|
+
|
|
48
38
|
for (const trinketType of VANILLA_TRINKETS_ARRAY) {
|
|
49
|
-
|
|
39
|
+
ALL_TRINKETS_ARRAY.push(trinketType);
|
|
40
|
+
ALL_TRINKETS_SET.add(trinketType);
|
|
50
41
|
}
|
|
51
42
|
|
|
52
|
-
|
|
53
|
-
for (const trinketType of
|
|
54
|
-
|
|
43
|
+
const moddedTrinketTypes = getModdedTrinketTypes();
|
|
44
|
+
for (const trinketType of moddedTrinketTypes) {
|
|
45
|
+
// Modded trinket types are contiguous, but we check every value just in case.
|
|
46
|
+
const itemConfigItem = itemConfig.GetTrinket(trinketType);
|
|
47
|
+
if (itemConfigItem !== undefined) {
|
|
48
|
+
MODDED_TRINKETS_ARRAY.push(trinketType);
|
|
49
|
+
MODDED_TRINKETS_SET.add(trinketType);
|
|
50
|
+
|
|
51
|
+
ALL_TRINKETS_ARRAY.push(trinketType);
|
|
52
|
+
ALL_TRINKETS_SET.add(trinketType);
|
|
53
|
+
}
|
|
55
54
|
}
|
|
56
55
|
}
|
|
57
56
|
|
|
@@ -65,7 +64,7 @@ function lazyInitTrinketArraysAndSets() {
|
|
|
65
64
|
* all trinkets will necessarily be present when a mod first loads (due to mod load order).
|
|
66
65
|
*/
|
|
67
66
|
export function getModdedTrinketArray(): readonly TrinketType[] {
|
|
68
|
-
|
|
67
|
+
lazyInitModdedTrinkets();
|
|
69
68
|
return MODDED_TRINKETS_ARRAY;
|
|
70
69
|
}
|
|
71
70
|
|
|
@@ -79,7 +78,7 @@ export function getModdedTrinketArray(): readonly TrinketType[] {
|
|
|
79
78
|
* all trinkets will necessarily be present when a mod first loads (due to mod load order).
|
|
80
79
|
*/
|
|
81
80
|
export function getModdedTrinketSet(): ReadonlySet<TrinketType> {
|
|
82
|
-
|
|
81
|
+
lazyInitModdedTrinkets();
|
|
83
82
|
return MODDED_TRINKETS_SET;
|
|
84
83
|
}
|
|
85
84
|
|
|
@@ -93,7 +92,7 @@ export function getModdedTrinketSet(): ReadonlySet<TrinketType> {
|
|
|
93
92
|
* all trinkets will necessarily be present when a mod first loads (due to mod load order).
|
|
94
93
|
*/
|
|
95
94
|
export function getTrinketArray(): readonly TrinketType[] {
|
|
96
|
-
|
|
95
|
+
lazyInitModdedTrinkets();
|
|
97
96
|
return ALL_TRINKETS_ARRAY;
|
|
98
97
|
}
|
|
99
98
|
|
|
@@ -107,7 +106,7 @@ export function getTrinketArray(): readonly TrinketType[] {
|
|
|
107
106
|
* all trinkets will necessarily be present when a mod first loads (due to mod load order).
|
|
108
107
|
*/
|
|
109
108
|
export function getTrinketSet(): ReadonlySet<TrinketType> {
|
|
110
|
-
|
|
109
|
+
lazyInitModdedTrinkets();
|
|
111
110
|
return ALL_TRINKETS_SET;
|
|
112
111
|
}
|
|
113
112
|
|
|
@@ -116,12 +115,9 @@ export function getTrinketSet(): ReadonlySet<TrinketType> {
|
|
|
116
115
|
*
|
|
117
116
|
* Use this if you need to iterate over the trinkets in order. If you need to do O(1) lookups, then
|
|
118
117
|
* use the `getVanillaTrinketSet` helper function instead.
|
|
119
|
-
*
|
|
120
|
-
* This function can only be called if at least one callback has been executed. This is because not
|
|
121
|
-
* all trinkets will necessarily be present when a mod first loads (due to mod load order).
|
|
122
118
|
*/
|
|
123
119
|
export function getVanillaTrinketArray(): readonly TrinketType[] {
|
|
124
|
-
|
|
120
|
+
lazyInitVanillaTrinkets();
|
|
125
121
|
return VANILLA_TRINKETS_ARRAY;
|
|
126
122
|
}
|
|
127
123
|
|
|
@@ -130,11 +126,8 @@ export function getVanillaTrinketArray(): readonly TrinketType[] {
|
|
|
130
126
|
*
|
|
131
127
|
* Use this if you need to do O(1) lookups. If you need to iterate over the trinkets in order, then
|
|
132
128
|
* use the `getVanillaTrinketArray` helper function instead.
|
|
133
|
-
*
|
|
134
|
-
* This function can only be called if at least one callback has been executed. This is because not
|
|
135
|
-
* all trinkets will necessarily be present when a mod first loads (due to mod load order).
|
|
136
129
|
*/
|
|
137
130
|
export function getVanillaTrinketSet(): ReadonlySet<TrinketType> {
|
|
138
|
-
|
|
131
|
+
lazyInitVanillaTrinkets();
|
|
139
132
|
return VANILLA_TRINKETS_SET;
|
|
140
133
|
}
|