isaacscript-common 7.8.0 → 7.10.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/callbacks/postPlayerReorderedCallbacks.d.ts +2 -2
  2. package/dist/callbacks/postPlayerReorderedCallbacks.d.ts.map +1 -1
  3. package/dist/callbacks/postPlayerReorderedCallbacks.lua +5 -3
  4. package/dist/callbacks/reorderedCallbacks.d.ts.map +1 -1
  5. package/dist/callbacks/reorderedCallbacks.lua +5 -1
  6. package/dist/callbacks/subscriptions/postGameStartedReorderedLast.d.ts +7 -0
  7. package/dist/callbacks/subscriptions/postGameStartedReorderedLast.d.ts.map +1 -0
  8. package/dist/callbacks/subscriptions/postGameStartedReorderedLast.lua +16 -0
  9. package/dist/enums/ModCallbackCustom.d.ts +88 -73
  10. package/dist/enums/ModCallbackCustom.d.ts.map +1 -1
  11. package/dist/enums/ModCallbackCustom.lua +71 -69
  12. package/dist/features/preventChildEntities.d.ts +13 -0
  13. package/dist/features/preventChildEntities.d.ts.map +1 -0
  14. package/dist/features/preventChildEntities.lua +33 -0
  15. package/dist/functions/players.d.ts +3 -0
  16. package/dist/functions/players.d.ts.map +1 -1
  17. package/dist/functions/players.lua +3 -0
  18. package/dist/index.d.ts +1 -0
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.lua +5 -0
  21. package/dist/initFeatures.d.ts.map +1 -1
  22. package/dist/initFeatures.lua +3 -0
  23. package/dist/interfaces/private/AddCallbackParameterCustom.d.ts +2 -0
  24. package/dist/interfaces/private/AddCallbackParameterCustom.d.ts.map +1 -1
  25. package/dist/objects/callbackRegisterFunctions.d.ts.map +1 -1
  26. package/dist/objects/callbackRegisterFunctions.lua +3 -0
  27. package/package.json +1 -1
  28. package/src/callbacks/postPlayerReorderedCallbacks.ts +9 -4
  29. package/src/callbacks/reorderedCallbacks.ts +8 -0
  30. package/src/callbacks/subscriptions/postGameStartedReorderedLast.ts +21 -0
  31. package/src/enums/ModCallbackCustom.ts +20 -4
  32. package/src/features/preventChildEntities.ts +44 -0
  33. package/src/functions/players.ts +3 -0
  34. package/src/index.ts +1 -0
  35. package/src/initFeatures.ts +2 -0
  36. package/src/interfaces/private/AddCallbackParameterCustom.ts +2 -0
  37. package/src/objects/callbackRegisterFunctions.ts +3 -0
@@ -327,6 +327,18 @@ export enum ModCallbackCustom {
327
327
  */
328
328
  POST_GAME_STARTED_REORDERED,
329
329
 
330
+ /**
331
+ * Similar to the `POST_GAME_STARTED_REORDERED` callback, but fires after all of the subscribed
332
+ * callbacks have finished firing. Thus, you can use this callback to do perform things after a
333
+ * new run has started (or continued), but you can be sure that all new-run-related initialization
334
+ * has been completed.
335
+ *
336
+ * ```ts
337
+ * function postGameStartedReorderedLast(isContinued: boolean): void {}
338
+ * ```
339
+ */
340
+ POST_GAME_STARTED_REORDERED_LAST,
341
+
330
342
  /**
331
343
  * Fires from the `POST_UPDATE` callback when the Greed Mode wave increases.
332
344
  *
@@ -503,6 +515,8 @@ export enum ModCallbackCustom {
503
515
  *
504
516
  * (Leaving a room with a grid entity does not count as "removing" it.)
505
517
  *
518
+ * This will fire when a Polty/Kineti picks up a grid entity.
519
+ *
506
520
  * When registering the callback, takes an optional second argument that will make the callback
507
521
  * only fire if it matches the `GridEntityType` provided.
508
522
  *
@@ -740,8 +754,9 @@ export enum ModCallbackCustom {
740
754
  POST_NPC_STATE_CHANGED,
741
755
 
742
756
  /**
743
- * Similar to the vanilla callback of the same name, but fires after the `POST_GAME_STARTED`
744
- * callback fires (if the player is being updated on the 0th game frame of the run).
757
+ * Similar to the vanilla callback of the same name, but fires after the
758
+ * `POST_GAME_STARTED_REORDERED` callback fires (if the player is being updated on the 0th game
759
+ * frame of the run).
745
760
  *
746
761
  * This callback is useful for two reasons:
747
762
  *
@@ -1036,8 +1051,9 @@ export enum ModCallbackCustom {
1036
1051
  POST_PLAYER_RENDER_REORDERED,
1037
1052
 
1038
1053
  /**
1039
- * Similar to the vanilla callback of the same name, but fires after the `POST_GAME_STARTED`
1040
- * callback fires (if the player is being updated on the 0th game frame of the run).
1054
+ * Similar to the vanilla callback of the same name, but fires after the
1055
+ * `POST_GAME_STARTED_REORDERED` callback fires (if the player is being updated on the 0th game
1056
+ * frame of the run).
1041
1057
  *
1042
1058
  * This callback is useful for two reasons:
1043
1059
  *
@@ -0,0 +1,44 @@
1
+ import { ModCallback } from "isaac-typescript-definitions";
2
+ import { saveDataManager } from "./saveDataManager/exports";
3
+
4
+ const FEATURE_NAME = "preventChildEntities";
5
+
6
+ const v = {
7
+ room: {
8
+ preventingEntities: new Set<PtrHash>(),
9
+ },
10
+ };
11
+
12
+ export function preventChildEntitiesInit(mod: Mod): void {
13
+ saveDataManager(FEATURE_NAME, v);
14
+
15
+ mod.AddCallback(ModCallback.POST_NPC_INIT, postNPCInit); // 27
16
+ }
17
+
18
+ // ModCallback.POST_NPC_INIT (27)
19
+ function postNPCInit(npc: EntityNPC) {
20
+ const spawnerEntityMatch =
21
+ npc.SpawnerEntity !== undefined &&
22
+ v.room.preventingEntities.has(GetPtrHash(npc.SpawnerEntity));
23
+
24
+ const parentMatch =
25
+ npc.Parent !== undefined &&
26
+ v.room.preventingEntities.has(GetPtrHash(npc.Parent));
27
+
28
+ if (spawnerEntityMatch || parentMatch) {
29
+ npc.Remove();
30
+ }
31
+ }
32
+
33
+ /**
34
+ * Helper function to prevent an entity from spawning any other entities. Meant to be used on NPCs
35
+ * like Squirts. This behavior will only last for the current room.
36
+ *
37
+ * Under the hood, this function will remove any new NPCs spawned that have a `Entity.SpawnerEntity`
38
+ * or `Entity.Parent` value that matches the provided entity. (They are removed during the
39
+ * `POST_NPC_INIT` callback specifically.)
40
+ */
41
+ export function preventChildEntities(entity: Entity): void {
42
+ const ptrHash = GetPtrHash(entity);
43
+ v.room.preventingEntities.add(ptrHash);
44
+ }
@@ -1065,6 +1065,9 @@ export function useActiveItemTemp(
1065
1065
  *
1066
1066
  * Tainted Magdalene has "permanent" health and "temporary" health. When standing still and doing
1067
1067
  * nothing, all of Tainted Magdalene's temporary health will eventually go away.
1068
+ *
1069
+ * Before using this function, it is expected that you check to see if the player is Tainted
1070
+ * Magdalene first, or else it will give a nonsensical result.
1068
1071
  */
1069
1072
  export function wouldDamageTaintedMagdaleneNonTemporaryHeartContainers(
1070
1073
  player: EntityPlayer,
package/src/index.ts CHANGED
@@ -57,6 +57,7 @@ export {
57
57
  anyPlayerUsingPony,
58
58
  isPlayerUsingPony,
59
59
  } from "./features/ponyDetection";
60
+ export { preventChildEntities } from "./features/preventChildEntities";
60
61
  export { preventCollectibleRotation } from "./features/preventCollectibleRotation";
61
62
  export { registerHotkey, unregisterHotkey } from "./features/registerHotkey";
62
63
  export {
@@ -16,6 +16,7 @@ import { persistentEntitiesInit } from "./features/persistentEntities";
16
16
  import { pickupIndexInit } from "./features/pickupIndex";
17
17
  import { playerInventoryInit } from "./features/playerInventory";
18
18
  import { ponyDetectionInit } from "./features/ponyDetection";
19
+ import { preventChildEntitiesInit } from "./features/preventChildEntities";
19
20
  import { preventCollectibleRotationInit } from "./features/preventCollectibleRotation";
20
21
  import { registerHotkeyInit } from "./features/registerHotkey";
21
22
  import { roomClearFrameInit } from "./features/roomClearFrame";
@@ -53,6 +54,7 @@ function initFeaturesMinor(mod: ModUpgraded) {
53
54
  pickupIndexInit(mod);
54
55
  playerInventoryInit(mod);
55
56
  ponyDetectionInit(mod);
57
+ preventChildEntitiesInit(mod);
56
58
  preventCollectibleRotationInit(mod);
57
59
  registerHotkeyInit(mod);
58
60
  roomClearFrameInit(mod);
@@ -20,6 +20,7 @@ import { PostFirstEsauJrRegisterParameters } from "../../callbacks/subscriptions
20
20
  import { PostFirstFlipRegisterParameters } from "../../callbacks/subscriptions/postFirstFlip";
21
21
  import { PostFlipRegisterParameters } from "../../callbacks/subscriptions/postFlip";
22
22
  import { PostGameStartedReorderedRegisterParameters } from "../../callbacks/subscriptions/postGameStartedReordered";
23
+ import { PostGameStartedReorderedLastRegisterParameters } from "../../callbacks/subscriptions/postGameStartedReorderedLast";
23
24
  import { PostGreedModeWaveRegisterParameters } from "../../callbacks/subscriptions/postGreedModeWave";
24
25
  import { PostGridEntityBrokenRegisterParameters } from "../../callbacks/subscriptions/postGridEntityBroken";
25
26
  import { PostGridEntityCollisionRegisterParameters } from "../../callbacks/subscriptions/postGridEntityCollision";
@@ -114,6 +115,7 @@ export interface AddCallbackParameterCustom {
114
115
  [ModCallbackCustom.POST_FIRST_FLIP]: PostFirstFlipRegisterParameters;
115
116
  [ModCallbackCustom.POST_FLIP]: PostFlipRegisterParameters;
116
117
  [ModCallbackCustom.POST_GAME_STARTED_REORDERED]: PostGameStartedReorderedRegisterParameters;
118
+ [ModCallbackCustom.POST_GAME_STARTED_REORDERED_LAST]: PostGameStartedReorderedLastRegisterParameters;
117
119
  [ModCallbackCustom.POST_GREED_MODE_WAVE]: PostGreedModeWaveRegisterParameters;
118
120
  [ModCallbackCustom.POST_GRID_ENTITY_BROKEN]: PostGridEntityBrokenRegisterParameters;
119
121
  [ModCallbackCustom.POST_GRID_ENTITY_COLLISION]: PostGridEntityCollisionRegisterParameters;
@@ -20,6 +20,7 @@ import { postFirstEsauJrRegister } from "../callbacks/subscriptions/postFirstEsa
20
20
  import { postFirstFlipRegister } from "../callbacks/subscriptions/postFirstFlip";
21
21
  import { postFlipRegister } from "../callbacks/subscriptions/postFlip";
22
22
  import { postGameStartedReorderedRegister } from "../callbacks/subscriptions/postGameStartedReordered";
23
+ import { postGameStartedReorderedLastRegister } from "../callbacks/subscriptions/postGameStartedReorderedLast";
23
24
  import { postGreedModeWaveRegister } from "../callbacks/subscriptions/postGreedModeWave";
24
25
  import { postGridEntityBrokenRegister } from "../callbacks/subscriptions/postGridEntityBroken";
25
26
  import { postGridEntityCollisionRegister } from "../callbacks/subscriptions/postGridEntityCollision";
@@ -122,6 +123,8 @@ export const CALLBACK_REGISTER_FUNCTIONS: {
122
123
  [ModCallbackCustom.POST_FLIP]: postFlipRegister,
123
124
  [ModCallbackCustom.POST_GAME_STARTED_REORDERED]:
124
125
  postGameStartedReorderedRegister,
126
+ [ModCallbackCustom.POST_GAME_STARTED_REORDERED_LAST]:
127
+ postGameStartedReorderedLastRegister,
125
128
  [ModCallbackCustom.POST_GREED_MODE_WAVE]: postGreedModeWaveRegister,
126
129
  [ModCallbackCustom.POST_GRID_ENTITY_BROKEN]: postGridEntityBrokenRegister,
127
130
  [ModCallbackCustom.POST_GRID_ENTITY_COLLISION]: