isaacscript-common 8.4.1 → 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/hex.d.ts +16 -0
- package/dist/functions/hex.d.ts.map +1 -0
- package/dist/functions/hex.lua +51 -0
- package/dist/functions/playerHealth.d.ts +1 -1
- package/dist/functions/playerHealth.d.ts.map +1 -1
- package/dist/functions/playerHealth.lua +20 -3
- 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/functions/utils.d.ts +0 -14
- package/dist/functions/utils.d.ts.map +1 -1
- package/dist/functions/utils.lua +0 -43
- package/dist/index.d.ts +3 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.lua +8 -0
- package/package.json +1 -1
- package/src/functions/collectibleSet.ts +38 -45
- package/src/functions/collectibles.ts +2 -1
- package/src/functions/hex.ts +60 -0
- package/src/functions/playerHealth.ts +17 -3
- package/src/functions/trinketSet.ts +38 -45
- package/src/functions/utils.ts +0 -55
- package/src/index.ts +1 -0
|
@@ -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,WAAW,EAGZ,MAAM,8BAA8B,CAAC;AAgBtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAyB7D,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,YAAY,GAAG,IAAI,CAEtE;AAED,6FAA6F;AAC7F,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GACd,OAAO,CAsBT;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,eAAe,EAAE,eAAe,GAC/B,MAAM,CAeR;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAC1C,eAAe,EAAE,eAAe,GAC/B,GAAG,CAYL;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAC3C,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,YAAY,GACnB,WAAW,CAyBb;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,eAAe,EAAE,eAAe,GAC/B,MAAM,CAOR;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,YAAY,GACxB,gBAAgB,CAsBlB;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,eAAe,EAAE,eAAe,GAC/B,GAAG,CAOL;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,C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AC/B,OAAO,CAGT;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,eAAe,EAAE,eAAe,GAC/B,OAAO,CAET;AAED,wBAAgB,sBAAsB,CACpC,eAAe,EAAE,eAAe,GAC/B,OAAO,CAGT;AAED,wBAAgB,wBAAwB,CACtC,eAAe,EAAE,eAAe,GAC/B,OAAO,CAET;AAED;;;;;;GAMG;AACH,wBAAgB,gCAAgC,CAC9C,eAAe,EAAE,eAAe,GAC/B,IAAI,CAQN;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,WAAW,EAAE,YAAY,GAAG,IAAI,CAS5E;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
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
3
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
4
|
+
/**
|
|
5
|
+
* Converts a hex string like "#33aa33" to a KColor object.
|
|
6
|
+
*
|
|
7
|
+
* @param hexString A hex string like "#ffffff" or "ffffff". (The "#" character is optional.)
|
|
8
|
+
*/
|
|
9
|
+
export declare function hexToColor(hexString: string, alpha: float): Color;
|
|
10
|
+
/**
|
|
11
|
+
* Converts a hex string like "#33aa33" to a Color object.
|
|
12
|
+
*
|
|
13
|
+
* @param hexString A hex string like "#ffffff" or "ffffff". (The "#" character is optional.)
|
|
14
|
+
*/
|
|
15
|
+
export declare function hexToKColor(hexString: string, alpha: float): KColor;
|
|
16
|
+
//# sourceMappingURL=hex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hex.d.ts","sourceRoot":"","sources":["../../src/functions/hex.ts"],"names":[],"mappings":";;;AAIA;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,KAAK,CAMjE;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,MAAM,CAMnE"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__StringReplace = ____lualib.__TS__StringReplace
|
|
3
|
+
local __TS__StringSubstring = ____lualib.__TS__StringSubstring
|
|
4
|
+
local ____exports = {}
|
|
5
|
+
local hexToRGB, HEX_STRING_LENGTH
|
|
6
|
+
local ____log = require("functions.log")
|
|
7
|
+
local logError = ____log.logError
|
|
8
|
+
function hexToRGB(self, hexString)
|
|
9
|
+
hexString = __TS__StringReplace(hexString, "#", "")
|
|
10
|
+
if #hexString ~= HEX_STRING_LENGTH then
|
|
11
|
+
logError("Hex strings must be of length: " .. tostring(HEX_STRING_LENGTH))
|
|
12
|
+
return {0, 0, 0}
|
|
13
|
+
end
|
|
14
|
+
local rString = __TS__StringSubstring(hexString, 0, 2)
|
|
15
|
+
local r = tonumber("0x" .. rString)
|
|
16
|
+
if r == nil then
|
|
17
|
+
logError(("Failed to convert `0x" .. rString) .. "` to a number.")
|
|
18
|
+
return {0, 0, 0}
|
|
19
|
+
end
|
|
20
|
+
local gString = __TS__StringSubstring(hexString, 2, 4)
|
|
21
|
+
local g = tonumber("0x" .. gString)
|
|
22
|
+
if g == nil then
|
|
23
|
+
logError(("Failed to convert `0x" .. gString) .. "` to a number.")
|
|
24
|
+
return {0, 0, 0}
|
|
25
|
+
end
|
|
26
|
+
local bString = __TS__StringSubstring(hexString, 4, 6)
|
|
27
|
+
local b = tonumber("0x" .. bString)
|
|
28
|
+
if b == nil then
|
|
29
|
+
logError(("Failed to convert `0x" .. bString) .. "` to a number.")
|
|
30
|
+
return {0, 0, 0}
|
|
31
|
+
end
|
|
32
|
+
return {r, g, b}
|
|
33
|
+
end
|
|
34
|
+
HEX_STRING_LENGTH = 6
|
|
35
|
+
--- Converts a hex string like "#33aa33" to a KColor object.
|
|
36
|
+
--
|
|
37
|
+
-- @param hexString A hex string like "#ffffff" or "ffffff". (The "#" character is optional.)
|
|
38
|
+
function ____exports.hexToColor(self, hexString, alpha)
|
|
39
|
+
local r, g, b = table.unpack(hexToRGB(nil, hexString))
|
|
40
|
+
local base = 255
|
|
41
|
+
return Color(r / base, g / base, b / base, alpha)
|
|
42
|
+
end
|
|
43
|
+
--- Converts a hex string like "#33aa33" to a Color object.
|
|
44
|
+
--
|
|
45
|
+
-- @param hexString A hex string like "#ffffff" or "ffffff". (The "#" character is optional.)
|
|
46
|
+
function ____exports.hexToKColor(self, hexString, alpha)
|
|
47
|
+
local r, g, b = table.unpack(hexToRGB(nil, hexString))
|
|
48
|
+
local base = 255
|
|
49
|
+
return KColor(r / base, g / base, b / base, alpha)
|
|
50
|
+
end
|
|
51
|
+
return ____exports
|
|
@@ -12,7 +12,7 @@ export declare function addPlayerHealthType(player: EntityPlayer, healthType: He
|
|
|
12
12
|
*/
|
|
13
13
|
export declare function getPlayerHealth(player: EntityPlayer): PlayerHealth;
|
|
14
14
|
export declare function getPlayerHealthType(player: EntityPlayer, healthType: HealthType): int;
|
|
15
|
-
/** Returns a `PlayerHealth` object with all
|
|
15
|
+
/** Returns a `PlayerHealth` object with all zeros. */
|
|
16
16
|
export declare function newPlayerHealth(): PlayerHealth;
|
|
17
17
|
export declare function playerConvertBlackHeartsToSoulHearts(player: EntityPlayer): void;
|
|
18
18
|
export declare function playerConvertSoulHeartsToBlackHearts(player: EntityPlayer): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playerHealth.d.ts","sourceRoot":"","sources":["../../src/functions/playerHealth.ts"],"names":[],"mappings":";;AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAiB,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"playerHealth.d.ts","sourceRoot":"","sources":["../../src/functions/playerHealth.ts"],"names":[],"mappings":";;AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAiB,MAAM,4BAA4B,CAAC;AAYzE,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,YAAY,EACpB,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,GAAG,GACb,IAAI,CA+CN;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY,GAAG,YAAY,CA2ElE;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,YAAY,EACpB,UAAU,EAAE,UAAU,GACrB,GAAG,CAmDL;AAED,sDAAsD;AACtD,wBAAgB,eAAe,IAAI,YAAY,CAc9C;AAED,wBAAgB,oCAAoC,CAClD,MAAM,EAAE,YAAY,GACnB,IAAI,CAQN;AAED,wBAAgB,oCAAoC,CAClD,MAAM,EAAE,YAAY,GACnB,IAAI,CAQN;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAMjE;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAwBhE;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,YAAY,GACzB,IAAI,CAsHN"}
|
|
@@ -21,6 +21,8 @@ local getPlayerHearts = ____players.getPlayerHearts
|
|
|
21
21
|
local getPlayerSoulHearts = ____players.getPlayerSoulHearts
|
|
22
22
|
local isCharacter = ____players.isCharacter
|
|
23
23
|
local setActiveItem = ____players.setActiveItem
|
|
24
|
+
local ____utils = require("functions.utils")
|
|
25
|
+
local ____repeat = ____utils["repeat"]
|
|
24
26
|
function ____exports.removeAllPlayerHealth(self, player)
|
|
25
27
|
local goldenHearts = player:GetGoldenHearts()
|
|
26
28
|
local eternalHearts = player:GetEternalHearts()
|
|
@@ -105,8 +107,23 @@ function ____exports.setPlayerHealth(self, player, playerHealth)
|
|
|
105
107
|
)
|
|
106
108
|
player:AddRottenHearts(playerHealth.rottenHearts)
|
|
107
109
|
if character == PlayerType.MAGDALENE_B then
|
|
108
|
-
|
|
109
|
-
|
|
110
|
+
____repeat(
|
|
111
|
+
nil,
|
|
112
|
+
playerHealth.hearts,
|
|
113
|
+
function()
|
|
114
|
+
if player:HasFullHearts() then
|
|
115
|
+
return
|
|
116
|
+
end
|
|
117
|
+
local hearts = player:GetHearts()
|
|
118
|
+
local maxHearts = player:GetMaxHearts()
|
|
119
|
+
if hearts == maxHearts - 1 then
|
|
120
|
+
player:AddHearts(1)
|
|
121
|
+
return
|
|
122
|
+
end
|
|
123
|
+
player:AddHearts(1)
|
|
124
|
+
player:AddHearts(-1)
|
|
125
|
+
end
|
|
126
|
+
)
|
|
110
127
|
else
|
|
111
128
|
player:AddHearts(playerHealth.hearts)
|
|
112
129
|
end
|
|
@@ -323,7 +340,7 @@ function ____exports.getPlayerHealthType(self, player, healthType)
|
|
|
323
340
|
end
|
|
324
341
|
until true
|
|
325
342
|
end
|
|
326
|
-
--- Returns a `PlayerHealth` object with all
|
|
343
|
+
--- Returns a `PlayerHealth` object with all zeros.
|
|
327
344
|
function ____exports.newPlayerHealth(self)
|
|
328
345
|
return {
|
|
329
346
|
maxHearts = 0,
|
|
@@ -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
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
-
/// <reference types="isaac-typescript-definitions" />
|
|
3
|
-
/// <reference types="isaac-typescript-definitions" />
|
|
4
2
|
/**
|
|
5
3
|
* Helper function to return an array with the elements from start to end. It is inclusive at the
|
|
6
4
|
* start and exclusive at the end. (The "e" stands for exclusive.)
|
|
@@ -16,18 +14,6 @@ export declare function erange(start: int, end?: int): int[];
|
|
|
16
14
|
* structures.
|
|
17
15
|
*/
|
|
18
16
|
export declare function getTraversalDescription(key: unknown, traversalDescription: string): string;
|
|
19
|
-
/**
|
|
20
|
-
* Converts a hex string like "#33aa33" to a KColor object.
|
|
21
|
-
*
|
|
22
|
-
* @param hexString A hex string like "#ffffff" or "ffffff". (The "#" character is optional.)
|
|
23
|
-
*/
|
|
24
|
-
export declare function hexToColor(hexString: string, alpha: float): Color;
|
|
25
|
-
/**
|
|
26
|
-
* Converts a hex string like "#33aa33" to a Color object.
|
|
27
|
-
*
|
|
28
|
-
* @param hexString A hex string like "#ffffff" or "ffffff". (The "#" character is optional.)
|
|
29
|
-
*/
|
|
30
|
-
export declare function hexToKColor(hexString: string, alpha: float): KColor;
|
|
31
17
|
/**
|
|
32
18
|
* Helper function to return an array with the elements from start to end, inclusive. (The "i"
|
|
33
19
|
* stands for inclusive.)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/functions/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/functions/utils.ts"],"names":[],"mappings":";AAIA;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,GAAG,GAAG,EAAE,CAYnD;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,OAAO,EACZ,oBAAoB,EAAE,MAAM,GAC3B,MAAM,CAQR;AAED;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,GAAG,GAAG,EAAE,CAYnD;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,OAAO,CAI5C;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAEpE;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAE9C;AAED,iGAAiG;AACjG,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAGxE;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,IAAI,GAAG,IAAI,CAI3D;AAED;;;;;;;;;;;;GAYG;AAEH,wBAAgB,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAG;AAEjD;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAYhE"}
|
package/dist/functions/utils.lua
CHANGED
|
@@ -1,37 +1,10 @@
|
|
|
1
|
-
local ____lualib = require("lualib_bundle")
|
|
2
|
-
local __TS__StringReplace = ____lualib.__TS__StringReplace
|
|
3
|
-
local __TS__StringSubstring = ____lualib.__TS__StringSubstring
|
|
4
1
|
local ____exports = {}
|
|
5
|
-
local hexToRGB, HEX_STRING_LENGTH
|
|
6
2
|
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
|
|
7
3
|
local RenderMode = ____isaac_2Dtypescript_2Ddefinitions.RenderMode
|
|
8
4
|
local ____cachedClasses = require("core.cachedClasses")
|
|
9
5
|
local game = ____cachedClasses.game
|
|
10
6
|
local ____consoleCommandsSet = require("sets.consoleCommandsSet")
|
|
11
7
|
local CONSOLE_COMMANDS_SET = ____consoleCommandsSet.CONSOLE_COMMANDS_SET
|
|
12
|
-
function hexToRGB(self, hexString)
|
|
13
|
-
hexString = __TS__StringReplace(hexString, "#", "")
|
|
14
|
-
if #hexString ~= HEX_STRING_LENGTH then
|
|
15
|
-
error("Hex strings must be of length: " .. tostring(HEX_STRING_LENGTH))
|
|
16
|
-
end
|
|
17
|
-
local rString = __TS__StringSubstring(hexString, 0, 2)
|
|
18
|
-
local r = tonumber("0x" .. rString)
|
|
19
|
-
if r == nil then
|
|
20
|
-
error(("Failed to convert `0x" .. rString) .. "` to a number.")
|
|
21
|
-
end
|
|
22
|
-
local gString = __TS__StringSubstring(hexString, 2, 4)
|
|
23
|
-
local g = tonumber("0x" .. gString)
|
|
24
|
-
if g == nil then
|
|
25
|
-
error(("Failed to convert `0x" .. gString) .. "` to a number.")
|
|
26
|
-
end
|
|
27
|
-
local bString = __TS__StringSubstring(hexString, 4, 6)
|
|
28
|
-
local b = tonumber("0x" .. bString)
|
|
29
|
-
if b == nil then
|
|
30
|
-
error(("Failed to convert `0x" .. bString) .. "` to a number.")
|
|
31
|
-
end
|
|
32
|
-
return {r, g, b}
|
|
33
|
-
end
|
|
34
|
-
HEX_STRING_LENGTH = 6
|
|
35
8
|
--- Helper function to return an array with the elements from start to end. It is inclusive at the
|
|
36
9
|
-- start and exclusive at the end. (The "e" stands for exclusive.)
|
|
37
10
|
--
|
|
@@ -63,22 +36,6 @@ function ____exports.getTraversalDescription(self, key, traversalDescription)
|
|
|
63
36
|
traversalDescription = traversalDescription .. tostring(key)
|
|
64
37
|
return traversalDescription
|
|
65
38
|
end
|
|
66
|
-
--- Converts a hex string like "#33aa33" to a KColor object.
|
|
67
|
-
--
|
|
68
|
-
-- @param hexString A hex string like "#ffffff" or "ffffff". (The "#" character is optional.)
|
|
69
|
-
function ____exports.hexToColor(self, hexString, alpha)
|
|
70
|
-
local r, g, b = table.unpack(hexToRGB(nil, hexString))
|
|
71
|
-
local base = 255
|
|
72
|
-
return Color(r / base, g / base, b / base, alpha)
|
|
73
|
-
end
|
|
74
|
-
--- Converts a hex string like "#33aa33" to a Color object.
|
|
75
|
-
--
|
|
76
|
-
-- @param hexString A hex string like "#ffffff" or "ffffff". (The "#" character is optional.)
|
|
77
|
-
function ____exports.hexToKColor(self, hexString, alpha)
|
|
78
|
-
local r, g, b = table.unpack(hexToRGB(nil, hexString))
|
|
79
|
-
local base = 255
|
|
80
|
-
return KColor(r / base, g / base, b / base, alpha)
|
|
81
|
-
end
|
|
82
39
|
--- Helper function to return an array with the elements from start to end, inclusive. (The "i"
|
|
83
40
|
-- stands for inclusive.)
|
|
84
41
|
--
|
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
|
|
|
@@ -8143,7 +8132,7 @@ export declare function newChargeBarSprites(maxCharges: int): ChargeBarSprites;
|
|
|
8143
8132
|
|
|
8144
8133
|
export declare function newPickingUpItem(): PickingUpItem;
|
|
8145
8134
|
|
|
8146
|
-
/** Returns a `PlayerHealth` object with all
|
|
8135
|
+
/** Returns a `PlayerHealth` object with all zeros. */
|
|
8147
8136
|
export declare function newPlayerHealth(): PlayerHealth;
|
|
8148
8137
|
|
|
8149
8138
|
/**
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kBAAkB,CAAC;AACjC,cAAc,sCAAsC,CAAC;AACrD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oCAAoC,CAAC;AACnD,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,gCAAgC,CAAC;AAC/C,cA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AAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iCAAiC,CAAC;AAChD,cAAc,mBAAmB,CAAC"}
|
package/dist/index.lua
CHANGED
|
@@ -687,6 +687,14 @@ do
|
|
|
687
687
|
end
|
|
688
688
|
end
|
|
689
689
|
end
|
|
690
|
+
do
|
|
691
|
+
local ____export = require("functions.hex")
|
|
692
|
+
for ____exportKey, ____exportValue in pairs(____export) do
|
|
693
|
+
if ____exportKey ~= "default" then
|
|
694
|
+
____exports[____exportKey] = ____exportValue
|
|
695
|
+
end
|
|
696
|
+
end
|
|
697
|
+
end
|
|
690
698
|
do
|
|
691
699
|
local ____export = require("functions.input")
|
|
692
700
|
for ____exportKey, ____exportValue in pairs(____export) do
|
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);
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { logError } from "./log";
|
|
2
|
+
|
|
3
|
+
const HEX_STRING_LENGTH = 6;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Converts a hex string like "#33aa33" to a KColor object.
|
|
7
|
+
*
|
|
8
|
+
* @param hexString A hex string like "#ffffff" or "ffffff". (The "#" character is optional.)
|
|
9
|
+
*/
|
|
10
|
+
export function hexToColor(hexString: string, alpha: float): Color {
|
|
11
|
+
const [r, g, b] = hexToRGB(hexString);
|
|
12
|
+
|
|
13
|
+
// Color values should be between 0 and 1.
|
|
14
|
+
const base = 255;
|
|
15
|
+
return Color(r / base, g / base, b / base, alpha);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Converts a hex string like "#33aa33" to a Color object.
|
|
20
|
+
*
|
|
21
|
+
* @param hexString A hex string like "#ffffff" or "ffffff". (The "#" character is optional.)
|
|
22
|
+
*/
|
|
23
|
+
export function hexToKColor(hexString: string, alpha: float): KColor {
|
|
24
|
+
const [r, g, b] = hexToRGB(hexString);
|
|
25
|
+
|
|
26
|
+
// KColor values should be between 0 and 1.
|
|
27
|
+
const base = 255;
|
|
28
|
+
return KColor(r / base, g / base, b / base, alpha);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function hexToRGB(hexString: string): [r: float, g: float, b: float] {
|
|
32
|
+
hexString = hexString.replace("#", "");
|
|
33
|
+
if (hexString.length !== HEX_STRING_LENGTH) {
|
|
34
|
+
logError(`Hex strings must be of length: ${HEX_STRING_LENGTH}`);
|
|
35
|
+
return [0, 0, 0];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const rString = hexString.substring(0, 2);
|
|
39
|
+
const r = tonumber(`0x${rString}`);
|
|
40
|
+
if (r === undefined) {
|
|
41
|
+
logError(`Failed to convert \`0x${rString}\` to a number.`);
|
|
42
|
+
return [0, 0, 0];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const gString = hexString.substring(2, 4);
|
|
46
|
+
const g = tonumber(`0x${gString}`);
|
|
47
|
+
if (g === undefined) {
|
|
48
|
+
logError(`Failed to convert \`0x${gString}\` to a number.`);
|
|
49
|
+
return [0, 0, 0];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const bString = hexString.substring(4, 6);
|
|
53
|
+
const b = tonumber(`0x${bString}`);
|
|
54
|
+
if (b === undefined) {
|
|
55
|
+
logError(`Failed to convert \`0x${bString}\` to a number.`);
|
|
56
|
+
return [0, 0, 0];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return [r, g, b];
|
|
60
|
+
}
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
isCharacter,
|
|
17
17
|
setActiveItem,
|
|
18
18
|
} from "./players";
|
|
19
|
+
import { repeat } from "./utils";
|
|
19
20
|
|
|
20
21
|
export function addPlayerHealthType(
|
|
21
22
|
player: EntityPlayer,
|
|
@@ -210,7 +211,7 @@ export function getPlayerHealthType(
|
|
|
210
211
|
}
|
|
211
212
|
}
|
|
212
213
|
|
|
213
|
-
/** Returns a `PlayerHealth` object with all
|
|
214
|
+
/** Returns a `PlayerHealth` object with all zeros. */
|
|
214
215
|
export function newPlayerHealth(): PlayerHealth {
|
|
215
216
|
return {
|
|
216
217
|
maxHearts: 0,
|
|
@@ -381,8 +382,21 @@ export function setPlayerHealth(
|
|
|
381
382
|
|
|
382
383
|
if (character === PlayerType.MAGDALENE_B) {
|
|
383
384
|
// Adding 1 heart to Tainted Magdalene will actually add two hearts.
|
|
384
|
-
|
|
385
|
-
|
|
385
|
+
repeat(playerHealth.hearts, () => {
|
|
386
|
+
if (player.HasFullHearts()) {
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
const hearts = player.GetHearts();
|
|
391
|
+
const maxHearts = player.GetMaxHearts();
|
|
392
|
+
if (hearts === maxHearts - 1) {
|
|
393
|
+
player.AddHearts(1);
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
player.AddHearts(1);
|
|
398
|
+
player.AddHearts(-1);
|
|
399
|
+
});
|
|
386
400
|
} else {
|
|
387
401
|
player.AddHearts(playerHealth.hearts);
|
|
388
402
|
}
|
|
@@ -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
|
}
|
package/src/functions/utils.ts
CHANGED
|
@@ -2,8 +2,6 @@ import { RenderMode } from "isaac-typescript-definitions";
|
|
|
2
2
|
import { game } from "../core/cachedClasses";
|
|
3
3
|
import { CONSOLE_COMMANDS_SET } from "../sets/consoleCommandsSet";
|
|
4
4
|
|
|
5
|
-
const HEX_STRING_LENGTH = 6;
|
|
6
|
-
|
|
7
5
|
/**
|
|
8
6
|
* Helper function to return an array with the elements from start to end. It is inclusive at the
|
|
9
7
|
* start and exclusive at the end. (The "e" stands for exclusive.)
|
|
@@ -44,59 +42,6 @@ export function getTraversalDescription(
|
|
|
44
42
|
return traversalDescription;
|
|
45
43
|
}
|
|
46
44
|
|
|
47
|
-
/**
|
|
48
|
-
* Converts a hex string like "#33aa33" to a KColor object.
|
|
49
|
-
*
|
|
50
|
-
* @param hexString A hex string like "#ffffff" or "ffffff". (The "#" character is optional.)
|
|
51
|
-
*/
|
|
52
|
-
export function hexToColor(hexString: string, alpha: float): Color {
|
|
53
|
-
const [r, g, b] = hexToRGB(hexString);
|
|
54
|
-
|
|
55
|
-
// Color values should be between 0 and 1.
|
|
56
|
-
const base = 255;
|
|
57
|
-
return Color(r / base, g / base, b / base, alpha);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Converts a hex string like "#33aa33" to a Color object.
|
|
62
|
-
*
|
|
63
|
-
* @param hexString A hex string like "#ffffff" or "ffffff". (The "#" character is optional.)
|
|
64
|
-
*/
|
|
65
|
-
export function hexToKColor(hexString: string, alpha: float): KColor {
|
|
66
|
-
const [r, g, b] = hexToRGB(hexString);
|
|
67
|
-
|
|
68
|
-
// KColor values should be between 0 and 1.
|
|
69
|
-
const base = 255;
|
|
70
|
-
return KColor(r / base, g / base, b / base, alpha);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function hexToRGB(hexString: string): [r: float, g: float, b: float] {
|
|
74
|
-
hexString = hexString.replace("#", "");
|
|
75
|
-
if (hexString.length !== HEX_STRING_LENGTH) {
|
|
76
|
-
error(`Hex strings must be of length: ${HEX_STRING_LENGTH}`);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const rString = hexString.substring(0, 2);
|
|
80
|
-
const r = tonumber(`0x${rString}`);
|
|
81
|
-
if (r === undefined) {
|
|
82
|
-
error(`Failed to convert \`0x${rString}\` to a number.`);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const gString = hexString.substring(2, 4);
|
|
86
|
-
const g = tonumber(`0x${gString}`);
|
|
87
|
-
if (g === undefined) {
|
|
88
|
-
error(`Failed to convert \`0x${gString}\` to a number.`);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const bString = hexString.substring(4, 6);
|
|
92
|
-
const b = tonumber(`0x${bString}`);
|
|
93
|
-
if (b === undefined) {
|
|
94
|
-
error(`Failed to convert \`0x${bString}\` to a number.`);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return [r, g, b];
|
|
98
|
-
}
|
|
99
|
-
|
|
100
45
|
/**
|
|
101
46
|
* Helper function to return an array with the elements from start to end, inclusive. (The "i"
|
|
102
47
|
* stands for inclusive.)
|
package/src/index.ts
CHANGED
|
@@ -84,6 +84,7 @@ export * from "./functions/flying";
|
|
|
84
84
|
export * from "./functions/globals";
|
|
85
85
|
export * from "./functions/gridEntities";
|
|
86
86
|
export * from "./functions/gridEntitiesSpecific";
|
|
87
|
+
export * from "./functions/hex";
|
|
87
88
|
export * from "./functions/input";
|
|
88
89
|
export * from "./functions/isaacAPIClass";
|
|
89
90
|
export * from "./functions/itemPool";
|