isaacscript-common 8.4.3 → 8.4.6

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 (39) hide show
  1. package/dist/callbacks/postCursedTeleport.lua +4 -4
  2. package/dist/callbacks/postPlayerFatalDamage.lua +7 -7
  3. package/dist/callbacks/postSacrifice.lua +2 -2
  4. package/dist/callbacks/postTrinketBreak.lua +2 -2
  5. package/dist/callbacks/subscriptions/postPlayerFatalDamage.d.ts +2 -2
  6. package/dist/callbacks/subscriptions/postPlayerFatalDamage.d.ts.map +1 -1
  7. package/dist/callbacks/subscriptions/postPlayerFatalDamage.lua +4 -4
  8. package/dist/features/customGridEntity.d.ts.map +1 -1
  9. package/dist/features/customGridEntity.lua +3 -36
  10. package/dist/features/extraConsoleCommands/init.d.ts.map +1 -1
  11. package/dist/features/extraConsoleCommands/init.lua +1 -1
  12. package/dist/functions/collectibleSet.d.ts +0 -6
  13. package/dist/functions/collectibleSet.d.ts.map +1 -1
  14. package/dist/functions/collectibleSet.lua +35 -46
  15. package/dist/functions/collectibles.d.ts +2 -1
  16. package/dist/functions/collectibles.d.ts.map +1 -1
  17. package/dist/functions/collectibles.lua +2 -1
  18. package/dist/functions/flag.d.ts +1 -1
  19. package/dist/functions/flag.lua +1 -1
  20. package/dist/functions/revive.d.ts +1 -1
  21. package/dist/functions/revive.d.ts.map +1 -1
  22. package/dist/functions/revive.lua +3 -3
  23. package/dist/functions/trinketSet.d.ts +0 -6
  24. package/dist/functions/trinketSet.d.ts.map +1 -1
  25. package/dist/functions/trinketSet.lua +35 -46
  26. package/dist/index.d.ts +5 -16
  27. package/package.json +2 -2
  28. package/src/callbacks/postCursedTeleport.ts +7 -7
  29. package/src/callbacks/postPlayerFatalDamage.ts +9 -16
  30. package/src/callbacks/postSacrifice.ts +5 -5
  31. package/src/callbacks/postTrinketBreak.ts +5 -5
  32. package/src/callbacks/subscriptions/postPlayerFatalDamage.ts +9 -9
  33. package/src/features/customGridEntity.ts +0 -55
  34. package/src/features/extraConsoleCommands/init.ts +8 -1
  35. package/src/functions/collectibleSet.ts +38 -45
  36. package/src/functions/collectibles.ts +2 -1
  37. package/src/functions/flag.ts +1 -1
  38. package/src/functions/revive.ts +4 -4
  39. package/src/functions/trinketSet.ts +38 -45
@@ -1,55 +1,50 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local Set = ____lualib.Set
3
3
  local __TS__New = ____lualib.__TS__New
4
- local __TS__ArraySort = ____lualib.__TS__ArraySort
5
4
  local ____exports = {}
6
5
  local ____cachedClasses = require("core.cachedClasses")
7
6
  local itemConfig = ____cachedClasses.itemConfig
8
- local ____constantsFirstLast = require("core.constantsFirstLast")
9
- local FIRST_TRINKET_TYPE = ____constantsFirstLast.FIRST_TRINKET_TYPE
10
- local LAST_VANILLA_TRINKET_TYPE = ____constantsFirstLast.LAST_VANILLA_TRINKET_TYPE
11
7
  local ____firstLast = require("features.firstLast")
12
- local getLastTrinketType = ____firstLast.getLastTrinketType
13
- local ____utils = require("functions.utils")
14
- local irange = ____utils.irange
8
+ local getModdedTrinketTypes = ____firstLast.getModdedTrinketTypes
9
+ local ____trinkets = require("functions.trinkets")
10
+ local getVanillaTrinketTypes = ____trinkets.getVanillaTrinketTypes
15
11
  local ALL_TRINKETS_ARRAY = {}
16
- local VANILLA_TRINKETS_ARRAY = {}
17
- local MODDED_TRINKETS_ARRAY = {}
18
12
  local ALL_TRINKETS_SET = __TS__New(Set)
13
+ local VANILLA_TRINKETS_ARRAY = {}
19
14
  local VANILLA_TRINKETS_SET = __TS__New(Set)
15
+ local MODDED_TRINKETS_ARRAY = {}
20
16
  local MODDED_TRINKETS_SET = __TS__New(Set)
21
- local function lazyInitTrinketArraysAndSets(self)
22
- if #ALL_TRINKETS_ARRAY ~= 0 then
17
+ local function lazyInitVanillaTrinkets(self)
18
+ if #VANILLA_TRINKETS_ARRAY > 0 then
23
19
  return
24
20
  end
25
- local lastTrinketType = getLastTrinketType(nil)
26
- local trinketTypeRange = irange(nil, FIRST_TRINKET_TYPE, lastTrinketType)
27
- for ____, trinketType in ipairs(trinketTypeRange) do
28
- do
29
- local itemConfigItem = itemConfig:GetTrinket(trinketType)
30
- if itemConfigItem == nil then
31
- goto __continue4
32
- end
33
- ALL_TRINKETS_ARRAY[#ALL_TRINKETS_ARRAY + 1] = trinketType
34
- if trinketType <= LAST_VANILLA_TRINKET_TYPE then
35
- VANILLA_TRINKETS_ARRAY[#VANILLA_TRINKETS_ARRAY + 1] = trinketType
36
- else
37
- MODDED_TRINKETS_ARRAY[#MODDED_TRINKETS_ARRAY + 1] = trinketType
38
- end
21
+ local vanillaTrinketTypes = getVanillaTrinketTypes(nil)
22
+ for ____, trinketType in ipairs(vanillaTrinketTypes) do
23
+ local itemConfigItem = itemConfig:GetTrinket(trinketType)
24
+ if itemConfigItem ~= nil then
25
+ VANILLA_TRINKETS_ARRAY[#VANILLA_TRINKETS_ARRAY + 1] = trinketType
26
+ VANILLA_TRINKETS_SET:add(trinketType)
39
27
  end
40
- ::__continue4::
41
28
  end
42
- __TS__ArraySort(ALL_TRINKETS_ARRAY)
43
- for ____, trinketType in ipairs(ALL_TRINKETS_ARRAY) do
44
- ALL_TRINKETS_SET:add(trinketType)
29
+ end
30
+ local function lazyInitModdedTrinkets(self)
31
+ if #MODDED_TRINKETS_ARRAY > 0 then
32
+ return
45
33
  end
46
- __TS__ArraySort(VANILLA_TRINKETS_ARRAY)
34
+ lazyInitVanillaTrinkets(nil)
47
35
  for ____, trinketType in ipairs(VANILLA_TRINKETS_ARRAY) do
48
- VANILLA_TRINKETS_SET:add(trinketType)
36
+ ALL_TRINKETS_ARRAY[#ALL_TRINKETS_ARRAY + 1] = trinketType
37
+ ALL_TRINKETS_SET:add(trinketType)
49
38
  end
50
- __TS__ArraySort(MODDED_TRINKETS_ARRAY)
51
- for ____, trinketType in ipairs(MODDED_TRINKETS_ARRAY) do
52
- MODDED_TRINKETS_SET:add(trinketType)
39
+ local moddedTrinketTypes = getModdedTrinketTypes(nil)
40
+ for ____, trinketType in ipairs(moddedTrinketTypes) do
41
+ local itemConfigItem = itemConfig:GetTrinket(trinketType)
42
+ if itemConfigItem ~= nil then
43
+ MODDED_TRINKETS_ARRAY[#MODDED_TRINKETS_ARRAY + 1] = trinketType
44
+ MODDED_TRINKETS_SET:add(trinketType)
45
+ ALL_TRINKETS_ARRAY[#ALL_TRINKETS_ARRAY + 1] = trinketType
46
+ ALL_TRINKETS_SET:add(trinketType)
47
+ end
53
48
  end
54
49
  end
55
50
  --- Returns an array containing every valid trinket type in the game, including modded trinkets.
@@ -60,7 +55,7 @@ end
60
55
  -- This function can only be called if at least one callback has been executed. This is because not
61
56
  -- all trinkets will necessarily be present when a mod first loads (due to mod load order).
62
57
  function ____exports.getModdedTrinketArray(self)
63
- lazyInitTrinketArraysAndSets(nil)
58
+ lazyInitModdedTrinkets(nil)
64
59
  return MODDED_TRINKETS_ARRAY
65
60
  end
66
61
  --- Returns a set containing every valid trinket type in the game, including modded trinkets.
@@ -71,7 +66,7 @@ end
71
66
  -- This function can only be called if at least one callback has been executed. This is because not
72
67
  -- all trinkets will necessarily be present when a mod first loads (due to mod load order).
73
68
  function ____exports.getModdedTrinketSet(self)
74
- lazyInitTrinketArraysAndSets(nil)
69
+ lazyInitModdedTrinkets(nil)
75
70
  return MODDED_TRINKETS_SET
76
71
  end
77
72
  --- Returns an array containing every modded trinket type in the game.
@@ -82,7 +77,7 @@ end
82
77
  -- This function can only be called if at least one callback has been executed. This is because not
83
78
  -- all trinkets will necessarily be present when a mod first loads (due to mod load order).
84
79
  function ____exports.getTrinketArray(self)
85
- lazyInitTrinketArraysAndSets(nil)
80
+ lazyInitModdedTrinkets(nil)
86
81
  return ALL_TRINKETS_ARRAY
87
82
  end
88
83
  --- Returns a set containing every modded trinket type in the game.
@@ -93,29 +88,23 @@ end
93
88
  -- This function can only be called if at least one callback has been executed. This is because not
94
89
  -- all trinkets will necessarily be present when a mod first loads (due to mod load order).
95
90
  function ____exports.getTrinketSet(self)
96
- lazyInitTrinketArraysAndSets(nil)
91
+ lazyInitModdedTrinkets(nil)
97
92
  return ALL_TRINKETS_SET
98
93
  end
99
94
  --- Returns an array containing every valid vanilla trinket type in the game.
100
95
  --
101
96
  -- Use this if you need to iterate over the trinkets in order. If you need to do O(1) lookups, then
102
97
  -- use the `getVanillaTrinketSet` helper function instead.
103
- --
104
- -- This function can only be called if at least one callback has been executed. This is because not
105
- -- all trinkets will necessarily be present when a mod first loads (due to mod load order).
106
98
  function ____exports.getVanillaTrinketArray(self)
107
- lazyInitTrinketArraysAndSets(nil)
99
+ lazyInitVanillaTrinkets(nil)
108
100
  return VANILLA_TRINKETS_ARRAY
109
101
  end
110
102
  --- Returns a set containing every valid vanilla trinket type in the game.
111
103
  --
112
104
  -- Use this if you need to do O(1) lookups. If you need to iterate over the trinkets in order, then
113
105
  -- use the `getVanillaTrinketArray` helper function instead.
114
- --
115
- -- This function can only be called if at least one callback has been executed. This is because not
116
- -- all trinkets will necessarily be present when a mod first loads (due to mod load order).
117
106
  function ____exports.getVanillaTrinketSet(self)
118
- lazyInitTrinketArraysAndSets(nil)
107
+ lazyInitVanillaTrinkets(nil)
119
108
  return VANILLA_TRINKETS_SET
120
109
  end
121
110
  return ____exports
package/dist/index.d.ts CHANGED
@@ -5098,9 +5098,6 @@ export declare function getVanillaCards(): Card[];
5098
5098
  *
5099
5099
  * Use this if you need to iterate over the collectibles in order. If you need to do O(1) lookups,
5100
5100
  * then use the `getVanillaCollectibleSet` helper function instead.
5101
- *
5102
- * This function can only be called if at least one callback has been executed. This is because not
5103
- * all collectibles will necessarily be present when a mod first loads (due to mod load order).
5104
5101
  */
5105
5102
  export declare function getVanillaCollectibleArray(): readonly CollectibleType[];
5106
5103
 
@@ -5109,9 +5106,6 @@ export declare function getVanillaCollectibleArray(): readonly CollectibleType[]
5109
5106
  *
5110
5107
  * Use this if you need to do O(1) lookups. If you need to iterate over the collectibles in order,
5111
5108
  * then use the `getVanillaCollectibleArray` helper function instead.
5112
- *
5113
- * This function can only be called if at least one callback has been executed. This is because not
5114
- * all collectibles will necessarily be present when a mod first loads (due to mod load order).
5115
5109
  */
5116
5110
  export declare function getVanillaCollectibleSet(): ReadonlySet<CollectibleType>;
5117
5111
 
@@ -5121,7 +5115,8 @@ export declare function getVanillaCollectibleSet(): ReadonlySet<CollectibleType>
5121
5115
  * collectible types.
5122
5116
  *
5123
5117
  * This function is only useful when building collectible type objects. For most purposes, you
5124
- * should use the `getVanillaCollectibleSet` helper function instead.
5118
+ * should use the `getVanillaCollectibleArray` or `getVanillaCollectibleSet` helper functions
5119
+ * instead.
5125
5120
  */
5126
5121
  export declare function getVanillaCollectibleTypeRange(): CollectibleType[];
5127
5122
 
@@ -5133,9 +5128,6 @@ export declare function getVanillaPillEffects(): PillEffect[];
5133
5128
  *
5134
5129
  * Use this if you need to iterate over the trinkets in order. If you need to do O(1) lookups, then
5135
5130
  * use the `getVanillaTrinketSet` helper function instead.
5136
- *
5137
- * This function can only be called if at least one callback has been executed. This is because not
5138
- * all trinkets will necessarily be present when a mod first loads (due to mod load order).
5139
5131
  */
5140
5132
  export declare function getVanillaTrinketArray(): readonly TrinketType[];
5141
5133
 
@@ -5144,9 +5136,6 @@ export declare function getVanillaTrinketArray(): readonly TrinketType[];
5144
5136
  *
5145
5137
  * Use this if you need to do O(1) lookups. If you need to iterate over the trinkets in order, then
5146
5138
  * use the `getVanillaTrinketArray` helper function instead.
5147
- *
5148
- * This function can only be called if at least one callback has been executed. This is because not
5149
- * all trinkets will necessarily be present when a mod first loads (due to mod load order).
5150
5139
  */
5151
5140
  export declare function getVanillaTrinketSet(): ReadonlySet<TrinketType>;
5152
5141
 
@@ -5673,7 +5662,7 @@ export declare function isDamageFromPlayer(damageSource: Entity): boolean;
5673
5662
  * Uses the player's current health and other miscellaneous things to determine if incoming damage
5674
5663
  * will be fatal.
5675
5664
  */
5676
- export declare function isDamageToPlayerFatal(player: EntityPlayer, damageAmount: int, damageSource: EntityRef, lastDamageGameFrame: int | undefined): boolean;
5665
+ export declare function isDamageToPlayerFatal(player: EntityPlayer, amount: int, source: EntityRef, lastDamageGameFrame: int | undefined): boolean;
5677
5666
 
5678
5667
  /**
5679
5668
  * Helper function to check if the given room grid index is a dead end. Specifically, this is
@@ -6080,7 +6069,7 @@ export declare function isSack(pickup: EntityPickup): pickup is EntityPickupSack
6080
6069
  export declare function isSecretRoomDoor(door: GridEntityDoor): boolean;
6081
6070
 
6082
6071
  /**
6083
- * Helper function to determine whether damage to a player in the EntityTakeDmg callback was
6072
+ * Helper function to determine whether damage to a player in the `ENTITY_TAKE_DMG` callback was
6084
6073
  * self-inflicted. For example, damage from a Curse Room door, a Razor, or a Blood Donation Machine
6085
6074
  * would count as self-inflicted damage.
6086
6075
  */
@@ -8716,7 +8705,7 @@ collectibleType?: CollectibleType
8716
8705
  ];
8717
8706
 
8718
8707
  declare type PostPlayerFatalDamageRegisterParameters = [
8719
- callback: (player: EntityPlayer, damageAmount: float, damageFlags: BitFlags<DamageFlag>, damageSource: EntityRef, damageCountdownFrames: int) => boolean | undefined,
8708
+ callback: (player: EntityPlayer, amount: float, damageFlags: BitFlags<DamageFlag>, source: EntityRef, countdownFrames: int) => boolean | undefined,
8720
8709
  playerVariant?: PlayerVariant,
8721
8710
  character?: PlayerType
8722
8711
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "8.4.3",
3
+ "version": "8.4.6",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -22,6 +22,6 @@
22
22
  "main": "dist/index",
23
23
  "types": "dist/index.d.ts",
24
24
  "dependencies": {
25
- "isaac-typescript-definitions": "^3.5.0"
25
+ "isaac-typescript-definitions": "^3.5.2"
26
26
  }
27
27
  }
@@ -54,26 +54,26 @@ function hasSubscriptions() {
54
54
  // ModCallback.ENTITY_TAKE_DMG (11)
55
55
  // EntityType.PLAYER (1)
56
56
  function entityTakeDmgPlayer(
57
- tookDamage: Entity,
58
- _damageAmount: float,
57
+ entity: Entity,
58
+ _amount: float,
59
59
  damageFlags: BitFlags<DamageFlag>,
60
- _damageSource: EntityRef,
61
- _damageCountdownFrames: int,
60
+ _source: EntityRef,
61
+ _countdownFrames: int,
62
62
  ): boolean | undefined {
63
63
  if (!hasSubscriptions()) {
64
64
  return undefined;
65
65
  }
66
66
 
67
67
  incrementNumSacrifices(damageFlags); // Has to be before setting the damage frame
68
- setDamageFrame(tookDamage, damageFlags);
68
+ setDamageFrame(entity, damageFlags);
69
69
 
70
70
  return undefined;
71
71
  }
72
72
 
73
- function setDamageFrame(tookDamage: Entity, damageFlags: BitFlags<DamageFlag>) {
73
+ function setDamageFrame(entity: Entity, damageFlags: BitFlags<DamageFlag>) {
74
74
  const gameFrameCount = game.GetFrameCount();
75
75
 
76
- const player = tookDamage.ToPlayer();
76
+ const player = entity.ToPlayer();
77
77
  if (player === undefined) {
78
78
  return;
79
79
  }
@@ -50,17 +50,17 @@ function hasSubscriptions() {
50
50
  // ModCallback.ENTITY_TAKE_DMG (11)
51
51
  // EntityType.PLAYER (1)
52
52
  function entityTakeDmgPlayer(
53
- tookDamage: Entity,
54
- damageAmount: float,
53
+ entity: Entity,
54
+ amount: float,
55
55
  damageFlags: BitFlags<DamageFlag>,
56
- damageSource: EntityRef,
57
- damageCountdownFrames: int,
56
+ source: EntityRef,
57
+ countdownFrames: int,
58
58
  ): boolean | undefined {
59
59
  if (!hasSubscriptions()) {
60
60
  return undefined;
61
61
  }
62
62
 
63
- const player = tookDamage.ToPlayer();
63
+ const player = entity.ToPlayer();
64
64
  if (player === undefined) {
65
65
  return undefined;
66
66
  }
@@ -83,23 +83,16 @@ function entityTakeDmgPlayer(
83
83
  return undefined;
84
84
  }
85
85
 
86
- if (
87
- !isDamageToPlayerFatal(
88
- player,
89
- damageAmount,
90
- damageSource,
91
- lastDamageGameFrame,
92
- )
93
- ) {
86
+ if (!isDamageToPlayerFatal(player, amount, source, lastDamageGameFrame)) {
94
87
  return undefined;
95
88
  }
96
89
 
97
90
  const shouldSustainDeath = postPlayerFatalDamageFire(
98
91
  player,
99
- damageAmount,
92
+ amount,
100
93
  damageFlags,
101
- damageSource,
102
- damageCountdownFrames,
94
+ source,
95
+ countdownFrames,
103
96
  );
104
97
  if (shouldSustainDeath !== undefined) {
105
98
  return shouldSustainDeath;
@@ -35,17 +35,17 @@ function hasSubscriptions() {
35
35
  // ModCallback.ENTITY_TAKE_DMG (11)
36
36
  // EntityType.PLAYER (1)
37
37
  function entityTakeDmgPlayer(
38
- tookDamage: Entity,
39
- _damageAmount: float,
38
+ entity: Entity,
39
+ _amount: float,
40
40
  damageFlags: BitFlags<DamageFlag>,
41
- _damageSource: EntityRef,
42
- _damageCountdownFrames: int,
41
+ _source: EntityRef,
42
+ _countdownFrames: int,
43
43
  ): boolean | undefined {
44
44
  if (!hasSubscriptions()) {
45
45
  return undefined;
46
46
  }
47
47
 
48
- const player = tookDamage.ToPlayer();
48
+ const player = entity.ToPlayer();
49
49
  if (player === undefined) {
50
50
  return undefined;
51
51
  }
@@ -52,17 +52,17 @@ function hasSubscriptions() {
52
52
  // ModCallback.ENTITY_TAKE_DMG (11)
53
53
  // EntityType.PLAYER (1)
54
54
  function entityTakeDmgPlayer(
55
- tookDamage: Entity,
56
- _damageAmount: float,
55
+ entity: Entity,
56
+ _amount: float,
57
57
  _damageFlags: BitFlags<DamageFlag>,
58
- _damageSource: EntityRef,
59
- _damageCountdownFrames: int,
58
+ _source: EntityRef,
59
+ _countdownFrames: int,
60
60
  ): boolean | undefined {
61
61
  if (!hasSubscriptions()) {
62
62
  return undefined;
63
63
  }
64
64
 
65
- const player = tookDamage.ToPlayer();
65
+ const player = entity.ToPlayer();
66
66
  if (player === undefined) {
67
67
  return undefined;
68
68
  }
@@ -7,10 +7,10 @@ import {
7
7
  export type PostPlayerFatalDamageRegisterParameters = [
8
8
  callback: (
9
9
  player: EntityPlayer,
10
- damageAmount: float,
10
+ amount: float,
11
11
  damageFlags: BitFlags<DamageFlag>,
12
- damageSource: EntityRef,
13
- damageCountdownFrames: int,
12
+ source: EntityRef,
13
+ countdownFrames: int,
14
14
  ) => boolean | undefined,
15
15
  playerVariant?: PlayerVariant,
16
16
  character?: PlayerType,
@@ -30,10 +30,10 @@ export function postPlayerFatalDamageRegister(
30
30
 
31
31
  export function postPlayerFatalDamageFire(
32
32
  player: EntityPlayer,
33
- damageAmount: float,
33
+ amount: float,
34
34
  damageFlags: BitFlags<DamageFlag>,
35
- damageSource: EntityRef,
36
- damageCountdownFrames: int,
35
+ source: EntityRef,
36
+ countdownFrames: int,
37
37
  ): boolean | undefined {
38
38
  const character = player.GetPlayerType();
39
39
 
@@ -50,10 +50,10 @@ export function postPlayerFatalDamageFire(
50
50
 
51
51
  const shouldSustainDeath = callback(
52
52
  player,
53
- damageAmount,
53
+ amount,
54
54
  damageFlags,
55
- damageSource,
56
- damageCountdownFrames,
55
+ source,
56
+ countdownFrames,
57
57
  );
58
58
 
59
59
  if (shouldSustainDeath !== undefined) {
@@ -1,14 +1,11 @@
1
1
  import {
2
2
  ActiveSlot,
3
3
  CollectibleType,
4
- DamageFlag,
5
- EntityType,
6
4
  GridCollisionClass,
7
5
  GridEntityType,
8
6
  ModCallback,
9
7
  UseFlag,
10
8
  } from "isaac-typescript-definitions";
11
- import { postGridEntityCustomBrokenFire } from "../callbacks/subscriptions/postGridEntityCustomBroken";
12
9
  import { DefaultMap } from "../classes/DefaultMap";
13
10
  import { ModUpgraded } from "../classes/ModUpgraded";
14
11
  import { game } from "../core/cachedClasses";
@@ -17,7 +14,6 @@ import {
17
14
  areFeaturesInitialized,
18
15
  errorIfFeaturesNotInitialized,
19
16
  } from "../featuresInitialized";
20
- import { hasFlag } from "../functions/flag";
21
17
  import {
22
18
  removeGridEntity,
23
19
  spawnGridEntityWithVariant,
@@ -49,12 +45,6 @@ const v = {
49
45
  export function customGridEntityInit(mod: ModUpgraded): void {
50
46
  saveDataManager(FEATURE_NAME, v);
51
47
 
52
- mod.AddCallback(
53
- ModCallback.ENTITY_TAKE_DMG,
54
- entityTakeDmgGenericProp,
55
- EntityType.GENERIC_PROP,
56
- ); // 11
57
-
58
48
  mod.AddCallback(
59
49
  ModCallback.PRE_USE_ITEM,
60
50
  preUseItemWeNeedToGoDeeper,
@@ -67,51 +57,6 @@ export function customGridEntityInit(mod: ModUpgraded): void {
67
57
  );
68
58
  }
69
59
 
70
- // ModCallback.ENTITY_TAKE_DMG (11)
71
- // EntityType.GENERIC_PROP (960)
72
- function entityTakeDmgGenericProp(
73
- tookDamage: Entity,
74
- _damageAmount: float,
75
- damageFlags: BitFlags<DamageFlag>,
76
- _damageSource: EntityRef,
77
- _damageCountdownFrames: int,
78
- ): boolean | undefined {
79
- const ptrHash = GetPtrHash(tookDamage);
80
- if (!v.room.genericPropPtrHashes.has(ptrHash)) {
81
- return undefined;
82
- }
83
-
84
- if (!hasFlag(damageFlags, DamageFlag.EXPLOSION)) {
85
- return false;
86
- }
87
-
88
- const room = game.GetRoom();
89
- const roomListIndex = getRoomListIndex();
90
- const roomCustomGridEntities = v.level.customGridEntities.get(roomListIndex);
91
- if (roomCustomGridEntities === undefined) {
92
- return false;
93
- }
94
-
95
- const gridIndex = room.GetGridIndex(tookDamage.Position);
96
- const data = roomCustomGridEntities.get(gridIndex);
97
- if (data === undefined) {
98
- return false;
99
- }
100
-
101
- const gridEntity = room.GetGridEntity(gridIndex);
102
- if (gridEntity === undefined) {
103
- error(
104
- `Failed to get the grid entity for a custom grid entity that broke at grid index: ${gridIndex}`,
105
- );
106
- }
107
-
108
- postGridEntityCustomBrokenFire(gridEntity, data.gridEntityTypeCustom);
109
-
110
- // Even though the custom grid entity is now broken, we do not want to remove it, as the end-user
111
- // could intend for it to persist with different graphics (or take multiple hits to be destroyed).
112
- return false;
113
- }
114
-
115
60
  // ModCallback.PRE_USE_ITEM (23)
116
61
  // CollectibleType.WE_NEED_TO_GO_DEEPER (84)
117
62
  function preUseItemWeNeedToGoDeeper(
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  CacheFlag,
3
3
  CollectibleType,
4
+ DamageFlag,
4
5
  EntityType,
5
6
  LevelCurse,
6
7
  ModCallback,
@@ -348,7 +349,13 @@ function evaluateCacheFlying(player: EntityPlayer) {
348
349
 
349
350
  // ModCallback.ENTITY_TAKE_DMG (11)
350
351
  // EntityType.PLAYER (1)
351
- function entityTakeDmgPlayer() {
352
+ function entityTakeDmgPlayer(
353
+ _entity: Entity,
354
+ _damageAmount: float,
355
+ _damageFlags: BitFlags<DamageFlag>,
356
+ _damageSource: EntityRef,
357
+ _damageCountdownFrames: int,
358
+ ) {
352
359
  if (v.run.spamBloodRights) {
353
360
  return false;
354
361
  }
@@ -1,57 +1,56 @@
1
1
  import { CollectibleType } from "isaac-typescript-definitions";
2
2
  import { itemConfig } from "../core/cachedClasses";
3
- import {
4
- FIRST_COLLECTIBLE_TYPE,
5
- LAST_VANILLA_COLLECTIBLE_TYPE,
6
- } from "../core/constantsFirstLast";
7
- import { getLastCollectibleType } from "../features/firstLast";
8
- import { irange } from "./utils";
3
+ import { getModdedCollectibleTypes } from "../features/firstLast";
4
+ import { getVanillaCollectibleTypeRange } from "./collectibles";
9
5
 
10
6
  const ALL_COLLECTIBLES_ARRAY: CollectibleType[] = [];
11
- const VANILLA_COLLECTIBLES_ARRAY: CollectibleType[] = [];
12
- const MODDED_COLLECTIBLES_ARRAY: CollectibleType[] = [];
13
-
14
7
  const ALL_COLLECTIBLES_SET = new Set<CollectibleType>();
8
+
9
+ const VANILLA_COLLECTIBLES_ARRAY: CollectibleType[] = [];
15
10
  const VANILLA_COLLECTIBLES_SET = new Set<CollectibleType>();
11
+
12
+ const MODDED_COLLECTIBLES_ARRAY: CollectibleType[] = [];
16
13
  const MODDED_COLLECTIBLES_SET = new Set<CollectibleType>();
17
14
 
18
- function lazyInitCollectibleArraysAndSets() {
19
- if (ALL_COLLECTIBLES_ARRAY.length !== 0) {
15
+ function lazyInitVanillaCollectibles() {
16
+ if (VANILLA_COLLECTIBLES_ARRAY.length > 0) {
20
17
  return;
21
18
  }
22
19
 
23
- const lastCollectibleType = getLastCollectibleType();
24
- const collectibleTypeRange = irange(
25
- FIRST_COLLECTIBLE_TYPE,
26
- lastCollectibleType,
27
- ) as CollectibleType[];
28
- for (const collectibleType of collectibleTypeRange) {
20
+ const vanillaCollectibleTypeRange = getVanillaCollectibleTypeRange();
21
+ for (const collectibleType of vanillaCollectibleTypeRange) {
22
+ // Vanilla collectible types are not contiguous, so we must check every value.
29
23
  const itemConfigItem = itemConfig.GetCollectible(collectibleType);
30
- if (itemConfigItem === undefined) {
31
- continue;
32
- }
33
-
34
- ALL_COLLECTIBLES_ARRAY.push(collectibleType);
35
- if (collectibleType <= LAST_VANILLA_COLLECTIBLE_TYPE) {
24
+ if (itemConfigItem !== undefined) {
36
25
  VANILLA_COLLECTIBLES_ARRAY.push(collectibleType);
37
- } else {
38
- MODDED_COLLECTIBLES_ARRAY.push(collectibleType);
26
+ VANILLA_COLLECTIBLES_SET.add(collectibleType);
39
27
  }
40
28
  }
29
+ }
41
30
 
42
- ALL_COLLECTIBLES_ARRAY.sort();
43
- for (const collectibleType of ALL_COLLECTIBLES_ARRAY) {
44
- ALL_COLLECTIBLES_SET.add(collectibleType);
31
+ function lazyInitModdedCollectibles() {
32
+ if (MODDED_COLLECTIBLES_ARRAY.length > 0) {
33
+ return;
45
34
  }
46
35
 
47
- VANILLA_COLLECTIBLES_ARRAY.sort();
36
+ lazyInitVanillaCollectibles();
37
+
48
38
  for (const collectibleType of VANILLA_COLLECTIBLES_ARRAY) {
49
- VANILLA_COLLECTIBLES_SET.add(collectibleType);
39
+ ALL_COLLECTIBLES_ARRAY.push(collectibleType);
40
+ ALL_COLLECTIBLES_SET.add(collectibleType);
50
41
  }
51
42
 
52
- MODDED_COLLECTIBLES_ARRAY.sort();
53
- for (const collectibleType of MODDED_COLLECTIBLES_ARRAY) {
54
- MODDED_COLLECTIBLES_SET.add(collectibleType);
43
+ const moddedCollectibleTypes = getModdedCollectibleTypes();
44
+ for (const collectibleType of moddedCollectibleTypes) {
45
+ // Modded collectible types are contiguous, but we check every value just in case.
46
+ const itemConfigItem = itemConfig.GetCollectible(collectibleType);
47
+ if (itemConfigItem !== undefined) {
48
+ MODDED_COLLECTIBLES_ARRAY.push(collectibleType);
49
+ MODDED_COLLECTIBLES_SET.add(collectibleType);
50
+
51
+ ALL_COLLECTIBLES_ARRAY.push(collectibleType);
52
+ ALL_COLLECTIBLES_SET.add(collectibleType);
53
+ }
55
54
  }
56
55
  }
57
56
 
@@ -66,7 +65,7 @@ function lazyInitCollectibleArraysAndSets() {
66
65
  * all collectibles will necessarily be present when a mod first loads (due to mod load order).
67
66
  */
68
67
  export function getCollectibleArray(): readonly CollectibleType[] {
69
- lazyInitCollectibleArraysAndSets();
68
+ lazyInitModdedCollectibles();
70
69
  return ALL_COLLECTIBLES_ARRAY;
71
70
  }
72
71
 
@@ -80,7 +79,7 @@ export function getCollectibleArray(): readonly CollectibleType[] {
80
79
  * all collectibles will necessarily be present when a mod first loads (due to mod load order).
81
80
  */
82
81
  export function getCollectibleSet(): ReadonlySet<CollectibleType> {
83
- lazyInitCollectibleArraysAndSets();
82
+ lazyInitModdedCollectibles();
84
83
  return ALL_COLLECTIBLES_SET;
85
84
  }
86
85
 
@@ -94,7 +93,7 @@ export function getCollectibleSet(): ReadonlySet<CollectibleType> {
94
93
  * all collectibles will necessarily be present when a mod first loads (due to mod load order).
95
94
  */
96
95
  export function getModdedCollectibleArray(): readonly CollectibleType[] {
97
- lazyInitCollectibleArraysAndSets();
96
+ lazyInitModdedCollectibles();
98
97
  return MODDED_COLLECTIBLES_ARRAY;
99
98
  }
100
99
 
@@ -108,7 +107,7 @@ export function getModdedCollectibleArray(): readonly CollectibleType[] {
108
107
  * all collectibles will necessarily be present when a mod first loads (due to mod load order).
109
108
  */
110
109
  export function getModdedCollectibleSet(): ReadonlySet<CollectibleType> {
111
- lazyInitCollectibleArraysAndSets();
110
+ lazyInitModdedCollectibles();
112
111
  return MODDED_COLLECTIBLES_SET;
113
112
  }
114
113
 
@@ -117,12 +116,9 @@ export function getModdedCollectibleSet(): ReadonlySet<CollectibleType> {
117
116
  *
118
117
  * Use this if you need to iterate over the collectibles in order. If you need to do O(1) lookups,
119
118
  * then use the `getVanillaCollectibleSet` helper function instead.
120
- *
121
- * This function can only be called if at least one callback has been executed. This is because not
122
- * all collectibles will necessarily be present when a mod first loads (due to mod load order).
123
119
  */
124
120
  export function getVanillaCollectibleArray(): readonly CollectibleType[] {
125
- lazyInitCollectibleArraysAndSets();
121
+ lazyInitVanillaCollectibles();
126
122
  return VANILLA_COLLECTIBLES_ARRAY;
127
123
  }
128
124
 
@@ -131,11 +127,8 @@ export function getVanillaCollectibleArray(): readonly CollectibleType[] {
131
127
  *
132
128
  * Use this if you need to do O(1) lookups. If you need to iterate over the collectibles in order,
133
129
  * then use the `getVanillaCollectibleArray` helper function instead.
134
- *
135
- * This function can only be called if at least one callback has been executed. This is because not
136
- * all collectibles will necessarily be present when a mod first loads (due to mod load order).
137
130
  */
138
131
  export function getVanillaCollectibleSet(): ReadonlySet<CollectibleType> {
139
- lazyInitCollectibleArraysAndSets();
132
+ lazyInitVanillaCollectibles();
140
133
  return VANILLA_COLLECTIBLES_SET;
141
134
  }