isaacscript-common 7.18.0 → 8.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/constantsFirstLast.d.ts +10 -85
- package/dist/core/constantsFirstLast.d.ts.map +1 -1
- package/dist/core/constantsFirstLast.lua +10 -90
- package/dist/enums/ModCallbackCustom.d.ts +21 -0
- package/dist/enums/ModCallbackCustom.d.ts.map +1 -1
- package/dist/features/characterStats.lua +2 -2
- package/dist/features/extraConsoleCommands/listCommands.d.ts.map +1 -1
- package/dist/features/extraConsoleCommands/listCommands.lua +9 -5
- package/dist/features/firstLast.d.ts +190 -0
- package/dist/features/firstLast.d.ts.map +1 -0
- package/dist/features/firstLast.lua +341 -0
- package/dist/functions/array.d.ts +1 -9
- package/dist/functions/array.d.ts.map +1 -1
- package/dist/functions/array.lua +0 -6
- package/dist/functions/cards.d.ts +0 -8
- package/dist/functions/cards.d.ts.map +1 -1
- package/dist/functions/cards.lua +9 -24
- package/dist/functions/{cacheFlag.d.ts → collectibleCacheFlag.d.ts} +8 -8
- package/dist/functions/collectibleCacheFlag.d.ts.map +1 -0
- package/dist/functions/{cacheFlag.lua → collectibleCacheFlag.lua} +12 -13
- package/dist/functions/collectibleSet.d.ts +18 -0
- package/dist/functions/collectibleSet.d.ts.map +1 -1
- package/dist/functions/collectibleSet.lua +29 -9
- package/dist/functions/collectibles.d.ts +0 -13
- package/dist/functions/collectibles.d.ts.map +1 -1
- package/dist/functions/collectibles.lua +0 -18
- package/dist/functions/flying.lua +2 -2
- package/dist/functions/pills.d.ts +0 -10
- package/dist/functions/pills.d.ts.map +1 -1
- package/dist/functions/pills.lua +0 -15
- package/dist/functions/players.d.ts +12 -0
- package/dist/functions/players.d.ts.map +1 -1
- package/dist/functions/players.lua +52 -9
- package/dist/functions/random.d.ts.map +1 -1
- package/dist/functions/random.lua +2 -0
- package/dist/functions/stats.d.ts +9 -0
- package/dist/functions/stats.d.ts.map +1 -0
- package/dist/functions/stats.lua +11 -0
- package/dist/functions/trinketCacheFlag.d.ts +9 -1
- package/dist/functions/trinketCacheFlag.d.ts.map +1 -1
- package/dist/functions/trinketCacheFlag.lua +28 -10
- package/dist/functions/trinketSet.d.ts +18 -0
- package/dist/functions/trinketSet.d.ts.map +1 -1
- package/dist/functions/trinketSet.lua +29 -9
- package/dist/functions/trinkets.d.ts +1 -10
- package/dist/functions/trinkets.d.ts.map +1 -1
- package/dist/functions/trinkets.lua +0 -24
- package/dist/index.d.ts +259 -117
- package/dist/index.d.ts.map +1 -1
- package/dist/index.lua +14 -6
- package/dist/initFeatures.d.ts.map +1 -1
- package/dist/initFeatures.lua +3 -0
- package/package.json +1 -1
- package/src/core/constantsFirstLast.ts +12 -125
- package/src/enums/ModCallbackCustom.ts +21 -0
- package/src/features/characterStats.ts +1 -1
- package/src/features/extraConsoleCommands/listCommands.ts +8 -5
- package/src/features/firstLast.ts +429 -0
- package/src/functions/array.ts +1 -9
- package/src/functions/cards.ts +5 -28
- package/src/functions/{cacheFlag.ts → collectibleCacheFlag.ts} +13 -16
- package/src/functions/collectibleSet.ts +28 -21
- package/src/functions/collectibles.ts +0 -22
- package/src/functions/flying.ts +1 -1
- package/src/functions/pills.ts +0 -22
- package/src/functions/players.ts +41 -0
- package/src/functions/random.ts +3 -0
- package/src/functions/stats.ts +12 -0
- package/src/functions/trinketCacheFlag.ts +29 -7
- package/src/functions/trinketSet.ts +28 -21
- package/src/functions/trinkets.ts +0 -34
- package/src/index.ts +2 -1
- package/src/initFeatures.ts +2 -0
- package/dist/functions/cacheFlag.d.ts.map +0 -1
|
@@ -2,9 +2,9 @@ import { CollectibleType } from "isaac-typescript-definitions";
|
|
|
2
2
|
import { itemConfig } from "../core/cachedClasses";
|
|
3
3
|
import {
|
|
4
4
|
FIRST_COLLECTIBLE_TYPE,
|
|
5
|
-
LAST_COLLECTIBLE_TYPE,
|
|
6
5
|
LAST_VANILLA_COLLECTIBLE_TYPE,
|
|
7
6
|
} from "../core/constantsFirstLast";
|
|
7
|
+
import { getLastCollectibleType } from "../features/firstLast";
|
|
8
8
|
import { irange } from "./utils";
|
|
9
9
|
|
|
10
10
|
const ALL_COLLECTIBLES_ARRAY: CollectibleType[] = [];
|
|
@@ -15,14 +15,15 @@ const ALL_COLLECTIBLES_SET = new Set<CollectibleType>();
|
|
|
15
15
|
const VANILLA_COLLECTIBLES_SET = new Set<CollectibleType>();
|
|
16
16
|
const MODDED_COLLECTIBLES_SET = new Set<CollectibleType>();
|
|
17
17
|
|
|
18
|
-
function
|
|
18
|
+
function lazyInitCollectibleArraysAndSets() {
|
|
19
19
|
if (ALL_COLLECTIBLES_ARRAY.length !== 0) {
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
const lastCollectibleType = getLastCollectibleType();
|
|
23
24
|
const collectibleTypeRange = irange(
|
|
24
25
|
FIRST_COLLECTIBLE_TYPE,
|
|
25
|
-
|
|
26
|
+
lastCollectibleType,
|
|
26
27
|
) as CollectibleType[];
|
|
27
28
|
for (const collectibleType of collectibleTypeRange) {
|
|
28
29
|
const itemConfigItem = itemConfig.GetCollectible(collectibleType);
|
|
@@ -60,11 +61,12 @@ function initCollectibleArraysAndSets() {
|
|
|
60
61
|
*
|
|
61
62
|
* Use this if you need to iterate over the collectibles in order. If you need to do O(1) lookups,
|
|
62
63
|
* then use the `getCollectibleSet` helper function instead.
|
|
64
|
+
*
|
|
65
|
+
* This function can only be called if at least one callback has been executed. This is because not
|
|
66
|
+
* all collectibles will necessarily be present when a mod first loads (due to mod load order).
|
|
63
67
|
*/
|
|
64
68
|
export function getCollectibleArray(): readonly CollectibleType[] {
|
|
65
|
-
|
|
66
|
-
initCollectibleArraysAndSets();
|
|
67
|
-
|
|
69
|
+
lazyInitCollectibleArraysAndSets();
|
|
68
70
|
return ALL_COLLECTIBLES_ARRAY;
|
|
69
71
|
}
|
|
70
72
|
|
|
@@ -73,11 +75,12 @@ export function getCollectibleArray(): readonly CollectibleType[] {
|
|
|
73
75
|
*
|
|
74
76
|
* Use this if you need to do O(1) lookups. If you need to iterate over the collectibles in order,
|
|
75
77
|
* then use the `getCollectibleArray` helper function instead.
|
|
78
|
+
*
|
|
79
|
+
* This function can only be called if at least one callback has been executed. This is because not
|
|
80
|
+
* all collectibles will necessarily be present when a mod first loads (due to mod load order).
|
|
76
81
|
*/
|
|
77
82
|
export function getCollectibleSet(): ReadonlySet<CollectibleType> {
|
|
78
|
-
|
|
79
|
-
initCollectibleArraysAndSets();
|
|
80
|
-
|
|
83
|
+
lazyInitCollectibleArraysAndSets();
|
|
81
84
|
return ALL_COLLECTIBLES_SET;
|
|
82
85
|
}
|
|
83
86
|
|
|
@@ -86,11 +89,12 @@ export function getCollectibleSet(): ReadonlySet<CollectibleType> {
|
|
|
86
89
|
*
|
|
87
90
|
* Use this if you need to iterate over the collectibles in order. If you need to do O(1) lookups,
|
|
88
91
|
* then use the `getModdedCollectibleSet` helper function instead.
|
|
92
|
+
*
|
|
93
|
+
* This function can only be called if at least one callback has been executed. This is because not
|
|
94
|
+
* all collectibles will necessarily be present when a mod first loads (due to mod load order).
|
|
89
95
|
*/
|
|
90
96
|
export function getModdedCollectibleArray(): readonly CollectibleType[] {
|
|
91
|
-
|
|
92
|
-
initCollectibleArraysAndSets();
|
|
93
|
-
|
|
97
|
+
lazyInitCollectibleArraysAndSets();
|
|
94
98
|
return MODDED_COLLECTIBLES_ARRAY;
|
|
95
99
|
}
|
|
96
100
|
|
|
@@ -99,11 +103,12 @@ export function getModdedCollectibleArray(): readonly CollectibleType[] {
|
|
|
99
103
|
*
|
|
100
104
|
* Use this if you need to do O(1) lookups. If you need to iterate over the collectibles in order,
|
|
101
105
|
* then use the `getModdedCollectibleArray` helper function instead.
|
|
106
|
+
*
|
|
107
|
+
* This function can only be called if at least one callback has been executed. This is because not
|
|
108
|
+
* all collectibles will necessarily be present when a mod first loads (due to mod load order).
|
|
102
109
|
*/
|
|
103
110
|
export function getModdedCollectibleSet(): ReadonlySet<CollectibleType> {
|
|
104
|
-
|
|
105
|
-
initCollectibleArraysAndSets();
|
|
106
|
-
|
|
111
|
+
lazyInitCollectibleArraysAndSets();
|
|
107
112
|
return MODDED_COLLECTIBLES_SET;
|
|
108
113
|
}
|
|
109
114
|
|
|
@@ -112,11 +117,12 @@ export function getModdedCollectibleSet(): ReadonlySet<CollectibleType> {
|
|
|
112
117
|
*
|
|
113
118
|
* Use this if you need to iterate over the collectibles in order. If you need to do O(1) lookups,
|
|
114
119
|
* 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).
|
|
115
123
|
*/
|
|
116
124
|
export function getVanillaCollectibleArray(): readonly CollectibleType[] {
|
|
117
|
-
|
|
118
|
-
initCollectibleArraysAndSets();
|
|
119
|
-
|
|
125
|
+
lazyInitCollectibleArraysAndSets();
|
|
120
126
|
return VANILLA_COLLECTIBLES_ARRAY;
|
|
121
127
|
}
|
|
122
128
|
|
|
@@ -125,10 +131,11 @@ export function getVanillaCollectibleArray(): readonly CollectibleType[] {
|
|
|
125
131
|
*
|
|
126
132
|
* Use this if you need to do O(1) lookups. If you need to iterate over the collectibles in order,
|
|
127
133
|
* 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).
|
|
128
137
|
*/
|
|
129
138
|
export function getVanillaCollectibleSet(): ReadonlySet<CollectibleType> {
|
|
130
|
-
|
|
131
|
-
initCollectibleArraysAndSets();
|
|
132
|
-
|
|
139
|
+
lazyInitCollectibleArraysAndSets();
|
|
133
140
|
return VANILLA_COLLECTIBLES_SET;
|
|
134
141
|
}
|
|
@@ -13,8 +13,6 @@ import { game, itemConfig } from "../core/cachedClasses";
|
|
|
13
13
|
import { BLIND_ITEM_PNG_PATH, DEFAULT_ITEM_POOL_TYPE } from "../core/constants";
|
|
14
14
|
import {
|
|
15
15
|
FIRST_COLLECTIBLE_TYPE,
|
|
16
|
-
FIRST_MODDED_COLLECTIBLE_TYPE,
|
|
17
|
-
LAST_COLLECTIBLE_TYPE,
|
|
18
16
|
LAST_VANILLA_COLLECTIBLE_TYPE,
|
|
19
17
|
} from "../core/constantsFirstLast";
|
|
20
18
|
import {
|
|
@@ -372,26 +370,6 @@ export function getCollectibleTags(
|
|
|
372
370
|
return itemConfigItem === undefined ? ItemConfigTagZero : itemConfigItem.Tags;
|
|
373
371
|
}
|
|
374
372
|
|
|
375
|
-
/**
|
|
376
|
-
* Helper function to get an array that represents the all modded collectible types.
|
|
377
|
-
*
|
|
378
|
-
* This function is only useful when building collectible type objects. For most purposes, you
|
|
379
|
-
* should use the `getModdedCollectibleSet` helper function instead.
|
|
380
|
-
*
|
|
381
|
-
* Returns an empty array if there are no modded collectible types.
|
|
382
|
-
*
|
|
383
|
-
* (This function is named differently from the `getVanillaCollectibleTypeRange` function because
|
|
384
|
-
* all modded collectible types are contiguous. Thus, each value represents a real
|
|
385
|
-
* `CollectibleType`.)
|
|
386
|
-
*/
|
|
387
|
-
export function getModdedCollectibleTypes(): CollectibleType[] {
|
|
388
|
-
if (LAST_VANILLA_COLLECTIBLE_TYPE === LAST_COLLECTIBLE_TYPE) {
|
|
389
|
-
return [];
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
return irange(FIRST_MODDED_COLLECTIBLE_TYPE, LAST_COLLECTIBLE_TYPE);
|
|
393
|
-
}
|
|
394
|
-
|
|
395
373
|
/**
|
|
396
374
|
* Helper function to get an array that represents the range from the first collectible type to the
|
|
397
375
|
* last vanilla collectible type. This will include integers that do not represent any valid
|
package/src/functions/flying.ts
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
PlayerType,
|
|
6
6
|
TrinketType,
|
|
7
7
|
} from "isaac-typescript-definitions";
|
|
8
|
-
import { getCollectiblesForCacheFlag } from "./
|
|
8
|
+
import { getCollectiblesForCacheFlag } from "./collectibleCacheFlag";
|
|
9
9
|
import { copySet, deleteSetsFromSet } from "./set";
|
|
10
10
|
|
|
11
11
|
const FLYING_CHARACTERS: ReadonlySet<PlayerType> = new Set([
|
package/src/functions/pills.ts
CHANGED
|
@@ -7,12 +7,10 @@ import {
|
|
|
7
7
|
import { itemConfig } from "../core/cachedClasses";
|
|
8
8
|
import {
|
|
9
9
|
FIRST_HORSE_PILL_COLOR,
|
|
10
|
-
FIRST_MODDED_PILL_EFFECT,
|
|
11
10
|
FIRST_PILL_COLOR,
|
|
12
11
|
FIRST_PILL_EFFECT,
|
|
13
12
|
LAST_HORSE_PILL_COLOR,
|
|
14
13
|
LAST_NORMAL_PILL_COLOR,
|
|
15
|
-
LAST_PILL_EFFECT,
|
|
16
14
|
LAST_VANILLA_PILL_EFFECT,
|
|
17
15
|
} from "../core/constantsFirstLast";
|
|
18
16
|
import { FALSE_PHD_PILL_CONVERSIONS } from "../maps/falsePHDPillConversions";
|
|
@@ -52,13 +50,6 @@ export function getAllPillColors(): PillColor[] {
|
|
|
52
50
|
return pillColors;
|
|
53
51
|
}
|
|
54
52
|
|
|
55
|
-
/**
|
|
56
|
-
* Helper function to get an array with every valid pill effect. This includes modded pill effects.
|
|
57
|
-
*/
|
|
58
|
-
export function getAllPillEffects(): PillEffect[] {
|
|
59
|
-
return irange(FIRST_PILL_EFFECT, LAST_PILL_EFFECT);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
53
|
/**
|
|
63
54
|
* Helper function to get the associated pill effect after False PHD is acquired. If a pill effect
|
|
64
55
|
* is not altered by False PHD, then the same pill effect will be returned.
|
|
@@ -83,19 +74,6 @@ export function getHorsePillColors(): PillColor[] {
|
|
|
83
74
|
return irange(FIRST_HORSE_PILL_COLOR, LAST_HORSE_PILL_COLOR);
|
|
84
75
|
}
|
|
85
76
|
|
|
86
|
-
/**
|
|
87
|
-
* Helper function to get an array with every modded pill effect.
|
|
88
|
-
*
|
|
89
|
-
* Returns an empty array if there are no modded pill effects.
|
|
90
|
-
*/
|
|
91
|
-
export function getModdedPillEffects(): PillEffect[] {
|
|
92
|
-
if (LAST_VANILLA_PILL_EFFECT === LAST_PILL_EFFECT) {
|
|
93
|
-
return [];
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return irange(FIRST_MODDED_PILL_EFFECT, LAST_PILL_EFFECT);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
77
|
/**
|
|
100
78
|
* Helper function to get the corresponding normal pill color from a horse pill color.
|
|
101
79
|
*
|
package/src/functions/players.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
NullItemID,
|
|
8
8
|
PlayerForm,
|
|
9
9
|
PlayerType,
|
|
10
|
+
TrinketSlot,
|
|
10
11
|
TrinketType,
|
|
11
12
|
} from "isaac-typescript-definitions";
|
|
12
13
|
import { game, itemConfig } from "../core/cachedClasses";
|
|
@@ -882,6 +883,46 @@ export function playerHasCollectible(
|
|
|
882
883
|
);
|
|
883
884
|
}
|
|
884
885
|
|
|
886
|
+
/**
|
|
887
|
+
* Helper function to remove all of the active items from a player. This includes the Schoolbag item
|
|
888
|
+
* and any pocket actives.
|
|
889
|
+
*/
|
|
890
|
+
export function removeAllActiveItems(player: EntityPlayer): void {
|
|
891
|
+
for (const activeSlot of getEnumValues(ActiveSlot)) {
|
|
892
|
+
const collectibleType = player.GetActiveItem(activeSlot);
|
|
893
|
+
if (collectibleType === CollectibleType.NULL) {
|
|
894
|
+
continue;
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
let hasCollectible: boolean;
|
|
898
|
+
do {
|
|
899
|
+
player.RemoveCollectible(collectibleType);
|
|
900
|
+
hasCollectible = player.HasCollectible(collectibleType);
|
|
901
|
+
} while (hasCollectible);
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
/**
|
|
906
|
+
* Helper function to remove all of the held trinkets from a player.
|
|
907
|
+
*
|
|
908
|
+
* This will not remove any smelted trinkets, unless the player happens to be holding a trinket that
|
|
909
|
+
* they also have smelted. (In that case, both the held and the smelted trinket will be removed.)
|
|
910
|
+
*/
|
|
911
|
+
export function removeAllPlayerTrinkets(player: EntityPlayer): void {
|
|
912
|
+
for (const trinketSlot of getEnumValues(TrinketSlot)) {
|
|
913
|
+
const trinketType = player.GetTrinket(trinketSlot);
|
|
914
|
+
if (trinketType === TrinketType.NULL) {
|
|
915
|
+
continue;
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
let hasTrinket: boolean;
|
|
919
|
+
do {
|
|
920
|
+
player.TryRemoveTrinket(trinketType);
|
|
921
|
+
hasTrinket = player.HasTrinket(trinketType);
|
|
922
|
+
} while (hasTrinket);
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
|
|
885
926
|
/**
|
|
886
927
|
* Helper function to remove a collectible costume from a player. Use this helper function to avoid
|
|
887
928
|
* having to request the collectible from the item config.
|
package/src/functions/random.ts
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CacheFlag } from "isaac-typescript-definitions";
|
|
2
|
+
import { DEFAULT_PLAYER_STAT_MAP } from "../maps/defaultPlayerStatMap";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Returns the starting stat that Isaac (the default character) starts with. For example, if you
|
|
6
|
+
* pass this function `CacheFlag.DAMAGE`, it will return 3.5.
|
|
7
|
+
*
|
|
8
|
+
* Note that the default fire delay is represented in the tear stat, not the `MaxFireDelay` value.
|
|
9
|
+
*/
|
|
10
|
+
export function getDefaultPlayerStat(cacheFlag: CacheFlag): number | undefined {
|
|
11
|
+
return DEFAULT_PLAYER_STAT_MAP.get(cacheFlag);
|
|
12
|
+
}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { CacheFlag, TrinketType } from "isaac-typescript-definitions";
|
|
2
|
+
import { itemConfig } from "../core/cachedClasses";
|
|
3
|
+
import { getTrinketTypes } from "../features/firstLast";
|
|
2
4
|
import { getEnumValues } from "./enums";
|
|
5
|
+
import { hasFlag } from "./flag";
|
|
3
6
|
import { copySet } from "./set";
|
|
4
|
-
import { getTrinketTypes, trinketHasCacheFlag } from "./trinkets";
|
|
5
7
|
|
|
6
8
|
const CACHE_FLAG_TO_TRINKETS_MAP = new Map<CacheFlag, Set<TrinketType>>();
|
|
7
9
|
|
|
8
|
-
function
|
|
10
|
+
function lazyInitCacheFlagMap() {
|
|
11
|
+
if (CACHE_FLAG_TO_TRINKETS_MAP.size > 0) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
9
15
|
for (const cacheFlag of getEnumValues(CacheFlag)) {
|
|
10
16
|
const trinketsSet = new Set<TrinketType>();
|
|
11
17
|
|
|
@@ -21,7 +27,10 @@ function initCacheFlagMap() {
|
|
|
21
27
|
|
|
22
28
|
/**
|
|
23
29
|
* Returns a map containing every trinket type that the player has that matches the provided
|
|
24
|
-
* CacheFlag
|
|
30
|
+
* `CacheFlag`. The values of the map correspond to the multiplier for that trinket.
|
|
31
|
+
*
|
|
32
|
+
* This function can only be called if at least one callback has been executed. This is because not
|
|
33
|
+
* all trinkets will necessarily be present when a mod first loads (due to mod load order).
|
|
25
34
|
*/
|
|
26
35
|
export function getPlayerTrinketsForCacheFlag(
|
|
27
36
|
player: EntityPlayer,
|
|
@@ -42,14 +51,14 @@ export function getPlayerTrinketsForCacheFlag(
|
|
|
42
51
|
|
|
43
52
|
/**
|
|
44
53
|
* Returns a set containing every trinket type with the given cache flag, including modded trinkets.
|
|
54
|
+
*
|
|
55
|
+
* This function can only be called if at least one callback has been executed. This is because not
|
|
56
|
+
* all trinkets will necessarily be present when a mod first loads (due to mod load order).
|
|
45
57
|
*/
|
|
46
58
|
export function getTrinketsForCacheFlag(
|
|
47
59
|
cacheFlag: CacheFlag,
|
|
48
60
|
): Set<TrinketType> {
|
|
49
|
-
|
|
50
|
-
if (CACHE_FLAG_TO_TRINKETS_MAP.size === 0) {
|
|
51
|
-
initCacheFlagMap();
|
|
52
|
-
}
|
|
61
|
+
lazyInitCacheFlagMap();
|
|
53
62
|
|
|
54
63
|
const trinketsSet = CACHE_FLAG_TO_TRINKETS_MAP.get(cacheFlag);
|
|
55
64
|
if (trinketsSet === undefined) {
|
|
@@ -58,3 +67,16 @@ export function getTrinketsForCacheFlag(
|
|
|
58
67
|
|
|
59
68
|
return copySet(trinketsSet);
|
|
60
69
|
}
|
|
70
|
+
|
|
71
|
+
/** Helper function to check in the item config if a given trinket has a given cache flag. */
|
|
72
|
+
export function trinketHasCacheFlag(
|
|
73
|
+
trinketType: TrinketType,
|
|
74
|
+
cacheFlag: CacheFlag,
|
|
75
|
+
): boolean {
|
|
76
|
+
const itemConfigItem = itemConfig.GetTrinket(trinketType);
|
|
77
|
+
if (itemConfigItem === undefined) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return hasFlag(itemConfigItem.CacheFlags, cacheFlag);
|
|
82
|
+
}
|
|
@@ -2,9 +2,9 @@ import { TrinketType } from "isaac-typescript-definitions";
|
|
|
2
2
|
import { itemConfig } from "../core/cachedClasses";
|
|
3
3
|
import {
|
|
4
4
|
FIRST_TRINKET_TYPE,
|
|
5
|
-
LAST_TRINKET_TYPE,
|
|
6
5
|
LAST_VANILLA_TRINKET_TYPE,
|
|
7
6
|
} from "../core/constantsFirstLast";
|
|
7
|
+
import { getLastTrinketType } from "../features/firstLast";
|
|
8
8
|
import { irange } from "./utils";
|
|
9
9
|
|
|
10
10
|
const ALL_TRINKETS_ARRAY: TrinketType[] = [];
|
|
@@ -15,14 +15,15 @@ const ALL_TRINKETS_SET = new Set<TrinketType>();
|
|
|
15
15
|
const VANILLA_TRINKETS_SET = new Set<TrinketType>();
|
|
16
16
|
const MODDED_TRINKETS_SET = new Set<TrinketType>();
|
|
17
17
|
|
|
18
|
-
function
|
|
18
|
+
function lazyInitTrinketArraysAndSets() {
|
|
19
19
|
if (ALL_TRINKETS_ARRAY.length !== 0) {
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
const lastTrinketType = getLastTrinketType();
|
|
23
24
|
const trinketTypeRange = irange(
|
|
24
25
|
FIRST_TRINKET_TYPE,
|
|
25
|
-
|
|
26
|
+
lastTrinketType,
|
|
26
27
|
) as TrinketType[];
|
|
27
28
|
for (const trinketType of trinketTypeRange) {
|
|
28
29
|
const itemConfigItem = itemConfig.GetTrinket(trinketType);
|
|
@@ -59,11 +60,12 @@ function initTrinketArraysAndSets() {
|
|
|
59
60
|
*
|
|
60
61
|
* Use this if you need to iterate over the trinkets in order. If you need to do O(1) lookups, then
|
|
61
62
|
* use the `getTrinketSet` helper function instead.
|
|
63
|
+
*
|
|
64
|
+
* This function can only be called if at least one callback has been executed. This is because not
|
|
65
|
+
* all trinkets will necessarily be present when a mod first loads (due to mod load order).
|
|
62
66
|
*/
|
|
63
67
|
export function getModdedTrinketArray(): readonly TrinketType[] {
|
|
64
|
-
|
|
65
|
-
initTrinketArraysAndSets();
|
|
66
|
-
|
|
68
|
+
lazyInitTrinketArraysAndSets();
|
|
67
69
|
return MODDED_TRINKETS_ARRAY;
|
|
68
70
|
}
|
|
69
71
|
|
|
@@ -72,11 +74,12 @@ export function getModdedTrinketArray(): readonly TrinketType[] {
|
|
|
72
74
|
*
|
|
73
75
|
* Use this if you need to do O(1) lookups. If you need to iterate over the trinkets in order, then
|
|
74
76
|
* use the `getTrinketArray` helper function instead.
|
|
77
|
+
*
|
|
78
|
+
* This function can only be called if at least one callback has been executed. This is because not
|
|
79
|
+
* all trinkets will necessarily be present when a mod first loads (due to mod load order).
|
|
75
80
|
*/
|
|
76
81
|
export function getModdedTrinketSet(): ReadonlySet<TrinketType> {
|
|
77
|
-
|
|
78
|
-
initTrinketArraysAndSets();
|
|
79
|
-
|
|
82
|
+
lazyInitTrinketArraysAndSets();
|
|
80
83
|
return MODDED_TRINKETS_SET;
|
|
81
84
|
}
|
|
82
85
|
|
|
@@ -85,11 +88,12 @@ export function getModdedTrinketSet(): ReadonlySet<TrinketType> {
|
|
|
85
88
|
*
|
|
86
89
|
* Use this if you need to iterate over the trinkets in order. If you need to do O(1) lookups, then
|
|
87
90
|
* use the `getModdedTrinketSet` helper function instead.
|
|
91
|
+
*
|
|
92
|
+
* This function can only be called if at least one callback has been executed. This is because not
|
|
93
|
+
* all trinkets will necessarily be present when a mod first loads (due to mod load order).
|
|
88
94
|
*/
|
|
89
95
|
export function getTrinketArray(): readonly TrinketType[] {
|
|
90
|
-
|
|
91
|
-
initTrinketArraysAndSets();
|
|
92
|
-
|
|
96
|
+
lazyInitTrinketArraysAndSets();
|
|
93
97
|
return ALL_TRINKETS_ARRAY;
|
|
94
98
|
}
|
|
95
99
|
|
|
@@ -98,11 +102,12 @@ export function getTrinketArray(): readonly TrinketType[] {
|
|
|
98
102
|
*
|
|
99
103
|
* Use this if you need to do O(1) lookups. If you need to iterate over the trinkets in order, then
|
|
100
104
|
* use the `getModdedTrinketArray` helper function instead.
|
|
105
|
+
*
|
|
106
|
+
* This function can only be called if at least one callback has been executed. This is because not
|
|
107
|
+
* all trinkets will necessarily be present when a mod first loads (due to mod load order).
|
|
101
108
|
*/
|
|
102
109
|
export function getTrinketSet(): ReadonlySet<TrinketType> {
|
|
103
|
-
|
|
104
|
-
initTrinketArraysAndSets();
|
|
105
|
-
|
|
110
|
+
lazyInitTrinketArraysAndSets();
|
|
106
111
|
return ALL_TRINKETS_SET;
|
|
107
112
|
}
|
|
108
113
|
|
|
@@ -111,11 +116,12 @@ export function getTrinketSet(): ReadonlySet<TrinketType> {
|
|
|
111
116
|
*
|
|
112
117
|
* Use this if you need to iterate over the trinkets in order. If you need to do O(1) lookups, then
|
|
113
118
|
* 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).
|
|
114
122
|
*/
|
|
115
123
|
export function getVanillaTrinketArray(): readonly TrinketType[] {
|
|
116
|
-
|
|
117
|
-
initTrinketArraysAndSets();
|
|
118
|
-
|
|
124
|
+
lazyInitTrinketArraysAndSets();
|
|
119
125
|
return VANILLA_TRINKETS_ARRAY;
|
|
120
126
|
}
|
|
121
127
|
|
|
@@ -124,10 +130,11 @@ export function getVanillaTrinketArray(): readonly TrinketType[] {
|
|
|
124
130
|
*
|
|
125
131
|
* Use this if you need to do O(1) lookups. If you need to iterate over the trinkets in order, then
|
|
126
132
|
* 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).
|
|
127
136
|
*/
|
|
128
137
|
export function getVanillaTrinketSet(): ReadonlySet<TrinketType> {
|
|
129
|
-
|
|
130
|
-
initTrinketArraysAndSets();
|
|
131
|
-
|
|
138
|
+
lazyInitTrinketArraysAndSets();
|
|
132
139
|
return VANILLA_TRINKETS_SET;
|
|
133
140
|
}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
-
CacheFlag,
|
|
3
2
|
PlayerType,
|
|
4
3
|
TrinketSlot,
|
|
5
4
|
TrinketType,
|
|
6
5
|
} from "isaac-typescript-definitions";
|
|
7
6
|
import { itemConfig } from "../core/cachedClasses";
|
|
8
7
|
import {
|
|
9
|
-
FIRST_MODDED_TRINKET_TYPE,
|
|
10
8
|
FIRST_TRINKET_TYPE,
|
|
11
|
-
LAST_TRINKET_TYPE,
|
|
12
9
|
LAST_VANILLA_TRINKET_TYPE,
|
|
13
10
|
} from "../core/constantsFirstLast";
|
|
14
11
|
import {
|
|
@@ -17,7 +14,6 @@ import {
|
|
|
17
14
|
} from "../maps/trinketDescriptionMap";
|
|
18
15
|
import { DEFAULT_TRINKET_NAME, TRINKET_NAME_MAP } from "../maps/trinketNameMap";
|
|
19
16
|
import { getEntityID } from "./entities";
|
|
20
|
-
import { hasFlag } from "./flag";
|
|
21
17
|
import { isTrinket } from "./pickupVariants";
|
|
22
18
|
import { isCharacter } from "./players";
|
|
23
19
|
import { clearSprite } from "./sprites";
|
|
@@ -45,19 +41,6 @@ export function getGoldenTrinketType(trinketType: TrinketType): TrinketType {
|
|
|
45
41
|
return asNumber(trinketType) + GOLDEN_TRINKET_ADJUSTMENT;
|
|
46
42
|
}
|
|
47
43
|
|
|
48
|
-
/**
|
|
49
|
-
* Helper function to get an array that represents every modded trinket type.
|
|
50
|
-
*
|
|
51
|
-
* Returns an empty array if there are no modded trinket types.
|
|
52
|
-
*/
|
|
53
|
-
export function getModdedTrinketTypes(): TrinketType[] {
|
|
54
|
-
if (LAST_VANILLA_TRINKET_TYPE === LAST_TRINKET_TYPE) {
|
|
55
|
-
return [];
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return irange(FIRST_MODDED_TRINKET_TYPE, LAST_TRINKET_TYPE);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
44
|
/**
|
|
62
45
|
* Returns the slot number corresponding to where a trinket can be safely inserted.
|
|
63
46
|
*
|
|
@@ -139,11 +122,6 @@ export function getTrinketName(trinketType: TrinketType): string {
|
|
|
139
122
|
return DEFAULT_TRINKET_NAME;
|
|
140
123
|
}
|
|
141
124
|
|
|
142
|
-
/** Helper function to get an array that contains every trinket type. */
|
|
143
|
-
export function getTrinketTypes(): TrinketType[] {
|
|
144
|
-
return irange(FIRST_TRINKET_TYPE, LAST_TRINKET_TYPE);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
125
|
/** Helper function to get an array that represents every vanilla trinket type. */
|
|
148
126
|
export function getVanillaTrinketTypes(): TrinketType[] {
|
|
149
127
|
return irange(FIRST_TRINKET_TYPE, LAST_VANILLA_TRINKET_TYPE);
|
|
@@ -200,15 +178,3 @@ export function setTrinketSprite(
|
|
|
200
178
|
sprite.LoadGraphics();
|
|
201
179
|
}
|
|
202
180
|
}
|
|
203
|
-
|
|
204
|
-
export function trinketHasCacheFlag(
|
|
205
|
-
trinketType: TrinketType,
|
|
206
|
-
cacheFlag: CacheFlag,
|
|
207
|
-
): boolean {
|
|
208
|
-
const itemConfigItem = itemConfig.GetTrinket(trinketType);
|
|
209
|
-
if (itemConfigItem === undefined) {
|
|
210
|
-
return false;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
return hasFlag(itemConfigItem.CacheFlags, cacheFlag);
|
|
214
|
-
}
|
package/src/index.ts
CHANGED
|
@@ -29,6 +29,7 @@ export * from "./features/disableInputs";
|
|
|
29
29
|
export * from "./features/extraConsoleCommands/exports";
|
|
30
30
|
export * from "./features/fadeInRemover";
|
|
31
31
|
export * from "./features/fastReset";
|
|
32
|
+
export * from "./features/firstLast";
|
|
32
33
|
export * from "./features/forgottenSwitch";
|
|
33
34
|
export * from "./features/pause";
|
|
34
35
|
export * from "./features/persistentEntities";
|
|
@@ -52,12 +53,12 @@ export * from "./functions/bitSet128";
|
|
|
52
53
|
export * from "./functions/bitwise";
|
|
53
54
|
export * from "./functions/bombs";
|
|
54
55
|
export * from "./functions/bosses";
|
|
55
|
-
export * from "./functions/cacheFlag";
|
|
56
56
|
export * from "./functions/cards";
|
|
57
57
|
export * from "./functions/challenges";
|
|
58
58
|
export * from "./functions/characters";
|
|
59
59
|
export * from "./functions/charge";
|
|
60
60
|
export * from "./functions/chargeBar";
|
|
61
|
+
export * from "./functions/collectibleCacheFlag";
|
|
61
62
|
export * from "./functions/collectibles";
|
|
62
63
|
export * from "./functions/collectibleSet";
|
|
63
64
|
export * from "./functions/collectibleTag";
|
package/src/initFeatures.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { disableAllSoundInit } from "./features/disableAllSound";
|
|
|
11
11
|
import { disableInputsInit } from "./features/disableInputs";
|
|
12
12
|
import { fadeInRemoverInit } from "./features/fadeInRemover";
|
|
13
13
|
import { fastResetInit } from "./features/fastReset";
|
|
14
|
+
import { firstLastInit } from "./features/firstLast";
|
|
14
15
|
import { forgottenSwitchInit } from "./features/forgottenSwitch";
|
|
15
16
|
import { pauseInit } from "./features/pause";
|
|
16
17
|
import { persistentEntitiesInit } from "./features/persistentEntities";
|
|
@@ -49,6 +50,7 @@ function initFeaturesMinor(mod: ModUpgraded) {
|
|
|
49
50
|
disableInputsInit(mod);
|
|
50
51
|
fadeInRemoverInit(mod);
|
|
51
52
|
fastResetInit(mod);
|
|
53
|
+
firstLastInit(mod);
|
|
52
54
|
forgottenSwitchInit(mod);
|
|
53
55
|
collectibleItemPoolTypeInit(mod);
|
|
54
56
|
pauseInit(mod);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cacheFlag.d.ts","sourceRoot":"","sources":["../../src/functions/cacheFlag.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AA4B1E,wBAAgB,uBAAuB,CACrC,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,SAAS,GACnB,OAAO,CAOT;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,SAAS,GACnB,GAAG,CAAC,eAAe,CAAC,CAYtB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM,GAAG,SAAS,CAE7E;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iCAAiC,CAC/C,MAAM,EAAE,YAAY,EACpB,SAAS,EAAE,SAAS,GACnB,eAAe,EAAE,CAYnB"}
|