isaacscript-common 29.5.0 → 29.5.2

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 (70) hide show
  1. package/dist/index.rollup.d.ts +148 -228
  2. package/dist/isaacscript-common.lua +1682 -1711
  3. package/dist/src/callbackClasses.d.ts +0 -1
  4. package/dist/src/callbackClasses.d.ts.map +1 -1
  5. package/dist/src/callbackClasses.lua +0 -5
  6. package/dist/src/callbacks.d.ts +126 -127
  7. package/dist/src/callbacks.d.ts.map +1 -1
  8. package/dist/src/callbacks.lua +0 -1
  9. package/dist/src/classes/features/callbackLogic/EsauJrDetection.d.ts +1 -1
  10. package/dist/src/classes/features/callbackLogic/EsauJrDetection.d.ts.map +1 -1
  11. package/dist/src/classes/features/callbackLogic/EsauJrDetection.lua +2 -2
  12. package/dist/src/classes/features/callbackLogic/FlipDetection.d.ts +1 -1
  13. package/dist/src/classes/features/callbackLogic/FlipDetection.d.ts.map +1 -1
  14. package/dist/src/classes/features/callbackLogic/FlipDetection.lua +2 -2
  15. package/dist/src/classes/features/callbackLogic/GameReorderedCallbacks.d.ts +1 -1
  16. package/dist/src/classes/features/callbackLogic/GameReorderedCallbacks.d.ts.map +1 -1
  17. package/dist/src/classes/features/callbackLogic/GameReorderedCallbacks.lua +2 -2
  18. package/dist/src/classes/features/callbackLogic/PlayerCollectibleDetection.d.ts +1 -1
  19. package/dist/src/classes/features/callbackLogic/PlayerCollectibleDetection.d.ts.map +1 -1
  20. package/dist/src/classes/features/callbackLogic/PlayerCollectibleDetection.lua +2 -2
  21. package/dist/src/classes/features/other/PickupIndexCreation.d.ts +4 -0
  22. package/dist/src/classes/features/other/PickupIndexCreation.d.ts.map +1 -1
  23. package/dist/src/classes/features/other/PreventCollectibleRotation.d.ts +9 -3
  24. package/dist/src/classes/features/other/PreventCollectibleRotation.d.ts.map +1 -1
  25. package/dist/src/classes/features/other/PreventCollectibleRotation.lua +66 -25
  26. package/dist/src/enums/ModCallbackCustom.d.ts +126 -144
  27. package/dist/src/enums/ModCallbackCustom.d.ts.map +1 -1
  28. package/dist/src/enums/ModCallbackCustom.lua +126 -128
  29. package/dist/src/features.d.ts.map +1 -1
  30. package/dist/src/features.lua +2 -2
  31. package/dist/src/functions/collectibles.d.ts +0 -52
  32. package/dist/src/functions/collectibles.d.ts.map +1 -1
  33. package/dist/src/functions/collectibles.lua +0 -68
  34. package/dist/src/functions/playerIndex.d.ts +3 -3
  35. package/dist/src/functions/playerIndex.lua +3 -3
  36. package/dist/src/functions/utils.d.ts +2 -0
  37. package/dist/src/functions/utils.d.ts.map +1 -1
  38. package/dist/src/functions/utils.lua +2 -0
  39. package/dist/src/index.d.ts +0 -1
  40. package/dist/src/index.d.ts.map +1 -1
  41. package/dist/src/interfaces/private/AddCallbackParametersCustom.d.ts +0 -4
  42. package/dist/src/interfaces/private/AddCallbackParametersCustom.d.ts.map +1 -1
  43. package/dist/src/shouldFire.d.ts +0 -1
  44. package/dist/src/shouldFire.d.ts.map +1 -1
  45. package/dist/src/shouldFire.lua +0 -5
  46. package/package.json +2 -2
  47. package/src/callbackClasses.ts +0 -1
  48. package/src/callbacks.ts +0 -1
  49. package/src/classes/features/callbackLogic/EsauJrDetection.ts +2 -2
  50. package/src/classes/features/callbackLogic/FlipDetection.ts +2 -2
  51. package/src/classes/features/callbackLogic/GameReorderedCallbacks.ts +2 -2
  52. package/src/classes/features/callbackLogic/PlayerCollectibleDetection.ts +2 -2
  53. package/src/classes/features/other/PickupIndexCreation.ts +4 -0
  54. package/src/classes/features/other/PreventCollectibleRotation.ts +108 -49
  55. package/src/enums/ModCallbackCustom.ts +0 -19
  56. package/src/features.ts +7 -5
  57. package/src/functions/collectibles.ts +0 -79
  58. package/src/functions/playerIndex.ts +3 -3
  59. package/src/functions/utils.ts +2 -0
  60. package/src/index.ts +0 -1
  61. package/src/interfaces/private/AddCallbackParametersCustom.ts +0 -5
  62. package/src/shouldFire.ts +0 -13
  63. package/dist/src/classes/callbacks/PostCollectibleInitFirst.d.ts +0 -15
  64. package/dist/src/classes/callbacks/PostCollectibleInitFirst.d.ts.map +0 -1
  65. package/dist/src/classes/callbacks/PostCollectibleInitFirst.lua +0 -36
  66. package/dist/src/types/CollectibleIndex.d.ts +0 -18
  67. package/dist/src/types/CollectibleIndex.d.ts.map +0 -1
  68. package/dist/src/types/CollectibleIndex.lua +0 -2
  69. package/src/classes/callbacks/PostCollectibleInitFirst.ts +0 -44
  70. package/src/types/CollectibleIndex.ts +0 -17
@@ -1,29 +1,41 @@
1
1
  import {
2
2
  CardType,
3
3
  CollectibleType,
4
+ DiceFloorSubType,
4
5
  ModCallback,
5
6
  PickupVariant,
6
7
  } from "isaac-typescript-definitions";
7
8
  import { game } from "../../../core/cachedClasses";
8
9
  import { Exported } from "../../../decorators";
10
+ import { ISCFeature } from "../../../enums/ISCFeature";
11
+ import { ModCallbackCustom } from "../../../enums/ModCallbackCustom";
9
12
  import { setCollectibleSubType } from "../../../functions/collectibles";
10
13
  import { getEntityID } from "../../../functions/entities";
14
+ import { getCollectibles } from "../../../functions/pickupsSpecific";
11
15
  import { isCollectible } from "../../../functions/pickupVariants";
16
+ import { asCollectibleType } from "../../../functions/types";
17
+ import { PickupIndex } from "../../../types/PickupIndex";
18
+ import { ReadonlySet } from "../../../types/ReadonlySet";
12
19
  import { Feature } from "../../private/Feature";
20
+ import { PickupIndexCreation } from "./PickupIndexCreation";
21
+
22
+ const ROLL_COLLECTIBLE_TYPES = new ReadonlySet([
23
+ // The `PRE_USE_ITEM` D6 callback is fired for D6, D100, Dice Shard, 4-pip Dice Room, and 6-pip
24
+ // Dice Room.
25
+ CollectibleType.D6, // 105
26
+ CollectibleType.ETERNAL_D6, // 609
27
+ CollectibleType.SPINDOWN_DICE, // 723
28
+ ]);
29
+
30
+ const ROLL_FLOOR_DICE_FLOOR_SUB_TYPES = new ReadonlySet([
31
+ DiceFloorSubType.FOUR_PIP,
32
+ DiceFloorSubType.SIX_PIP,
33
+ ]);
13
34
 
14
35
  const v = {
15
- room: {
16
- /**
17
- * Index is a string containing the grid index and the InitSeed of the collectible.
18
- * (e.g. "12,1123579202")
19
- *
20
- * (We cannot simply use the InitSeed of the collectible because Diplopia can cause multiple
21
- * collectibles in the room to have the same InitSeed. However, no two collectibles should ever
22
- * be on the same grid index.)
23
- *
24
- * (We cannot use PtrHash as an index because that stays the same when the item is rolled.)
25
- */
26
- trackedCollectibles: new Map<string, CollectibleType>(),
36
+ run: {
37
+ trackedCollectibles: new Map<PickupIndex, CollectibleType>(),
38
+ rollGameFrame: null as int | null,
27
39
  },
28
40
  };
29
41
 
@@ -31,59 +43,106 @@ export class PreventCollectibleRotation extends Feature {
31
43
  /** @internal */
32
44
  public override v = v;
33
45
 
46
+ private pickupIndexCreation: PickupIndexCreation;
47
+
34
48
  /** @internal */
35
- constructor() {
49
+ constructor(pickupIndexCreation: PickupIndexCreation) {
36
50
  super();
37
51
 
52
+ this.featuresUsed = [ISCFeature.PICKUP_INDEX_CREATION];
53
+
38
54
  this.callbacksUsed = [
39
55
  // 5
40
56
  [
41
57
  ModCallback.POST_USE_CARD,
42
- this.useCardSoulOfIsaac,
58
+ this.postUseCardSoulOfIsaac,
43
59
  [CardType.SOUL_ISAAC],
44
60
  ],
45
61
 
46
- // 35
47
- [
48
- ModCallback.POST_PICKUP_UPDATE,
49
- this.postPickupUpdateCollectible,
50
- [PickupVariant.COLLECTIBLE],
51
- ],
62
+ // 23, 105
63
+ [ModCallback.PRE_USE_ITEM, this.preUseItem],
64
+ ];
65
+
66
+ this.customCallbacksUsed = [
67
+ [ModCallbackCustom.POST_DICE_ROOM_ACTIVATED, this.postDiceRoomActivated],
68
+ [ModCallbackCustom.POST_PICKUP_CHANGED, this.postPickupChanged],
52
69
  ];
70
+
71
+ this.pickupIndexCreation = pickupIndexCreation;
53
72
  }
54
73
 
74
+ private preUseItem = (
75
+ collectibleType: CollectibleType,
76
+ ): boolean | undefined => {
77
+ if (ROLL_COLLECTIBLE_TYPES.has(collectibleType)) {
78
+ markRollFrame();
79
+ }
80
+
81
+ return undefined;
82
+ };
83
+
84
+ /**
85
+ * Soul of Isaac causes items to flip. We assume that the player deliberately wants to roll a
86
+ * quest item, so we delete all tracked items in the current room.
87
+ */
55
88
  // ModCallback.POST_USE_CARD (5)
56
89
  // Card.SOUL_ISAAC (81)
57
- private useCardSoulOfIsaac = () => {
58
- // Soul of Isaac causes items to flip. Delete all tracked items (assuming that the player
59
- // deliberately wants to roll a quest item).
60
- v.room.trackedCollectibles.clear();
90
+ private postUseCardSoulOfIsaac = () => {
91
+ const collectibles = getCollectibles();
92
+ for (const collectible of collectibles) {
93
+ const pickupIndex = this.pickupIndexCreation.getPickupIndex(collectible);
94
+ v.run.trackedCollectibles.delete(pickupIndex);
95
+ }
61
96
  };
62
97
 
63
- // ModCallback.POST_PICKUP_UPDATE (35)
64
- // PickupVariant.COLLECTIBLE (100)
65
- private postPickupUpdateCollectible = (pickup: EntityPickup) => {
66
- const collectible = pickup as EntityPickupCollectible;
67
-
68
- this.checkCollectibleRotated(collectible);
98
+ // ModCallbackCustom.POST_DICE_ROOM_ACTIVATED
99
+ private postDiceRoomActivated = (
100
+ _player: EntityPlayer,
101
+ diceFloorSubType: DiceFloorSubType,
102
+ ) => {
103
+ if (ROLL_FLOOR_DICE_FLOOR_SUB_TYPES.has(diceFloorSubType)) {
104
+ v.run.trackedCollectibles.clear();
105
+ }
69
106
  };
70
107
 
71
- private checkCollectibleRotated(collectible: EntityPickupCollectible) {
72
- // Ignore empty pedestals (i.e. items that have already been taken by the player).
73
- if (collectible.SubType === CollectibleType.NULL) {
108
+ // ModCallbackCustom.POST_PICKUP_CHANGED
109
+ private postPickupChanged = (
110
+ pickup: EntityPickup,
111
+ oldVariant: PickupVariant,
112
+ _oldSubType: int,
113
+ newVariant: PickupVariant,
114
+ newSubType: int,
115
+ ) => {
116
+ // We only care about collectibles rotating.
117
+ if (
118
+ oldVariant !== PickupVariant.COLLECTIBLE ||
119
+ newVariant !== PickupVariant.COLLECTIBLE
120
+ ) {
74
121
  return;
75
122
  }
76
123
 
77
- const index = getMapIndex(collectible);
78
- const trackedCollectibleType = v.room.trackedCollectibles.get(index);
79
- if (
80
- trackedCollectibleType !== undefined &&
81
- collectible.SubType !== trackedCollectibleType
82
- ) {
83
- // This item has switched, so restore it back to the way it was.
84
- setCollectibleSubType(collectible, trackedCollectibleType);
124
+ // Ignore empty pedestals (i.e. collectibles that have already been taken by the player).
125
+ if (asCollectibleType(newSubType) === CollectibleType.NULL) {
126
+ return;
85
127
  }
86
- }
128
+
129
+ const pickupIndex = this.pickupIndexCreation.getPickupIndex(pickup);
130
+ const trackedCollectibleType = v.run.trackedCollectibles.get(pickupIndex);
131
+ if (trackedCollectibleType === undefined) {
132
+ return;
133
+ }
134
+
135
+ const gameFrameCount = game.GetFrameCount();
136
+ if (gameFrameCount === v.run.rollGameFrame) {
137
+ v.run.trackedCollectibles.delete(pickupIndex);
138
+ return;
139
+ }
140
+
141
+ if (trackedCollectibleType !== asCollectibleType(newSubType)) {
142
+ // This collectible has rotated, so restore it back to the way it was.
143
+ setCollectibleSubType(pickup, trackedCollectibleType);
144
+ }
145
+ };
87
146
 
88
147
  /**
89
148
  * Helper function to prevent a collectible from being affected by Tainted Isaac's rotation
@@ -109,17 +168,17 @@ export class PreventCollectibleRotation extends Feature {
109
168
  );
110
169
  }
111
170
 
112
- const index = getMapIndex(collectible);
113
- v.room.trackedCollectibles.set(index, collectibleType);
171
+ const pickupIndex = this.pickupIndexCreation.getPickupIndex(collectible);
172
+ v.run.trackedCollectibles.set(pickupIndex, collectibleType);
114
173
 
115
174
  // The item might have already shifted on the first frame that it spawns, so change it back if
116
175
  // necessary.
117
- this.checkCollectibleRotated(collectible);
176
+ if (collectible.SubType !== collectibleType) {
177
+ setCollectibleSubType(collectible, collectibleType);
178
+ }
118
179
  }
119
180
  }
120
181
 
121
- function getMapIndex(collectible: EntityPickup) {
122
- const room = game.GetRoom();
123
- const gridIndex = room.GetGridIndex(collectible.Position);
124
- return `${gridIndex},${collectible.InitSeed}`;
182
+ function markRollFrame() {
183
+ v.run.rollGameFrame = game.GetFrameCount();
125
184
  }
@@ -244,25 +244,6 @@ export enum ModCallbackCustom {
244
244
  */
245
245
  POST_COLLECTIBLE_EMPTY,
246
246
 
247
- /**
248
- * Fires from the `POST_PICKUP_INIT` callback on the first time that a player has seen the
249
- * respective collectible on the run. For more details on how this is calculated, see the
250
- * documentation for the `getCollectibleIndex` helper function.
251
- *
252
- * This callback is useful because collectibles will despawn upon leaving the room and respawn
253
- * upon re-entering the room. Additionally, when playing as Tainted Isaac, the `POST_PICKUP_INIT`
254
- * callback will fire every time the item shifts.
255
- *
256
- * When registering the callback with the `ModUpgraded.AddCallbackCustom` method:
257
- * - You can provide an optional third argument that will make the callback only fire if it
258
- * matches the `CollectibleType` provided.
259
- *
260
- * ```ts
261
- * function postCollectibleInitLate(collectible: EntityPickupCollectible): void {}
262
- * ```
263
- */
264
- POST_COLLECTIBLE_INIT_FIRST,
265
-
266
247
  /**
267
248
  * Fires from the `POST_PLAYER_RENDER` callback on the first frame that the "TeleportUp" animation
268
249
  * begins playing after a player triggers a Cursed Eye teleport or a Cursed Skull teleport. (Both
package/src/features.ts CHANGED
@@ -141,7 +141,6 @@ export function getFeatures(
141
141
  const moddedElementDetection = new ModdedElementDetection();
142
142
  const ponyDetection = new PonyDetection();
143
143
  const pressInput = new PressInput();
144
- const preventCollectibleRotation = new PreventCollectibleRotation();
145
144
  const roomClearFrame = new RoomClearFrame();
146
145
  const roomHistory = new RoomHistory();
147
146
  const runNextRoom = new RunNextRoom();
@@ -149,15 +148,18 @@ export function getFeatures(
149
148
  const stageHistory = new StageHistory();
150
149
 
151
150
  const runInNFrames = new RunInNFrames(roomHistory);
151
+ const pickupIndexCreation = new PickupIndexCreation(
152
+ roomHistory,
153
+ saveDataManager,
154
+ );
155
+ const preventCollectibleRotation = new PreventCollectibleRotation(
156
+ pickupIndexCreation,
157
+ );
152
158
 
153
159
  const customGridEntities = new CustomGridEntities(runInNFrames);
154
160
  const moddedElementSets = new ModdedElementSets(moddedElementDetection);
155
161
  const itemPoolDetection = new ItemPoolDetection(moddedElementSets);
156
162
  const pause = new Pause(disableInputs);
157
- const pickupIndexCreation = new PickupIndexCreation(
158
- roomHistory,
159
- saveDataManager,
160
- );
161
163
  const preventGridEntityRespawn = new PreventGridEntityRespawn(runInNFrames);
162
164
  const spawnCollectible = new SpawnCollectible(preventCollectibleRotation);
163
165
 
@@ -11,7 +11,6 @@ import {
11
11
  PickupPrice,
12
12
  PickupVariant,
13
13
  RenderMode,
14
- RoomType,
15
14
  } from "isaac-typescript-definitions";
16
15
  import { game, itemConfig } from "../core/cachedClasses";
17
16
  import { BLIND_ITEM_PNG_PATH, DEFAULT_ITEM_POOL_TYPE } from "../core/constants";
@@ -28,11 +27,9 @@ import {
28
27
  DEFAULT_COLLECTIBLE_NAME,
29
28
  } from "../maps/collectibleTypeToNameMap";
30
29
  import { SINGLE_USE_ACTIVE_COLLECTIBLE_TYPES_SET } from "../sets/singleUseActiveCollectibleTypesSet";
31
- import { CollectibleIndex } from "../types/CollectibleIndex";
32
30
  import { getEntityID } from "./entities";
33
31
  import { hasFlag } from "./flag";
34
32
  import { isCollectible } from "./pickupVariants";
35
- import { getRoomListIndex } from "./roomData";
36
33
  import { clearSprite, spriteEquals } from "./sprites";
37
34
  import { isNumber } from "./types";
38
35
  import { iRange } from "./utils";
@@ -251,82 +248,6 @@ export function getCollectibleGfxFilename(
251
248
  return itemConfigItem.GfxFileName;
252
249
  }
253
250
 
254
- /**
255
- * Mods may have to keep track of data relating to a collectible. Finding an index for these kinds
256
- * of data structures is difficult, since collectibles are respawned every time a player re-enters a
257
- * room (like all other pickups), so the `PtrHash` will change.
258
- *
259
- * Use this function to get a unique index for a collectible to use in these data structures.
260
- *
261
- * If your mod is upgraded, then you should use the `getPickupIndex` function instead, as it is more
262
- * general purpose and less prone to error (but relies on stateful tracking of pickups as the run
263
- * progresses).
264
- *
265
- * Collectibles are a special case of pickups: they cannot be pushed around. (They actually can be
266
- * pushed, but usually will stay on the same grid index.) Thus, it is possible to generate a
267
- * somewhat reliable non-stateful index for collectibles. We use a 4-tuple of the room list index,
268
- * the grid index of the collectible in the room, the collectible's `SubType`, and the collectible's
269
- * `InitSeed`.
270
- *
271
- * Collectibles that are shifted by Tainted Isaac's mechanic will have unique collectible indexes
272
- * because the `SubType` is different. (The collectible entities share the same `InitSeed` and
273
- * `PtrHash`.)
274
- *
275
- * Collectibles that are rolled (with e.g. a D6) will have unique collectible indexes because the
276
- * `SubType` and `InitSeed` are different. If you want to track collectibles independently of any
277
- * rerolls, then you can use the `PtrHash` as an index instead. (The `PtrHash` will not persist
278
- * between rooms, however.)
279
- *
280
- * Note that:
281
- * - The grid index is a necessary part of the collectible index because Diplopia and Crooked Penny
282
- * can cause two or more collectibles with the same `SubType` and `InitSeed` to exist in the same
283
- * room.
284
- * - This index will fail in the case where the player uses Diplopia or a successful Crooked Penny
285
- * seven or more times in the same room, since that will cause two or more collectibles with the
286
- * same grid index, `SubType`, and `InitSeed` to exist. (More than seven is required in non-1x1
287
- * rooms.)
288
- * - The `SubType` is a necessary part of the collectible index because Tainted Isaac will
289
- * continuously cause collectibles to morph into new sub-types with the same `InitSeed`.
290
- * - Using a collectible's position as part of the index is problematic, since players can push a
291
- * pedestal. (Even using the grid index does not solve this problem, since it is possible in
292
- * certain cases for collectibles to be spawned at a position that is not aligned with the grid,
293
- * and the pedestal pushed to an adjacent tile, but this case should be extremely rare.)
294
- * - Mega Chests spawn two collectibles on the exact same position. However, both of them will have
295
- * a different `InitSeed`, so this is not a problem for this indexing scheme.
296
- * - The indexing scheme used is different for collectibles that are inside of a Treasure Room or
297
- * Boss Room, in order to handle the case of the player seeing the same collectible again in a
298
- * post-Ascent Treasure Room or Boss Room. A 5-tuple of stage, stage type, grid index, `SubType`,
299
- * and `InitSeed` is used in this case. (Using the room list index or the room grid index is not
300
- * suitable for this purpose, since both of these values can change in the post-Ascent rooms.)
301
- * Even though Treasure Rooms and Boss Rooms are grouped together in this scheme, there probably
302
- * will not be collectibles with the same grid index, SubType, and InitSeed.
303
- */
304
- export function getCollectibleIndex(
305
- collectible: EntityPickup,
306
- ): CollectibleIndex {
307
- if (!isCollectible(collectible)) {
308
- const entityID = getEntityID(collectible);
309
- error(
310
- `The "getCollectibleIndex" function was given a non-collectible: ${entityID}`,
311
- );
312
- }
313
-
314
- const level = game.GetLevel();
315
- const stage = level.GetStage();
316
- const stageType = level.GetStageType();
317
- const room = game.GetRoom();
318
- const roomType = room.GetType();
319
- const gridIndex = room.GetGridIndex(collectible.Position);
320
- const roomListIndex = getRoomListIndex();
321
-
322
- // Handle the special case of being in a Treasure Room or Boss Room.
323
- if (roomType === RoomType.TREASURE || roomType === RoomType.BOSS) {
324
- return `${stage},${stageType},${gridIndex},${collectible.SubType},${collectible.InitSeed}` as CollectibleIndex;
325
- }
326
-
327
- return `${roomListIndex},${gridIndex},${collectible.SubType},${collectible.InitSeed}` as CollectibleIndex;
328
- }
329
-
330
251
  /**
331
252
  * Helper function to get the initial amount of charges that a collectible has. Returns 0 if the
332
253
  * provided collectible type was not valid.
@@ -79,9 +79,9 @@ export function getPlayerFromIndex(
79
79
  * (1). This works even if the player does not have any Sad Onions.
80
80
  *
81
81
  * Note that by default, this returns the same index for both The Forgotten and The Soul. (Even
82
- * though they are technically different characters, they share the same inventory and InitSeed.) If
83
- * this is not desired, pass true for the `differentiateForgottenAndSoul` argument, and the RNG of
84
- * Spoon Bender (3) will be used for The Soul.
82
+ * though they are technically different characters, they share the same inventory and `InitSeed`.)
83
+ * If this is not desired, pass true for the `differentiateForgottenAndSoul` argument, and the RNG
84
+ * of Spoon Bender (3) will be used for The Soul.
85
85
  *
86
86
  * Also note that this index does not work in the `POST_PLAYER_INIT` function for players 2 through
87
87
  * 4. With that said, in almost all cases, you should be lazy-initializing your data structures in
@@ -176,6 +176,8 @@ export function repeat(n: int, func: (i: int) => void): void {
176
176
  * useful as a means to prevent unused variables.)
177
177
  *
178
178
  * This function does not actually do anything. (It is an "empty" function.)
179
+ *
180
+ * @allowEmptyVariadic
179
181
  */
180
182
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
181
183
  export function todo(...args: unknown[]): void {}
package/src/index.ts CHANGED
@@ -151,7 +151,6 @@ export * from "./types/AnyClass";
151
151
  export * from "./types/AnyEntity";
152
152
  export * from "./types/AnyFunction";
153
153
  export * from "./types/AnyGridEntity";
154
- export * from "./types/CollectibleIndex";
155
154
  export * from "./types/ConversionHeartSubType";
156
155
  export * from "./types/Decrement";
157
156
  export * from "./types/EntityID";
@@ -145,11 +145,6 @@ export interface AddCallbackParametersCustom {
145
145
  collectibleType?: CollectibleType,
146
146
  ];
147
147
 
148
- [ModCallbackCustom.POST_COLLECTIBLE_INIT_FIRST]: [
149
- callback: (collectible: EntityPickupCollectible) => void,
150
- collectibleType?: CollectibleType,
151
- ];
152
-
153
148
  [ModCallbackCustom.POST_CURSED_TELEPORT]: [
154
149
  callback: (player: EntityPlayer) => void,
155
150
  playerVariant?: PlayerVariant,
package/src/shouldFire.ts CHANGED
@@ -84,19 +84,6 @@ export function shouldFireBoolean(
84
84
  return optionalArg === undefined || optionalArg === fireArg;
85
85
  }
86
86
 
87
- export function shouldFireCollectible(
88
- fireArgs: [collectible: EntityPickupCollectible],
89
- optionalArgs: [collectibleType?: CollectibleType],
90
- ): boolean {
91
- const [collectible] = fireArgs;
92
- const [callbackCollectibleType] = optionalArgs;
93
-
94
- return (
95
- callbackCollectibleType === undefined ||
96
- callbackCollectibleType === collectible.SubType
97
- );
98
- }
99
-
100
87
  export function shouldFireCollectibleType(
101
88
  fireArgs: [player: EntityPlayer, collectibleType: CollectibleType],
102
89
  optionalArgs: [collectibleType?: CollectibleType],
@@ -1,15 +0,0 @@
1
- import { ModCallbackCustom } from "../../enums/ModCallbackCustom";
2
- import { shouldFireCollectible } from "../../shouldFire";
3
- import { CollectibleIndex } from "../../types/CollectibleIndex";
4
- import { CustomCallback } from "../private/CustomCallback";
5
- export declare class PostCollectibleInitFirst extends CustomCallback<ModCallbackCustom.POST_COLLECTIBLE_INIT_FIRST> {
6
- v: {
7
- run: {
8
- seenCollectibles: Set<CollectibleIndex>;
9
- };
10
- };
11
- constructor();
12
- protected shouldFire: typeof shouldFireCollectible;
13
- private postPickupInitCollectible;
14
- }
15
- //# sourceMappingURL=PostCollectibleInitFirst.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PostCollectibleInitFirst.d.ts","sourceRoot":"","sources":["../../../../src/classes/callbacks/PostCollectibleInitFirst.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAQ3D,qBAAa,wBAAyB,SAAQ,cAAc,CAAC,iBAAiB,CAAC,2BAA2B,CAAC;IACzF,CAAC;;;;MAAK;;IAetB,UAAmB,UAAU,+BAAyB;IAItD,OAAO,CAAC,yBAAyB,CAS/B;CACH"}
@@ -1,36 +0,0 @@
1
- local ____lualib = require("lualib_bundle")
2
- local Set = ____lualib.Set
3
- local __TS__New = ____lualib.__TS__New
4
- local __TS__Class = ____lualib.__TS__Class
5
- local __TS__ClassExtends = ____lualib.__TS__ClassExtends
6
- local ____exports = {}
7
- local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
8
- local ModCallback = ____isaac_2Dtypescript_2Ddefinitions.ModCallback
9
- local PickupVariant = ____isaac_2Dtypescript_2Ddefinitions.PickupVariant
10
- local ____collectibles = require("src.functions.collectibles")
11
- local getCollectibleIndex = ____collectibles.getCollectibleIndex
12
- local ____shouldFire = require("src.shouldFire")
13
- local shouldFireCollectible = ____shouldFire.shouldFireCollectible
14
- local ____CustomCallback = require("src.classes.private.CustomCallback")
15
- local CustomCallback = ____CustomCallback.CustomCallback
16
- local v = {run = {seenCollectibles = __TS__New(Set)}}
17
- ____exports.PostCollectibleInitFirst = __TS__Class()
18
- local PostCollectibleInitFirst = ____exports.PostCollectibleInitFirst
19
- PostCollectibleInitFirst.name = "PostCollectibleInitFirst"
20
- __TS__ClassExtends(PostCollectibleInitFirst, CustomCallback)
21
- function PostCollectibleInitFirst.prototype.____constructor(self)
22
- CustomCallback.prototype.____constructor(self)
23
- self.v = v
24
- self.shouldFire = shouldFireCollectible
25
- self.postPickupInitCollectible = function(____, pickup)
26
- local collectible = pickup
27
- local collectibleIndex = getCollectibleIndex(nil, collectible)
28
- if v.run.seenCollectibles:has(collectibleIndex) then
29
- return
30
- end
31
- v.run.seenCollectibles:add(collectibleIndex)
32
- self:fire(collectible)
33
- end
34
- self.callbacksUsed = {{ModCallback.POST_PICKUP_INIT, self.postPickupInitCollectible, {PickupVariant.COLLECTIBLE}}}
35
- end
36
- return ____exports
@@ -1,18 +0,0 @@
1
- /**
2
- * `CollectibleIndex` is a specific type of string that represents a unique identifier for a
3
- * collectible. Mods can signify that data structures handle collectibles by using this type.
4
- *
5
- * For more information, see the documentation for the `getCollectibleIndex` function.
6
- *
7
- * For example:
8
- *
9
- * ```ts
10
- * const collectiblesNameMap = new Map<CollectibleIndex, string>();
11
- * ```
12
- *
13
- * This type is branded for extra type safety.
14
- */
15
- export type CollectibleIndex = string & {
16
- readonly __collectibleIndexBrand: symbol;
17
- };
18
- //# sourceMappingURL=CollectibleIndex.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CollectibleIndex.d.ts","sourceRoot":"","sources":["../../../src/types/CollectibleIndex.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG;IACtC,QAAQ,CAAC,uBAAuB,EAAE,MAAM,CAAC;CAC1C,CAAC"}
@@ -1,2 +0,0 @@
1
- local ____exports = {}
2
- return ____exports
@@ -1,44 +0,0 @@
1
- import { ModCallback, PickupVariant } from "isaac-typescript-definitions";
2
- import { ModCallbackCustom } from "../../enums/ModCallbackCustom";
3
- import { getCollectibleIndex } from "../../functions/collectibles";
4
- import { shouldFireCollectible } from "../../shouldFire";
5
- import { CollectibleIndex } from "../../types/CollectibleIndex";
6
- import { CustomCallback } from "../private/CustomCallback";
7
-
8
- const v = {
9
- run: {
10
- seenCollectibles: new Set<CollectibleIndex>(),
11
- },
12
- };
13
-
14
- export class PostCollectibleInitFirst extends CustomCallback<ModCallbackCustom.POST_COLLECTIBLE_INIT_FIRST> {
15
- public override v = v;
16
-
17
- constructor() {
18
- super();
19
-
20
- this.callbacksUsed = [
21
- // 34
22
- [
23
- ModCallback.POST_PICKUP_INIT,
24
- this.postPickupInitCollectible,
25
- [PickupVariant.COLLECTIBLE],
26
- ],
27
- ];
28
- }
29
-
30
- protected override shouldFire = shouldFireCollectible;
31
-
32
- // ModCallback.POST_PICKUP_INIT (34)
33
- // PickupVariant.COLLECTIBLE (100)
34
- private postPickupInitCollectible = (pickup: EntityPickup): void => {
35
- const collectible = pickup as EntityPickupCollectible;
36
- const collectibleIndex = getCollectibleIndex(collectible);
37
- if (v.run.seenCollectibles.has(collectibleIndex)) {
38
- return;
39
- }
40
-
41
- v.run.seenCollectibles.add(collectibleIndex);
42
- this.fire(collectible);
43
- };
44
- }
@@ -1,17 +0,0 @@
1
- /**
2
- * `CollectibleIndex` is a specific type of string that represents a unique identifier for a
3
- * collectible. Mods can signify that data structures handle collectibles by using this type.
4
- *
5
- * For more information, see the documentation for the `getCollectibleIndex` function.
6
- *
7
- * For example:
8
- *
9
- * ```ts
10
- * const collectiblesNameMap = new Map<CollectibleIndex, string>();
11
- * ```
12
- *
13
- * This type is branded for extra type safety.
14
- */
15
- export type CollectibleIndex = string & {
16
- readonly __collectibleIndexBrand: symbol;
17
- };