isaacscript-common 7.11.0 → 7.14.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.
Files changed (37) hide show
  1. package/dist/features/customPickup.d.ts +24 -0
  2. package/dist/features/customPickup.d.ts.map +1 -0
  3. package/dist/features/customPickup.lua +85 -0
  4. package/dist/features/customStage/backdrop.lua +3 -3
  5. package/dist/features/customStage/customStageGridEntities.d.ts.map +1 -1
  6. package/dist/features/customStage/customStageGridEntities.lua +61 -35
  7. package/dist/features/customStage/shadows.lua +2 -2
  8. package/dist/functions/collectibleSet.d.ts.map +1 -1
  9. package/dist/functions/collectibleSet.lua +2 -2
  10. package/dist/functions/npcs.lua +3 -3
  11. package/dist/functions/pickups.lua +2 -2
  12. package/dist/functions/trinketSet.d.ts +44 -0
  13. package/dist/functions/trinketSet.d.ts.map +1 -0
  14. package/dist/functions/trinketSet.lua +101 -0
  15. package/dist/index.d.ts +2 -0
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.lua +13 -0
  18. package/dist/initFeatures.d.ts.map +1 -1
  19. package/dist/initFeatures.lua +3 -0
  20. package/dist/interfaces/CustomStageTSConfig.d.ts +47 -0
  21. package/dist/interfaces/CustomStageTSConfig.d.ts.map +1 -1
  22. package/dist/objects/coinSubTypeToValue.d.ts +1 -1
  23. package/dist/objects/coinSubTypeToValue.d.ts.map +1 -1
  24. package/dist/objects/coinSubTypeToValue.lua +1 -1
  25. package/package.json +1 -1
  26. package/src/features/customPickup.ts +135 -0
  27. package/src/features/customStage/backdrop.ts +2 -2
  28. package/src/features/customStage/customStageGridEntities.ts +58 -16
  29. package/src/features/customStage/shadows.ts +2 -2
  30. package/src/functions/collectibleSet.ts +4 -3
  31. package/src/functions/npcs.ts +2 -2
  32. package/src/functions/pickups.ts +2 -2
  33. package/src/functions/trinketSet.ts +133 -0
  34. package/src/index.ts +2 -0
  35. package/src/initFeatures.ts +2 -0
  36. package/src/interfaces/CustomStageTSConfig.ts +50 -0
  37. package/src/objects/coinSubTypeToValue.ts +1 -1
package/dist/index.lua CHANGED
@@ -156,6 +156,11 @@ do
156
156
  ____exports.removeCustomGridEntity = removeCustomGridEntity
157
157
  ____exports.spawnCustomGridEntity = spawnCustomGridEntity
158
158
  end
159
+ do
160
+ local ____customPickup = require("features.customPickup")
161
+ local registerCustomPickup = ____customPickup.registerCustomPickup
162
+ ____exports.registerCustomPickup = registerCustomPickup
163
+ end
159
164
  do
160
165
  local ____export = require("features.customStage.exports")
161
166
  for ____exportKey, ____exportValue in pairs(____export) do
@@ -1106,6 +1111,14 @@ do
1106
1111
  end
1107
1112
  end
1108
1113
  end
1114
+ do
1115
+ local ____export = require("functions.trinketSet")
1116
+ for ____exportKey, ____exportValue in pairs(____export) do
1117
+ if ____exportKey ~= "default" then
1118
+ ____exports[____exportKey] = ____exportValue
1119
+ end
1120
+ end
1121
+ end
1109
1122
  do
1110
1123
  local ____export = require("functions.tstlClass")
1111
1124
  for ____exportKey, ____exportValue in pairs(____export) do
@@ -1 +1 @@
1
- {"version":3,"file":"initFeatures.d.ts","sourceRoot":"","sources":["../src/initFeatures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AA6BpD,wBAAgB,YAAY,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CAGnD"}
1
+ {"version":3,"file":"initFeatures.d.ts","sourceRoot":"","sources":["../src/initFeatures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AA8BpD,wBAAgB,YAAY,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CAGnD"}
@@ -8,6 +8,8 @@ local ____collectibleItemPoolType = require("features.collectibleItemPoolType")
8
8
  local collectibleItemPoolTypeInit = ____collectibleItemPoolType.collectibleItemPoolTypeInit
9
9
  local ____customGridEntity = require("features.customGridEntity")
10
10
  local customGridEntityInit = ____customGridEntity.customGridEntityInit
11
+ local ____customPickup = require("features.customPickup")
12
+ local customPickupInit = ____customPickup.customPickupInit
11
13
  local ____init = require("features.customStage.init")
12
14
  local customStageInit = ____init.customStageInit
13
15
  local ____init = require("features.customTrapdoor.init")
@@ -63,6 +65,7 @@ function initFeaturesMajor(self, mod)
63
65
  customGridEntityInit(nil, mod)
64
66
  end
65
67
  function initFeaturesMinor(self, mod)
68
+ customPickupInit(nil, mod)
66
69
  customTrapdoorInit(nil, mod)
67
70
  disableAllSoundInit(nil, mod)
68
71
  disableInputsInit(nil, mod)
@@ -119,8 +119,22 @@ export interface CustomStageTSConfig {
119
119
  *
120
120
  * If not specified, the vanilla Basement decorations spritesheet will be used. For reference,
121
121
  * this is located at: `resources/gfx/grid/props_01_basement.png`
122
+ *
123
+ * If you want to have custom animations for your decorations, then do not use this field and use
124
+ * `decorationsANM2Path` instead.
122
125
  */
123
126
  decorationsPNGPath?: string;
127
+ /**
128
+ * Optional. The full path to the anm2 file that contains the custom animations for the
129
+ * decorations of the floor.
130
+ *
131
+ * If not specified, the vanilla Basement decorations spritesheet will be used. For reference,
132
+ * this is located at: `resources/gfx/grid/props_01_basement.png`
133
+ *
134
+ * If you do not want to have custom animations for your decorations, then do not use this field
135
+ * and use `decorationsPNGPath` instead.
136
+ */
137
+ decorationsANM2Path?: string;
124
138
  /**
125
139
  * Optional. The full path to the spritesheet that contains the graphics of the rocks/blocks/urns
126
140
  * for the floor.
@@ -132,16 +146,49 @@ export interface CustomStageTSConfig {
132
146
  *
133
147
  * If not specified, the vanilla Basement rocks spritesheet will be used. For reference, this is
134
148
  * located at: `resources-dlc3/gfx/grid/rocks_basement.png`
149
+ *
150
+ * If you want to have custom animations for your rocks, then do not use this field and use
151
+ * `rocksANM2Path` instead.
135
152
  */
136
153
  rocksPNGPath?: string;
154
+ /**
155
+ * Optional. The full path to the anm2 file that contains the custom animations for the
156
+ * rocks/blocks/urns of the floor.
157
+ *
158
+ * If specified, it is assumed that you have your own custom rock alt type, and all vanilla
159
+ * rewards/enemies that spawn from urns will be automatically removed. Use the
160
+ * `POST_GRID_ENTITY_BROKEN` callback to make your own custom rewards. Or, if you want to emulate
161
+ * a vanilla urn/mushroom/skull/polyp/bucket, use the `spawnRockAltReward` helper function.
162
+ *
163
+ * If not specified, the vanilla Basement rocks spritesheet will be used. For reference, this is
164
+ * located at: `resources-dlc3/gfx/grid/rocks_basement.png`
165
+ *
166
+ * If you do not want to have custom animations for your rocks, then do not use this field and use
167
+ * `rocksPNGPath` instead.
168
+ */
169
+ rocksANM2Path?: string;
137
170
  /**
138
171
  * Optional. The full path to the spritesheet that contains the graphics of the pits for the
139
172
  * floor.
140
173
  *
141
174
  * If not specified, the vanilla Basement pits spritesheet will be used. For reference, this is
142
175
  * located at: `resources/gfx/grid/grid_pit.png`
176
+ *
177
+ * If you do not want to have custom animations for your pits, then do not use this field and use
178
+ * `pitsANM2Path` instead.
143
179
  */
144
180
  pitsPNGPath?: string;
181
+ /**
182
+ * Optional. The full path to the anm2 file that contains the custom animations for the pits of
183
+ * the floor.
184
+ *
185
+ * If not specified, the vanilla Basement pits spritesheet will be used. For reference, this is
186
+ * located at: `resources/gfx/grid/grid_pit.png`
187
+ *
188
+ * If you do not want to have custom animations for your pits, then do not use this field and use
189
+ * `pitsPNGPath` instead.
190
+ */
191
+ pitsANM2Path?: string;
145
192
  /**
146
193
  * Optional. A collection of paths that contain graphics for the doors of the floor. If not
147
194
  * specified, the doors for Basement will be used.
@@ -1 +1 @@
1
- {"version":3,"file":"CustomStageTSConfig.d.ts","sourceRoot":"","sources":["../../src/interfaces/CustomStageTSConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,MAAM,WAAW,mBAAmB;IAClC,+CAA+C;IAC/C,IAAI,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;;;;;;;;OAUG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAE1B;;;;;;;;;;;;;;;;;;OAkBG;IACH,SAAS,CA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;WAMG;QACH,eAAe,CAAC,EAAE;YAChB;;;eAGG;YACH,CAAC,EAAE,MAAM,CAAC;YAEV;;;eAGG;YACH,CAAC,EAAE,MAAM,CAAC;YAEV;;;eAGG;YACH,CAAC,EAAE,MAAM,CAAC;YAEV;;;eAGG;YACH,CAAC,EAAE,MAAM,CAAC;SACX,CAAC;QAEF;;;;;;;WAOG;QACH,aAAa,CAAC,EAAE;YACd;;;eAGG;YACH,CAAC,EAAE,MAAM,CAAC;YAEV;;;eAGG;YACH,CAAC,EAAE,MAAM,CAAC;YAEV;;;eAGG;YACH,CAAC,EAAE,MAAM,CAAC;YAEV;;;eAGG;YACH,CAAC,EAAE,MAAM,CAAC;SACX,CAAC;KACH,CAAC;CACH;AAED;;;GAGG;AAEH,MAAM,WAAW,iBAAiB;IAChC;;;;;OAKG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;;;OAKG;IACH,KAAK,CAAC,EAAE;QACN;;;WAGG;QACH,CAAC,EAAE,MAAM,CAAC;QAEV;;;WAGG;QACH,CAAC,EAAE,MAAM,CAAC;QAEV;;;WAGG;QACH,CAAC,EAAE,MAAM,CAAC;QAEV;;;WAGG;QACH,CAAC,EAAE,MAAM,CAAC;KACX,CAAC;CACH;AAED;;;GAGG;AAEH,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;;;;;;;;;;;;;OAeG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf,kFAAkF;IAClF,YAAY,CAAC,EAAE;QAEb;;;;;WAKG;QACH,WAAW,EAAE,MAAM,CAAC;QAGpB;;;;;WAKG;QACH,eAAe,EAAE,MAAM,CAAC;KACzB,CAAC;CACH"}
@@ -1,6 +1,6 @@
1
1
  import { CoinSubType } from "isaac-typescript-definitions";
2
2
  export declare const DEFAULT_COIN_VALUE = 1;
3
- export declare const COIN_SUBTYPE_TO_VALUE: {
3
+ export declare const COIN_SUB_TYPE_TO_VALUE: {
4
4
  readonly [key in CoinSubType]: int;
5
5
  };
6
6
  //# sourceMappingURL=coinSubTypeToValue.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"coinSubTypeToValue.d.ts","sourceRoot":"","sources":["../../src/objects/coinSubTypeToValue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D,eAAO,MAAM,kBAAkB,IAAI,CAAC;AAEpC,eAAO,MAAM,qBAAqB,EAAE;IAAE,QAAQ,EAAE,GAAG,IAAI,WAAW,GAAG,GAAG;CAS9D,CAAC"}
1
+ {"version":3,"file":"coinSubTypeToValue.d.ts","sourceRoot":"","sources":["../../src/objects/coinSubTypeToValue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D,eAAO,MAAM,kBAAkB,IAAI,CAAC;AAEpC,eAAO,MAAM,sBAAsB,EAAE;IAAE,QAAQ,EAAE,GAAG,IAAI,WAAW,GAAG,GAAG;CAS/D,CAAC"}
@@ -2,7 +2,7 @@ local ____exports = {}
2
2
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
3
3
  local CoinSubType = ____isaac_2Dtypescript_2Ddefinitions.CoinSubType
4
4
  ____exports.DEFAULT_COIN_VALUE = 1
5
- ____exports.COIN_SUBTYPE_TO_VALUE = {
5
+ ____exports.COIN_SUB_TYPE_TO_VALUE = {
6
6
  [CoinSubType.NULL] = 0,
7
7
  [CoinSubType.PENNY] = 1,
8
8
  [CoinSubType.NICKEL] = 5,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "7.11.0",
3
+ "version": "7.14.0",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -0,0 +1,135 @@
1
+ import {
2
+ EffectVariant,
3
+ EntityType,
4
+ ModCallback,
5
+ PickupVariant,
6
+ } from "isaac-typescript-definitions";
7
+ import { errorIfFeaturesNotInitialized } from "../featuresInitialized";
8
+ import {
9
+ getEntityID,
10
+ getEntityIDFromConstituents,
11
+ } from "../functions/entities";
12
+ import { spawnEffect } from "../functions/entitiesSpecific";
13
+
14
+ const FEATURE_NAME = "customPickup";
15
+
16
+ interface CustomPickupFunctions {
17
+ collectFunc: (player: EntityPlayer) => void;
18
+ collisionFunc: (player: EntityPlayer) => boolean;
19
+ }
20
+
21
+ /**
22
+ * Normally, we would make a custom entity to represent a fading-away pickup, but we don't want to
23
+ * interfere with the "entities2.xml" file in end-user mods. Thus, we must select a vanilla effect
24
+ * to masquerade as a backdrop effect.
25
+ *
26
+ * We arbitrarily choose a ladder for this purpose because it will not automatically despawn after
27
+ * time passes, like most other effects.
28
+ */
29
+ const PICKUP_EFFECT_VARIANT = EffectVariant.LADDER;
30
+ const PICKUP_EFFECT_SUB_TYPE = 103;
31
+
32
+ /** Indexed by entity ID. */
33
+ const customPickupFunctionsMap = new Map<string, CustomPickupFunctions>();
34
+
35
+ export function customPickupInit(mod: Mod): void {
36
+ mod.AddCallback(ModCallback.PRE_PICKUP_COLLISION, prePickupCollision); // 38
37
+ mod.AddCallback(
38
+ ModCallback.POST_EFFECT_RENDER,
39
+ postEffectRenderPickupEffect,
40
+ PICKUP_EFFECT_VARIANT,
41
+ ); // 56
42
+ }
43
+
44
+ // ModCallback.PRE_PICKUP_COLLISION (38)
45
+ function prePickupCollision(
46
+ pickup: EntityPickup,
47
+ collider: Entity,
48
+ ): boolean | undefined {
49
+ const entityID = getEntityID(pickup);
50
+ const customPickupFunctions = customPickupFunctionsMap.get(entityID);
51
+ if (customPickupFunctions === undefined) {
52
+ return undefined;
53
+ }
54
+
55
+ const player = collider.ToPlayer();
56
+ if (player === undefined) {
57
+ return undefined;
58
+ }
59
+
60
+ const shouldPickup = customPickupFunctions.collisionFunc(player);
61
+ if (!shouldPickup) {
62
+ return undefined;
63
+ }
64
+
65
+ pickup.Remove();
66
+
67
+ const pickupSprite = pickup.GetSprite();
68
+ const fileName = pickupSprite.GetFilename();
69
+
70
+ const effect = spawnEffect(
71
+ PICKUP_EFFECT_VARIANT,
72
+ PICKUP_EFFECT_SUB_TYPE,
73
+ pickup.Position,
74
+ );
75
+ const effectSprite = effect.GetSprite();
76
+ effectSprite.Load(fileName, true);
77
+ effectSprite.Play("Collect", true);
78
+
79
+ customPickupFunctions.collectFunc(player);
80
+
81
+ return undefined;
82
+ }
83
+
84
+ // ModCallback.POST_EFFECT_RENDER (56)
85
+ // PICKUP_EFFECT_VARIANT
86
+ function postEffectRenderPickupEffect(effect: EntityEffect) {
87
+ if (effect.SubType !== PICKUP_EFFECT_SUB_TYPE) {
88
+ return;
89
+ }
90
+
91
+ const sprite = effect.GetSprite();
92
+ if (sprite.IsFinished("Collect")) {
93
+ effect.Remove();
94
+ }
95
+ }
96
+
97
+ /**
98
+ * Helper function to register a custom pickup with the IsaacScript standard library. Use this
99
+ * feature for custom pickups that are intended to be picked up by the player, like keys and bombs.
100
+ *
101
+ * When IsaacScript detects that a player should be collecting the custom pickup, then the pickup
102
+ * will be immediately removed, and an effect showing the pickup's respective `Collect` animation
103
+ * will be spawned. (This emulates how a normal vanilla pickup would work.)
104
+ *
105
+ * Note that when you specify your custom pickup in the "entities2.xml" file, it should have a type
106
+ * of "5" and be associated with an anm2 file that has a "Collect" animation.
107
+ *
108
+ * @param pickupVariantCustom The variant for the corresponding custom pickup.
109
+ * @param subType The sub-type for the corresponding custom pickup.
110
+ * @param collectFunc The function to run when the player collects this pickup.
111
+ * @param collisionFunc Optional. The function to run when a player collides with the pickup.
112
+ * Default is a function that always returns true, meaning that the player will
113
+ * always immediately collect the pickup when they collide with it. Specify
114
+ * this function if your pickup should only be able to be collected under
115
+ * certain conditions.
116
+ */
117
+ export function registerCustomPickup(
118
+ pickupVariantCustom: PickupVariant,
119
+ subType: int,
120
+ collectFunc: (player: EntityPlayer) => void,
121
+ collisionFunc: (player: EntityPlayer) => boolean = () => true,
122
+ ): void {
123
+ errorIfFeaturesNotInitialized(FEATURE_NAME);
124
+
125
+ const entityID = getEntityIDFromConstituents(
126
+ EntityType.PICKUP,
127
+ pickupVariantCustom,
128
+ subType,
129
+ );
130
+ const customPickupFunctions: CustomPickupFunctions = {
131
+ collectFunc,
132
+ collisionFunc,
133
+ };
134
+ customPickupFunctionsMap.set(entityID, customPickupFunctions);
135
+ }
@@ -83,7 +83,7 @@ const N_FLOOR_ANM2_LAYERS: readonly int[] = [18, 19];
83
83
  * time passes, like most other effects.
84
84
  */
85
85
  const BACKDROP_EFFECT_VARIANT = EffectVariant.LADDER;
86
- const BACKDROP_EFFECT_SUBTYPE = 101;
86
+ const BACKDROP_EFFECT_SUB_TYPE = 101;
87
87
 
88
88
  const BACKDROP_ROOM_TYPE_SET: ReadonlySet<RoomType> = new Set([
89
89
  RoomType.DEFAULT,
@@ -135,7 +135,7 @@ function spawnWallEntity(
135
135
  const seed = 1 as Seed;
136
136
  const wallEffect = spawnEffectWithSeed(
137
137
  BACKDROP_EFFECT_VARIANT,
138
- BACKDROP_EFFECT_SUBTYPE,
138
+ BACKDROP_EFFECT_SUB_TYPE,
139
139
  VectorZero,
140
140
  seed,
141
141
  );
@@ -32,15 +32,13 @@ export function setCustomDecorationGraphics(
32
32
  ): void {
33
33
  // If the end-user did not specify custom decoration graphics, default to Basement graphics. (We
34
34
  // don't have to adjust anything for this case.)
35
- if (customStage.decorationsPNGPath === undefined) {
35
+ if (
36
+ customStage.decorationsPNGPath === undefined &&
37
+ customStage.decorationsANM2Path === undefined
38
+ ) {
36
39
  return;
37
40
  }
38
41
 
39
- const pngPath = removeCharactersBefore(
40
- customStage.decorationsPNGPath,
41
- "gfx/",
42
- );
43
-
44
42
  if (isCustomGridEntity(gridEntity)) {
45
43
  return;
46
44
  }
@@ -53,7 +51,21 @@ export function setCustomDecorationGraphics(
53
51
  const sprite = gridEntity.GetSprite();
54
52
  const fileName = sprite.GetFilename();
55
53
  // On Windows, this is: gfx/grid/Props_01_Basement.anm2
56
- if (fileName.toLowerCase() === "gfx/grid/props_01_basement.anm2") {
54
+ if (fileName.toLowerCase() !== "gfx/grid/props_01_basement.anm2") {
55
+ return;
56
+ }
57
+
58
+ if (customStage.decorationsANM2Path !== undefined) {
59
+ const anm2Path = removeCharactersBefore(
60
+ customStage.decorationsANM2Path,
61
+ "gfx/",
62
+ );
63
+ sprite.Load(anm2Path, true);
64
+ } else if (customStage.decorationsPNGPath !== undefined) {
65
+ const pngPath = removeCharactersBefore(
66
+ customStage.decorationsPNGPath,
67
+ "gfx/",
68
+ );
57
69
  sprite.ReplaceSpritesheet(0, pngPath);
58
70
  sprite.LoadGraphics();
59
71
  }
@@ -66,12 +78,13 @@ export function setCustomRockGraphics(
66
78
  ): void {
67
79
  // If the end-user did not specify custom rock graphics, default to Basement graphics. (We don't
68
80
  // have to adjust anything for this case.)
69
- if (customStage.rocksPNGPath === undefined) {
81
+ if (
82
+ customStage.rocksPNGPath === undefined &&
83
+ customStage.rocksANM2Path === undefined
84
+ ) {
70
85
  return;
71
86
  }
72
87
 
73
- const pngPath = removeCharactersBefore(customStage.rocksPNGPath, "gfx/");
74
-
75
88
  if (isCustomGridEntity(gridEntity)) {
76
89
  return;
77
90
  }
@@ -83,12 +96,41 @@ export function setCustomRockGraphics(
83
96
 
84
97
  const sprite = gridEntity.GetSprite();
85
98
  const fileName = sprite.GetFilename();
86
- if (fileName === "gfx/grid/grid_rock.anm2") {
87
- sprite.ReplaceSpritesheet(0, pngPath);
88
- sprite.LoadGraphics();
89
- } else if (fileName === "gfx/grid/grid_pit.anm2") {
90
- sprite.ReplaceSpritesheet(1, pngPath);
91
- sprite.LoadGraphics();
99
+
100
+ switch (fileName) {
101
+ case "gfx/grid/grid_rock.anm2": {
102
+ // The normal case of a rock.
103
+ if (customStage.rocksANM2Path !== undefined) {
104
+ const anm2Path = removeCharactersBefore(
105
+ customStage.rocksANM2Path,
106
+ "gfx/",
107
+ );
108
+ sprite.Load(anm2Path, true);
109
+ } else if (customStage.rocksPNGPath !== undefined) {
110
+ const pngPath = removeCharactersBefore(
111
+ customStage.rocksPNGPath,
112
+ "gfx/",
113
+ );
114
+ sprite.ReplaceSpritesheet(0, pngPath);
115
+ sprite.LoadGraphics();
116
+ }
117
+
118
+ break;
119
+ }
120
+
121
+ case "gfx/grid/grid_pit.anm2": {
122
+ // The case of when a rock is blown on a pit to make a bridge.
123
+ if (customStage.rocksPNGPath !== undefined) {
124
+ const pngPath = removeCharactersBefore(
125
+ customStage.rocksPNGPath,
126
+ "gfx/",
127
+ );
128
+ sprite.ReplaceSpritesheet(1, pngPath);
129
+ sprite.LoadGraphics();
130
+ }
131
+
132
+ break;
133
+ }
92
134
  }
93
135
  }
94
136
 
@@ -18,7 +18,7 @@ type ShadowAnimation = "1x1" | "1x2" | "2x1" | "2x2";
18
18
  * time passes, like most other effects.
19
19
  */
20
20
  const SHADOW_EFFECT_VARIANT = EffectVariant.LADDER;
21
- const SHADOW_EFFECT_SUBTYPE = 102;
21
+ const SHADOW_EFFECT_SUB_TYPE = 102;
22
22
 
23
23
  /** The animation comes from StageAPI. */
24
24
  const ROOM_SHAPE_TO_SHADOW_ANIMATION: {
@@ -60,7 +60,7 @@ export function setShadows(customStage: CustomStage): void {
60
60
  const seed = 1 as Seed;
61
61
  const shadowEffect = spawnEffectWithSeed(
62
62
  SHADOW_EFFECT_VARIANT,
63
- SHADOW_EFFECT_SUBTYPE,
63
+ SHADOW_EFFECT_SUB_TYPE,
64
64
  centerPos,
65
65
  seed,
66
66
  );
@@ -39,15 +39,16 @@ function initCollectibleArraysAndSets() {
39
39
  }
40
40
 
41
41
  ALL_COLLECTIBLES_ARRAY.sort();
42
- VANILLA_COLLECTIBLES_ARRAY.sort();
43
- MODDED_COLLECTIBLES_ARRAY.sort();
44
-
45
42
  for (const collectibleType of ALL_COLLECTIBLES_ARRAY) {
46
43
  ALL_COLLECTIBLES_SET.add(collectibleType);
47
44
  }
45
+
46
+ VANILLA_COLLECTIBLES_ARRAY.sort();
48
47
  for (const collectibleType of VANILLA_COLLECTIBLES_ARRAY) {
49
48
  VANILLA_COLLECTIBLES_SET.add(collectibleType);
50
49
  }
50
+
51
+ MODDED_COLLECTIBLES_ARRAY.sort();
51
52
  for (const collectibleType of MODDED_COLLECTIBLES_ARRAY) {
52
53
  MODDED_COLLECTIBLES_SET.add(collectibleType);
53
54
  }
@@ -41,7 +41,7 @@ const NON_ALIVE_NPCS_TYPE_VARIANT: ReadonlySet<string> = new Set([
41
41
  * Used to filter out certain NPCs when determining of an NPC is "alive" and/or should keep the
42
42
  * doors open.
43
43
  */
44
- const NON_ALIVE_NPCS_TYPE_VARIANT_SUBTYPE: ReadonlySet<string> = new Set([
44
+ const NON_ALIVE_NPCS_TYPE_VARIANT_SUB_TYPE: ReadonlySet<string> = new Set([
45
45
  `${EntityType.CHARGER}.${ChargerVariant.CHARGER}.${ChargerSubType.MY_SHADOW}`, // 23.0.1
46
46
  `${EntityType.MOTHER}.${MotherVariant.MOTHER_1}.${MotherSubType.PHASE_2}`, // 912
47
47
  ]);
@@ -81,7 +81,7 @@ export function isAliveExceptionNPC(npc: EntityNPC): boolean {
81
81
  }
82
82
 
83
83
  const entityTypeVariantSubType = `${npc.Type}.${npc.Variant}.${npc.SubType}`;
84
- if (NON_ALIVE_NPCS_TYPE_VARIANT_SUBTYPE.has(entityTypeVariantSubType)) {
84
+ if (NON_ALIVE_NPCS_TYPE_VARIANT_SUB_TYPE.has(entityTypeVariantSubType)) {
85
85
  return true;
86
86
  }
87
87
 
@@ -1,6 +1,6 @@
1
1
  import { CoinSubType } from "isaac-typescript-definitions";
2
2
  import {
3
- COIN_SUBTYPE_TO_VALUE,
3
+ COIN_SUB_TYPE_TO_VALUE,
4
4
  DEFAULT_COIN_VALUE,
5
5
  } from "../objects/coinSubTypeToValue";
6
6
  import { CHEST_PICKUP_VARIANTS } from "../sets/chestPickupVariantsSet";
@@ -14,7 +14,7 @@ import { isHeart } from "./pickupVariants";
14
14
  * sub-types.
15
15
  */
16
16
  export function getCoinValue(coinSubType: CoinSubType): int {
17
- const value = COIN_SUBTYPE_TO_VALUE[coinSubType];
17
+ const value = COIN_SUB_TYPE_TO_VALUE[coinSubType];
18
18
  // Handle modded coin sub-types.
19
19
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
20
20
  return value === undefined ? DEFAULT_COIN_VALUE : value;
@@ -0,0 +1,133 @@
1
+ import { TrinketType } from "isaac-typescript-definitions";
2
+ import { itemConfig } from "../core/cachedClasses";
3
+ import {
4
+ FIRST_TRINKET_TYPE,
5
+ LAST_TRINKET_TYPE,
6
+ LAST_VANILLA_TRINKET_TYPE,
7
+ } from "../core/constantsFirstLast";
8
+ import { irange } from "./utils";
9
+
10
+ const ALL_TRINKETS_ARRAY: TrinketType[] = [];
11
+ const VANILLA_TRINKETS_ARRAY: TrinketType[] = [];
12
+ const MODDED_TRINKETS_ARRAY: TrinketType[] = [];
13
+
14
+ const ALL_TRINKETS_SET = new Set<TrinketType>();
15
+ const VANILLA_TRINKETS_SET = new Set<TrinketType>();
16
+ const MODDED_TRINKETS_SET = new Set<TrinketType>();
17
+
18
+ function initTrinketArraysAndSets() {
19
+ if (ALL_TRINKETS_ARRAY.length !== 0) {
20
+ return;
21
+ }
22
+
23
+ const trinketTypeRange = irange(
24
+ FIRST_TRINKET_TYPE,
25
+ LAST_TRINKET_TYPE,
26
+ ) as TrinketType[];
27
+ for (const trinketType of trinketTypeRange) {
28
+ const itemConfigItem = itemConfig.GetTrinket(trinketType);
29
+ if (itemConfigItem === undefined) {
30
+ continue;
31
+ }
32
+
33
+ ALL_TRINKETS_ARRAY.push(trinketType);
34
+ if (trinketType <= LAST_VANILLA_TRINKET_TYPE) {
35
+ VANILLA_TRINKETS_ARRAY.push(trinketType);
36
+ } else {
37
+ MODDED_TRINKETS_ARRAY.push(trinketType);
38
+ }
39
+ }
40
+
41
+ ALL_TRINKETS_ARRAY.sort();
42
+ for (const trinketType of ALL_TRINKETS_ARRAY) {
43
+ ALL_TRINKETS_SET.add(trinketType);
44
+ }
45
+
46
+ VANILLA_TRINKETS_ARRAY.sort();
47
+ for (const trinketType of VANILLA_TRINKETS_ARRAY) {
48
+ VANILLA_TRINKETS_SET.add(trinketType);
49
+ }
50
+
51
+ MODDED_TRINKETS_ARRAY.sort();
52
+ for (const trinketType of MODDED_TRINKETS_ARRAY) {
53
+ MODDED_TRINKETS_SET.add(trinketType);
54
+ }
55
+ }
56
+
57
+ /**
58
+ * Returns an array containing every valid trinket type in the game, including modded trinkets.
59
+ *
60
+ * Use this if you need to iterate over the trinkets in order. If you need to do O(1) lookups, then
61
+ * use the `getTrinketSet` helper function instead.
62
+ */
63
+ export function getModdedTrinketArray(): readonly TrinketType[] {
64
+ // Lazy initialize the arrays/sets.
65
+ initTrinketArraysAndSets();
66
+
67
+ return MODDED_TRINKETS_ARRAY;
68
+ }
69
+
70
+ /**
71
+ * Returns a set containing every valid trinket type in the game, including modded trinkets.
72
+ *
73
+ * Use this if you need to do O(1) lookups. If you need to iterate over the trinkets in order, then
74
+ * use the `getTrinketArray` helper function instead.
75
+ */
76
+ export function getModdedTrinketSet(): ReadonlySet<TrinketType> {
77
+ // Lazy initialize the arrays/sets.
78
+ initTrinketArraysAndSets();
79
+
80
+ return MODDED_TRINKETS_SET;
81
+ }
82
+
83
+ /**
84
+ * Returns an array containing every modded trinket type in the game.
85
+ *
86
+ * Use this if you need to iterate over the trinkets in order. If you need to do O(1) lookups, then
87
+ * use the `getModdedTrinketSet` helper function instead.
88
+ */
89
+ export function getTrinketArray(): readonly TrinketType[] {
90
+ // Lazy initialize the arrays/sets.
91
+ initTrinketArraysAndSets();
92
+
93
+ return ALL_TRINKETS_ARRAY;
94
+ }
95
+
96
+ /**
97
+ * Returns a set containing every modded trinket type in the game.
98
+ *
99
+ * Use this if you need to do O(1) lookups. If you need to iterate over the trinkets in order, then
100
+ * use the `getModdedTrinketArray` helper function instead.
101
+ */
102
+ export function getTrinketSet(): ReadonlySet<TrinketType> {
103
+ // Lazy initialize the arrays/sets.
104
+ initTrinketArraysAndSets();
105
+
106
+ return ALL_TRINKETS_SET;
107
+ }
108
+
109
+ /**
110
+ * Returns an array containing every valid vanilla trinket type in the game.
111
+ *
112
+ * Use this if you need to iterate over the trinkets in order. If you need to do O(1) lookups, then
113
+ * use the `getVanillaTrinketSet` helper function instead.
114
+ */
115
+ export function getVanillaTrinketArray(): readonly TrinketType[] {
116
+ // Lazy initialize the arrays/sets.
117
+ initTrinketArraysAndSets();
118
+
119
+ return VANILLA_TRINKETS_ARRAY;
120
+ }
121
+
122
+ /**
123
+ * Returns a set containing every valid vanilla trinket type in the game.
124
+ *
125
+ * Use this if you need to do O(1) lookups. If you need to iterate over the trinkets in order, then
126
+ * use the `getVanillaTrinketArray` helper function instead.
127
+ */
128
+ export function getVanillaTrinketSet(): ReadonlySet<TrinketType> {
129
+ // Lazy initialize the arrays/sets.
130
+ initTrinketArraysAndSets();
131
+
132
+ return VANILLA_TRINKETS_SET;
133
+ }
package/src/index.ts CHANGED
@@ -25,6 +25,7 @@ export {
25
25
  removeCustomGridEntity,
26
26
  spawnCustomGridEntity,
27
27
  } from "./features/customGridEntity";
28
+ export { registerCustomPickup } from "./features/customPickup";
28
29
  export * from "./features/customStage/exports";
29
30
  export * from "./features/customTrapdoor/exports";
30
31
  export * from "./features/debugDisplay/exports";
@@ -175,6 +176,7 @@ export * from "./functions/transformations";
175
176
  export * from "./functions/trinketCacheFlag";
176
177
  export * from "./functions/trinketGive";
177
178
  export * from "./functions/trinkets";
179
+ export * from "./functions/trinketSet";
178
180
  export * from "./functions/tstlClass";
179
181
  export * from "./functions/types";
180
182
  export * from "./functions/ui";
@@ -3,6 +3,7 @@ import { characterHealthConversionInit } from "./features/characterHealthConvers
3
3
  import { characterStatsInit } from "./features/characterStats";
4
4
  import { collectibleItemPoolTypeInit } from "./features/collectibleItemPoolType";
5
5
  import { customGridEntityInit } from "./features/customGridEntity";
6
+ import { customPickupInit } from "./features/customPickup";
6
7
  import { customStageInit } from "./features/customStage/init";
7
8
  import { customTrapdoorInit } from "./features/customTrapdoor/init";
8
9
  import { deployJSONRoomInit } from "./features/deployJSONRoom";
@@ -42,6 +43,7 @@ function initFeaturesMajor(mod: ModUpgraded) {
42
43
  }
43
44
 
44
45
  function initFeaturesMinor(mod: ModUpgraded) {
46
+ customPickupInit(mod);
45
47
  customTrapdoorInit(mod);
46
48
  disableAllSoundInit(mod);
47
49
  disableInputsInit(mod);