isaacscript-common 3.3.0 → 3.4.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 (34) hide show
  1. package/callbacks/postHolyMantleRemoved.lua +2 -2
  2. package/callbacks/postPlayerCollectible.d.ts +1 -0
  3. package/callbacks/postPlayerCollectible.lua +95 -0
  4. package/callbacks/subscriptions/postPlayerCollectibleAdded.d.ts +6 -0
  5. package/callbacks/subscriptions/postPlayerCollectibleAdded.lua +34 -0
  6. package/callbacks/subscriptions/postPlayerCollectibleRemoved.d.ts +6 -0
  7. package/callbacks/subscriptions/postPlayerCollectibleRemoved.lua +34 -0
  8. package/constants.d.ts +5 -0
  9. package/constants.lua +5 -0
  10. package/enums/ModCallbackCustom.d.ts +427 -177
  11. package/enums/ModCallbackCustom.lua +36 -32
  12. package/features/playerInventory.d.ts +1 -10
  13. package/features/playerInventory.lua +23 -60
  14. package/functions/array.d.ts +3 -3
  15. package/functions/array.lua +3 -3
  16. package/functions/collectibleSet.d.ts +3 -3
  17. package/functions/collectibleSet.lua +3 -5
  18. package/functions/pills.d.ts +10 -0
  19. package/functions/pills.lua +16 -0
  20. package/functions/roomData.d.ts +5 -5
  21. package/functions/roomData.lua +7 -7
  22. package/functions/rooms.d.ts +1 -4
  23. package/functions/rooms.lua +19 -25
  24. package/functions/saveFile.lua +0 -1
  25. package/index.d.ts +1 -1
  26. package/index.lua +0 -2
  27. package/initCustomCallbacks.lua +3 -0
  28. package/interfaces/AddCallbackParameterCustom.d.ts +4 -0
  29. package/maps/PHDPillConversions.d.ts +2 -0
  30. package/maps/PHDPillConversions.lua +25 -0
  31. package/maps/falsePHDPillConversions.d.ts +2 -0
  32. package/maps/falsePHDPillConversions.lua +39 -0
  33. package/objects/callbackRegisterFunctions.lua +6 -0
  34. package/package.json +2 -2
@@ -94,68 +94,72 @@ ____exports.ModCallbackCustom.POST_PLAYER_CHANGE_HEALTH = 42
94
94
  ____exports.ModCallbackCustom[____exports.ModCallbackCustom.POST_PLAYER_CHANGE_HEALTH] = "POST_PLAYER_CHANGE_HEALTH"
95
95
  ____exports.ModCallbackCustom.POST_PLAYER_CHANGE_TYPE = 43
96
96
  ____exports.ModCallbackCustom[____exports.ModCallbackCustom.POST_PLAYER_CHANGE_TYPE] = "POST_PLAYER_CHANGE_TYPE"
97
- ____exports.ModCallbackCustom.POST_PLAYER_FATAL_DAMAGE = 44
97
+ ____exports.ModCallbackCustom.POST_PLAYER_COLLECTIBLE_ADDED = 44
98
+ ____exports.ModCallbackCustom[____exports.ModCallbackCustom.POST_PLAYER_COLLECTIBLE_ADDED] = "POST_PLAYER_COLLECTIBLE_ADDED"
99
+ ____exports.ModCallbackCustom.POST_PLAYER_COLLECTIBLE_REMOVED = 45
100
+ ____exports.ModCallbackCustom[____exports.ModCallbackCustom.POST_PLAYER_COLLECTIBLE_REMOVED] = "POST_PLAYER_COLLECTIBLE_REMOVED"
101
+ ____exports.ModCallbackCustom.POST_PLAYER_FATAL_DAMAGE = 46
98
102
  ____exports.ModCallbackCustom[____exports.ModCallbackCustom.POST_PLAYER_FATAL_DAMAGE] = "POST_PLAYER_FATAL_DAMAGE"
99
- ____exports.ModCallbackCustom.POST_PLAYER_INIT_LATE = 45
103
+ ____exports.ModCallbackCustom.POST_PLAYER_INIT_LATE = 47
100
104
  ____exports.ModCallbackCustom[____exports.ModCallbackCustom.POST_PLAYER_INIT_LATE] = "POST_PLAYER_INIT_LATE"
101
- ____exports.ModCallbackCustom.POST_PLAYER_INIT_REORDERED = 46
105
+ ____exports.ModCallbackCustom.POST_PLAYER_INIT_REORDERED = 48
102
106
  ____exports.ModCallbackCustom[____exports.ModCallbackCustom.POST_PLAYER_INIT_REORDERED] = "POST_PLAYER_INIT_REORDERED"
103
- ____exports.ModCallbackCustom.POST_PLAYER_RENDER_REORDERED = 47
107
+ ____exports.ModCallbackCustom.POST_PLAYER_RENDER_REORDERED = 49
104
108
  ____exports.ModCallbackCustom[____exports.ModCallbackCustom.POST_PLAYER_RENDER_REORDERED] = "POST_PLAYER_RENDER_REORDERED"
105
- ____exports.ModCallbackCustom.POST_PLAYER_UPDATE_REORDERED = 48
109
+ ____exports.ModCallbackCustom.POST_PLAYER_UPDATE_REORDERED = 50
106
110
  ____exports.ModCallbackCustom[____exports.ModCallbackCustom.POST_PLAYER_UPDATE_REORDERED] = "POST_PLAYER_UPDATE_REORDERED"
107
- ____exports.ModCallbackCustom.POST_POOP_RENDER = 49
111
+ ____exports.ModCallbackCustom.POST_POOP_RENDER = 51
108
112
  ____exports.ModCallbackCustom[____exports.ModCallbackCustom.POST_POOP_RENDER] = "POST_POOP_RENDER"
109
- ____exports.ModCallbackCustom.POST_POOP_UPDATE = 50
113
+ ____exports.ModCallbackCustom.POST_POOP_UPDATE = 52
110
114
  ____exports.ModCallbackCustom[____exports.ModCallbackCustom.POST_POOP_UPDATE] = "POST_POOP_UPDATE"
111
- ____exports.ModCallbackCustom.POST_PRESSURE_PLATE_RENDER = 51
115
+ ____exports.ModCallbackCustom.POST_PRESSURE_PLATE_RENDER = 53
112
116
  ____exports.ModCallbackCustom[____exports.ModCallbackCustom.POST_PRESSURE_PLATE_RENDER] = "POST_PRESSURE_PLATE_RENDER"
113
- ____exports.ModCallbackCustom.POST_PRESSURE_PLATE_UPDATE = 52
117
+ ____exports.ModCallbackCustom.POST_PRESSURE_PLATE_UPDATE = 54
114
118
  ____exports.ModCallbackCustom[____exports.ModCallbackCustom.POST_PRESSURE_PLATE_UPDATE] = "POST_PRESSURE_PLATE_UPDATE"
115
- ____exports.ModCallbackCustom.POST_PROJECTILE_INIT_LATE = 53
119
+ ____exports.ModCallbackCustom.POST_PROJECTILE_INIT_LATE = 55
116
120
  ____exports.ModCallbackCustom[____exports.ModCallbackCustom.POST_PROJECTILE_INIT_LATE] = "POST_PROJECTILE_INIT_LATE"
117
- ____exports.ModCallbackCustom.POST_PURCHASE = 54
121
+ ____exports.ModCallbackCustom.POST_PURCHASE = 56
118
122
  ____exports.ModCallbackCustom[____exports.ModCallbackCustom.POST_PURCHASE] = "POST_PURCHASE"
119
- ____exports.ModCallbackCustom.POST_ROCK_RENDER = 55
123
+ ____exports.ModCallbackCustom.POST_ROCK_RENDER = 57
120
124
  ____exports.ModCallbackCustom[____exports.ModCallbackCustom.POST_ROCK_RENDER] = "POST_ROCK_RENDER"
121
- ____exports.ModCallbackCustom.POST_ROCK_UPDATE = 56
125
+ ____exports.ModCallbackCustom.POST_ROCK_UPDATE = 58
122
126
  ____exports.ModCallbackCustom[____exports.ModCallbackCustom.POST_ROCK_UPDATE] = "POST_ROCK_UPDATE"
123
- ____exports.ModCallbackCustom.POST_ROOM_CLEAR_CHANGED = 57
127
+ ____exports.ModCallbackCustom.POST_ROOM_CLEAR_CHANGED = 59
124
128
  ____exports.ModCallbackCustom[____exports.ModCallbackCustom.POST_ROOM_CLEAR_CHANGED] = "POST_ROOM_CLEAR_CHANGED"
125
- ____exports.ModCallbackCustom.POST_SACRIFICE = 58
129
+ ____exports.ModCallbackCustom.POST_SACRIFICE = 60
126
130
  ____exports.ModCallbackCustom[____exports.ModCallbackCustom.POST_SACRIFICE] = "POST_SACRIFICE"
127
- ____exports.ModCallbackCustom.POST_SLOT_ANIMATION_CHANGED = 59
131
+ ____exports.ModCallbackCustom.POST_SLOT_ANIMATION_CHANGED = 61
128
132
  ____exports.ModCallbackCustom[____exports.ModCallbackCustom.POST_SLOT_ANIMATION_CHANGED] = "POST_SLOT_ANIMATION_CHANGED"
129
- ____exports.ModCallbackCustom.POST_SLOT_DESTROYED = 60
133
+ ____exports.ModCallbackCustom.POST_SLOT_DESTROYED = 62
130
134
  ____exports.ModCallbackCustom[____exports.ModCallbackCustom.POST_SLOT_DESTROYED] = "POST_SLOT_DESTROYED"
131
- ____exports.ModCallbackCustom.POST_SLOT_INIT = 61
135
+ ____exports.ModCallbackCustom.POST_SLOT_INIT = 63
132
136
  ____exports.ModCallbackCustom[____exports.ModCallbackCustom.POST_SLOT_INIT] = "POST_SLOT_INIT"
133
- ____exports.ModCallbackCustom.POST_SLOT_RENDER = 62
137
+ ____exports.ModCallbackCustom.POST_SLOT_RENDER = 64
134
138
  ____exports.ModCallbackCustom[____exports.ModCallbackCustom.POST_SLOT_RENDER] = "POST_SLOT_RENDER"
135
- ____exports.ModCallbackCustom.POST_SLOT_UPDATE = 63
139
+ ____exports.ModCallbackCustom.POST_SLOT_UPDATE = 65
136
140
  ____exports.ModCallbackCustom[____exports.ModCallbackCustom.POST_SLOT_UPDATE] = "POST_SLOT_UPDATE"
137
- ____exports.ModCallbackCustom.POST_SPIKES_RENDER = 64
141
+ ____exports.ModCallbackCustom.POST_SPIKES_RENDER = 66
138
142
  ____exports.ModCallbackCustom[____exports.ModCallbackCustom.POST_SPIKES_RENDER] = "POST_SPIKES_RENDER"
139
- ____exports.ModCallbackCustom.POST_SPIKES_UPDATE = 65
143
+ ____exports.ModCallbackCustom.POST_SPIKES_UPDATE = 67
140
144
  ____exports.ModCallbackCustom[____exports.ModCallbackCustom.POST_SPIKES_UPDATE] = "POST_SPIKES_UPDATE"
141
- ____exports.ModCallbackCustom.POST_TEAR_INIT_LATE = 66
145
+ ____exports.ModCallbackCustom.POST_TEAR_INIT_LATE = 68
142
146
  ____exports.ModCallbackCustom[____exports.ModCallbackCustom.POST_TEAR_INIT_LATE] = "POST_TEAR_INIT_LATE"
143
- ____exports.ModCallbackCustom.POST_TEAR_INIT_VERY_LATE = 67
147
+ ____exports.ModCallbackCustom.POST_TEAR_INIT_VERY_LATE = 69
144
148
  ____exports.ModCallbackCustom[____exports.ModCallbackCustom.POST_TEAR_INIT_VERY_LATE] = "POST_TEAR_INIT_VERY_LATE"
145
- ____exports.ModCallbackCustom.POST_TNT_RENDER = 68
149
+ ____exports.ModCallbackCustom.POST_TNT_RENDER = 70
146
150
  ____exports.ModCallbackCustom[____exports.ModCallbackCustom.POST_TNT_RENDER] = "POST_TNT_RENDER"
147
- ____exports.ModCallbackCustom.POST_TNT_UPDATE = 69
151
+ ____exports.ModCallbackCustom.POST_TNT_UPDATE = 71
148
152
  ____exports.ModCallbackCustom[____exports.ModCallbackCustom.POST_TNT_UPDATE] = "POST_TNT_UPDATE"
149
- ____exports.ModCallbackCustom.POST_TRANSFORMATION = 70
153
+ ____exports.ModCallbackCustom.POST_TRANSFORMATION = 72
150
154
  ____exports.ModCallbackCustom[____exports.ModCallbackCustom.POST_TRANSFORMATION] = "POST_TRANSFORMATION"
151
- ____exports.ModCallbackCustom.POST_TRINKET_BREAK = 71
155
+ ____exports.ModCallbackCustom.POST_TRINKET_BREAK = 73
152
156
  ____exports.ModCallbackCustom[____exports.ModCallbackCustom.POST_TRINKET_BREAK] = "POST_TRINKET_BREAK"
153
- ____exports.ModCallbackCustom.PRE_BERSERK_DEATH = 72
157
+ ____exports.ModCallbackCustom.PRE_BERSERK_DEATH = 74
154
158
  ____exports.ModCallbackCustom[____exports.ModCallbackCustom.PRE_BERSERK_DEATH] = "PRE_BERSERK_DEATH"
155
- ____exports.ModCallbackCustom.PRE_CUSTOM_REVIVE = 73
159
+ ____exports.ModCallbackCustom.PRE_CUSTOM_REVIVE = 75
156
160
  ____exports.ModCallbackCustom[____exports.ModCallbackCustom.PRE_CUSTOM_REVIVE] = "PRE_CUSTOM_REVIVE"
157
- ____exports.ModCallbackCustom.PRE_ITEM_PICKUP = 74
161
+ ____exports.ModCallbackCustom.PRE_ITEM_PICKUP = 76
158
162
  ____exports.ModCallbackCustom[____exports.ModCallbackCustom.PRE_ITEM_PICKUP] = "PRE_ITEM_PICKUP"
159
- ____exports.ModCallbackCustom.PRE_NEW_LEVEL = 75
163
+ ____exports.ModCallbackCustom.PRE_NEW_LEVEL = 77
160
164
  ____exports.ModCallbackCustom[____exports.ModCallbackCustom.PRE_NEW_LEVEL] = "PRE_NEW_LEVEL"
161
165
  return ____exports
@@ -1,4 +1,4 @@
1
- import { ActiveSlot, CollectibleType } from "isaac-typescript-definitions";
1
+ import { CollectibleType } from "isaac-typescript-definitions";
2
2
  /**
3
3
  * Helper function to get all of the collectibles that the player has gotten so far on this run, in
4
4
  * order.
@@ -12,12 +12,3 @@ import { ActiveSlot, CollectibleType } from "isaac-typescript-definitions";
12
12
  * order of the lowest `CollectibleType` to the highest.
13
13
  */
14
14
  export declare function getPlayerInventory(player: EntityPlayer, includeActiveCollectibles?: boolean): CollectibleType[];
15
- /**
16
- * Helper function to add a collectible to a player. Use this instead of the
17
- * `EntityPlayer.AddCollectible` method if you want the collectible that is added to be
18
- * automatically tracked by the player inventory tracker feature.
19
- *
20
- * You only need to use this function if you are using the inventory feature from the standard
21
- * library.
22
- */
23
- export declare function addCollectible(player: EntityPlayer, collectibleType: CollectibleType, charge?: int, firstTimePickingUp?: boolean, activeSlot?: ActiveSlot, varData?: int): void;
@@ -1,10 +1,9 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local __TS__New = ____lualib.__TS__New
3
- local Set = ____lualib.Set
4
3
  local __TS__Iterator = ____lualib.__TS__Iterator
5
4
  local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
6
5
  local ____exports = {}
7
- local newPlayerInventory, useItemD4, postGameStarted, postItemPickup, addCollectibleToInventory, v
6
+ local newPlayerInventory, resetInventory, useItemD4, postGameStarted, postCollectibleAdded, postCollectibleRemoved, v
8
7
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
9
8
  local CollectibleType = ____isaac_2Dtypescript_2Ddefinitions.CollectibleType
10
9
  local ModCallback = ____isaac_2Dtypescript_2Ddefinitions.ModCallback
@@ -21,13 +20,14 @@ local ____collectibles = require("functions.collectibles")
21
20
  local isActiveCollectible = ____collectibles.isActiveCollectible
22
21
  local ____collectibleSet = require("functions.collectibleSet")
23
22
  local getCollectibleSet = ____collectibleSet.getCollectibleSet
23
+ local ____playerDataStructures = require("functions.playerDataStructures")
24
+ local defaultMapGetPlayer = ____playerDataStructures.defaultMapGetPlayer
25
+ local mapSetPlayer = ____playerDataStructures.mapSetPlayer
24
26
  local ____playerIndex = require("functions.playerIndex")
25
27
  local getAllPlayers = ____playerIndex.getAllPlayers
26
28
  local getPlayerIndex = ____playerIndex.getPlayerIndex
27
29
  local ____utils = require("functions.utils")
28
30
  local ____repeat = ____utils["repeat"]
29
- local ____PickingUpItem = require("types.PickingUpItem")
30
- local pickingUpItemIsCollectible = ____PickingUpItem.pickingUpItemIsCollectible
31
31
  local ____exports = require("features.saveDataManager.exports")
32
32
  local saveDataManager = ____exports.saveDataManager
33
33
  function newPlayerInventory(self, player)
@@ -45,62 +45,42 @@ function newPlayerInventory(self, player)
45
45
  end
46
46
  return inventory
47
47
  end
48
- function useItemD4(self, _collectibleType, _rng, player)
49
- local playerIndex = getPlayerIndex(nil, player)
48
+ function resetInventory(self, player)
50
49
  local inventory = newPlayerInventory(nil, player)
51
- v.run.playersInventory:set(playerIndex, inventory)
50
+ mapSetPlayer(nil, v.run.playersInventory, player, inventory)
51
+ end
52
+ function useItemD4(self, _collectibleType, _rng, player)
53
+ resetInventory(nil, player)
52
54
  end
53
55
  function postGameStarted(self)
54
56
  for ____, player in ipairs(getAllPlayers(nil)) do
55
57
  local playerIndex = getPlayerIndex(nil, player)
56
58
  if not v.run.playersInventory:has(playerIndex) then
57
- local inventory = newPlayerInventory(nil, player)
58
- v.run.playersInventory:set(playerIndex, inventory)
59
+ resetInventory(nil, player)
59
60
  end
60
61
  end
61
62
  end
62
- function postItemPickup(self, player, pickingUpItem)
63
- if not pickingUpItemIsCollectible(nil, pickingUpItem) then
64
- return
65
- end
66
- addCollectibleToInventory(nil, player, pickingUpItem.subType)
67
- end
68
- function addCollectibleToInventory(self, player, collectibleType)
69
- local playerIndex = getPlayerIndex(nil, player)
70
- local inventory = v.run.playersInventory:getAndSetDefault(playerIndex, player)
63
+ function postCollectibleAdded(self, player, collectibleType)
64
+ local inventory = defaultMapGetPlayer(nil, v.run.playersInventory, player, player)
71
65
  inventory[#inventory + 1] = collectibleType
72
- if not isActiveCollectible(nil, collectibleType) then
73
- return
74
- end
75
- local activeCollectibleTypes = v.run.playersActiveCollectibleTypes:getAndSetDefault(playerIndex)
76
- activeCollectibleTypes[#activeCollectibleTypes + 1] = collectibleType
77
- local droppedActiveCollectibleTypes = __TS__ArrayFilter(
78
- activeCollectibleTypes,
79
- function(____, activeCollectibleType) return not player:HasCollectible(activeCollectibleType) end
80
- )
81
- for ____, activeCollectibleType in ipairs(droppedActiveCollectibleTypes) do
82
- arrayRemoveInPlace(nil, inventory, activeCollectibleType)
83
- arrayRemoveInPlace(nil, activeCollectibleTypes, activeCollectibleType)
84
- end
66
+ end
67
+ function postCollectibleRemoved(self, player, collectibleType)
68
+ local inventory = defaultMapGetPlayer(nil, v.run.playersInventory, player, player)
69
+ arrayRemoveInPlace(nil, inventory, collectibleType)
85
70
  end
86
71
  local FEATURE_NAME = "player inventory tracker"
87
- v = {run = {
88
- playersInventory = __TS__New(
89
- DefaultMap,
90
- function(____, player) return newPlayerInventory(nil, player) end
91
- ),
92
- playersActiveCollectibleTypes = __TS__New(
93
- DefaultMap,
94
- function() return {} end
95
- )
96
- }}
72
+ v = {run = {playersInventory = __TS__New(
73
+ DefaultMap,
74
+ function(____, player) return newPlayerInventory(nil, player) end
75
+ )}}
97
76
  ---
98
77
  -- @internal
99
78
  function ____exports.playerInventoryInit(self, mod)
100
79
  saveDataManager(nil, "playerInventory", v)
101
80
  mod:AddCallback(ModCallback.POST_USE_ITEM, useItemD4, CollectibleType.D4)
102
81
  mod:AddCallback(ModCallback.POST_GAME_STARTED, postGameStarted)
103
- mod:AddCallbackCustom(ModCallbackCustom.POST_ITEM_PICKUP, postItemPickup)
82
+ mod:AddCallbackCustom(ModCallbackCustom.POST_PLAYER_COLLECTIBLE_ADDED, postCollectibleAdded)
83
+ mod:AddCallbackCustom(ModCallbackCustom.POST_PLAYER_COLLECTIBLE_REMOVED, postCollectibleRemoved)
104
84
  end
105
85
  --- Helper function to get all of the collectibles that the player has gotten so far on this run, in
106
86
  -- order.
@@ -117,8 +97,7 @@ function ____exports.getPlayerInventory(self, player, includeActiveCollectibles)
117
97
  includeActiveCollectibles = true
118
98
  end
119
99
  errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
120
- local playerIndex = getPlayerIndex(nil, player)
121
- local inventory = v.run.playersInventory:getAndSetDefault(playerIndex, player)
100
+ local inventory = defaultMapGetPlayer(nil, v.run.playersInventory, player, player)
122
101
  local copiedInventory = copyArray(nil, inventory)
123
102
  if includeActiveCollectibles then
124
103
  return copiedInventory
@@ -128,20 +107,4 @@ function ____exports.getPlayerInventory(self, player, includeActiveCollectibles)
128
107
  function(____, collectibleType) return not isActiveCollectible(nil, collectibleType) end
129
108
  )
130
109
  end
131
- --- Helper function to add a collectible to a player. Use this instead of the
132
- -- `EntityPlayer.AddCollectible` method if you want the collectible that is added to be
133
- -- automatically tracked by the player inventory tracker feature.
134
- --
135
- -- You only need to use this function if you are using the inventory feature from the standard
136
- -- library.
137
- function ____exports.addCollectible(self, player, collectibleType, charge, firstTimePickingUp, activeSlot, varData)
138
- player:AddCollectible(
139
- collectibleType,
140
- charge,
141
- firstTimePickingUp,
142
- activeSlot,
143
- varData
144
- )
145
- addCollectibleToInventory(nil, player, collectibleType)
146
- end
147
110
  return ____exports
@@ -16,7 +16,7 @@ export declare function arrayEquals<T>(array1: T[] | readonly T[], array2: T[] |
16
16
  export declare function arrayRemove<T>(originalArray: T[] | readonly T[], ...elementsToRemove: T[]): T[];
17
17
  /**
18
18
  * Removes the specified element(s) from the array. If the specified element(s) are not found in the
19
- * array, this function will do nothing. Returns whether or not one or more elements were removed.
19
+ * array, this function will do nothing. Returns true if one or more elements were removed.
20
20
  *
21
21
  * This function is variadic, meaning that you can specify N arguments to remove N elements.
22
22
  */
@@ -31,8 +31,8 @@ export declare function arrayRemoveInPlace<T>(array: T[], ...elementsToRemove: T
31
31
  export declare function arrayRemoveIndex<T>(originalArray: T[] | readonly T[], ...indexesToRemove: int[]): T[];
32
32
  /**
33
33
  * Removes the elements at the specified indexes from the array. If the specified indexes are not
34
- * found in the array, this function will do nothing. Returns whether or not one or more elements
35
- * were removed.
34
+ * found in the array, this function will do nothing. Returns true if one or more elements were
35
+ * removed.
36
36
  *
37
37
  * This function is variadic, meaning that you can specify N arguments to remove N elements.
38
38
  */
@@ -87,7 +87,7 @@ function ____exports.arrayRemove(self, originalArray, ...)
87
87
  return array
88
88
  end
89
89
  --- Removes the specified element(s) from the array. If the specified element(s) are not found in the
90
- -- array, this function will do nothing. Returns whether or not one or more elements were removed.
90
+ -- array, this function will do nothing. Returns true if one or more elements were removed.
91
91
  --
92
92
  -- This function is variadic, meaning that you can specify N arguments to remove N elements.
93
93
  function ____exports.arrayRemoveInPlace(self, array, ...)
@@ -122,8 +122,8 @@ function ____exports.arrayRemoveIndex(self, originalArray, ...)
122
122
  return array
123
123
  end
124
124
  --- Removes the elements at the specified indexes from the array. If the specified indexes are not
125
- -- found in the array, this function will do nothing. Returns whether or not one or more elements
126
- -- were removed.
125
+ -- found in the array, this function will do nothing. Returns true if one or more elements were
126
+ -- removed.
127
127
  --
128
128
  -- This function is variadic, meaning that you can specify N arguments to remove N elements.
129
129
  function ____exports.arrayRemoveIndexInPlace(self, array, ...)
@@ -2,8 +2,8 @@ import { CollectibleType } from "isaac-typescript-definitions";
2
2
  /**
3
3
  * Returns a set containing every valid collectible type in the game, including modded collectibles.
4
4
  */
5
- export declare function getCollectibleSet(): Set<CollectibleType>;
5
+ export declare function getCollectibleSet(): ReadonlySet<CollectibleType>;
6
6
  /** Returns a set containing every modded collectible type in the game. */
7
- export declare function getModdedCollectibleSet(): Set<CollectibleType>;
7
+ export declare function getModdedCollectibleSet(): ReadonlySet<CollectibleType>;
8
8
  /** Returns a set containing every valid vanilla collectible type in the game. */
9
- export declare function getVanillaCollectibleSet(): Set<CollectibleType>;
9
+ export declare function getVanillaCollectibleSet(): ReadonlySet<CollectibleType>;
@@ -8,8 +8,6 @@ local ____constantsFirstLast = require("constantsFirstLast")
8
8
  local LAST_VANILLA_COLLECTIBLE_TYPE = ____constantsFirstLast.LAST_VANILLA_COLLECTIBLE_TYPE
9
9
  local ____collectibles = require("functions.collectibles")
10
10
  local getCollectibleTypeRange = ____collectibles.getCollectibleTypeRange
11
- local ____set = require("functions.set")
12
- local copySet = ____set.copySet
13
11
  local ALL_COLLECTIBLES_SET = __TS__New(Set)
14
12
  local VANILLA_COLLECTIBLES_SET = __TS__New(Set)
15
13
  local MODDED_COLLECTIBLES_SET = __TS__New(Set)
@@ -35,20 +33,20 @@ function ____exports.getCollectibleSet(self)
35
33
  if ALL_COLLECTIBLES_SET.size == 0 then
36
34
  initCollectibleSets(nil)
37
35
  end
38
- return copySet(nil, ALL_COLLECTIBLES_SET)
36
+ return ALL_COLLECTIBLES_SET
39
37
  end
40
38
  --- Returns a set containing every modded collectible type in the game.
41
39
  function ____exports.getModdedCollectibleSet(self)
42
40
  if ALL_COLLECTIBLES_SET.size == 0 then
43
41
  initCollectibleSets(nil)
44
42
  end
45
- return copySet(nil, MODDED_COLLECTIBLES_SET)
43
+ return MODDED_COLLECTIBLES_SET
46
44
  end
47
45
  --- Returns a set containing every valid vanilla collectible type in the game.
48
46
  function ____exports.getVanillaCollectibleSet(self)
49
47
  if ALL_COLLECTIBLES_SET.size == 0 then
50
48
  initCollectibleSets(nil)
51
49
  end
52
- return copySet(nil, VANILLA_COLLECTIBLES_SET)
50
+ return VANILLA_COLLECTIBLES_SET
53
51
  end
54
52
  return ____exports
@@ -8,6 +8,11 @@ export declare function getAllPillColors(): PillColor[];
8
8
  * Helper function to get an array with every valid pill effect. This includes modded pill effects.
9
9
  */
10
10
  export declare function getAllPillEffects(): PillEffect[];
11
+ /**
12
+ * Helper function to get the associated pill effect after False PHD is acquired. If a pill effect
13
+ * is not altered by False PHD, then the same pill effect will be returned.
14
+ */
15
+ export declare function getFalsePHDPillEffect(pillEffect: PillEffect): PillEffect;
11
16
  /**
12
17
  * Helper function to get the corresponding horse pill color from a normal pill color.
13
18
  *
@@ -33,6 +38,11 @@ export declare function getModdedPillEffects(): PillEffect[];
33
38
  export declare function getNormalPillColorFromHorse(pillColor: PillColor): PillColor;
34
39
  /** Helper function to get an array with every non-gold and non-horse pill color. */
35
40
  export declare function getNormalPillColors(): PillColor[];
41
+ /**
42
+ * Helper function to get the associated pill effect after PHD is acquired. If a pill effect is not
43
+ * altered by PHD, then the same pill effect will be returned.
44
+ */
45
+ export declare function getPHDPillEffect(pillEffect: PillEffect): PillEffect;
36
46
  /**
37
47
  * Helper function to get a pill effect class from a PillEffect enum value. In this context, the
38
48
  * class is equal to the numerical prefix in the "class" tag in the "pocketitems.xml" file. Use the
@@ -14,6 +14,10 @@ local LAST_HORSE_PILL_COLOR = ____constantsFirstLast.LAST_HORSE_PILL_COLOR
14
14
  local LAST_NORMAL_PILL_COLOR = ____constantsFirstLast.LAST_NORMAL_PILL_COLOR
15
15
  local LAST_PILL_EFFECT = ____constantsFirstLast.LAST_PILL_EFFECT
16
16
  local LAST_VANILLA_PILL_EFFECT = ____constantsFirstLast.LAST_VANILLA_PILL_EFFECT
17
+ local ____falsePHDPillConversions = require("maps.falsePHDPillConversions")
18
+ local FALSE_PHD_PILL_CONVERSIONS = ____falsePHDPillConversions.FALSE_PHD_PILL_CONVERSIONS
19
+ local ____PHDPillConversions = require("maps.PHDPillConversions")
20
+ local PHD_PILL_CONVERSIONS = ____PHDPillConversions.PHD_PILL_CONVERSIONS
17
21
  local ____pillEffectClasses = require("objects.pillEffectClasses")
18
22
  local DEFAULT_PILL_EFFECT_CLASS = ____pillEffectClasses.DEFAULT_PILL_EFFECT_CLASS
19
23
  local PILL_EFFECT_CLASSES = ____pillEffectClasses.PILL_EFFECT_CLASSES
@@ -44,6 +48,12 @@ end
44
48
  function ____exports.getAllPillEffects(self)
45
49
  return irange(nil, FIRST_PILL_EFFECT, LAST_PILL_EFFECT)
46
50
  end
51
+ --- Helper function to get the associated pill effect after False PHD is acquired. If a pill effect
52
+ -- is not altered by False PHD, then the same pill effect will be returned.
53
+ function ____exports.getFalsePHDPillEffect(self, pillEffect)
54
+ local convertedPillEffect = FALSE_PHD_PILL_CONVERSIONS:get(pillEffect)
55
+ return convertedPillEffect == nil and pillEffect or convertedPillEffect
56
+ end
47
57
  --- Helper function to get the corresponding horse pill color from a normal pill color.
48
58
  --
49
59
  -- For example, passing `PillColor.BLUE_BLUE` would result in 2049, which is the value that
@@ -77,6 +87,12 @@ end
77
87
  function ____exports.getNormalPillColors(self)
78
88
  return irange(nil, FIRST_PILL_COLOR, LAST_NORMAL_PILL_COLOR)
79
89
  end
90
+ --- Helper function to get the associated pill effect after PHD is acquired. If a pill effect is not
91
+ -- altered by PHD, then the same pill effect will be returned.
92
+ function ____exports.getPHDPillEffect(self, pillEffect)
93
+ local convertedPillEffect = PHD_PILL_CONVERSIONS:get(pillEffect)
94
+ return convertedPillEffect == nil and pillEffect or convertedPillEffect
95
+ end
80
96
  --- Helper function to get a pill effect class from a PillEffect enum value. In this context, the
81
97
  -- class is equal to the numerical prefix in the "class" tag in the "pocketitems.xml" file. Use the
82
98
  -- `getPillEffectType` helper function to determine whether or not the pill effect is positive,
@@ -1,9 +1,4 @@
1
1
  import { DoorSlot, RoomShape, RoomType, StageID } from "isaac-typescript-definitions";
2
- /**
3
- * Alias for the `Level.GetCurrentRoomDesc` method. Use this to make it more clear what type of
4
- * `RoomDescriptor` object that you are retrieving.
5
- */
6
- export declare function getCurrentRoomDescriptorReadOnly(): ReadonlyRoomDescriptor;
7
2
  /**
8
3
  * Helper function to get the set of allowed door slots for the room at the supplied grid index.
9
4
  * This corresponds to the doors that are enabled in the STB/XML file for the room.
@@ -21,6 +16,11 @@ export declare function getRoomData(roomGridIndex?: int): RoomConfig | undefined
21
16
  * @param roomGridIndex Optional. Default is the current room index.
22
17
  */
23
18
  export declare function getRoomDescriptor(roomGridIndex?: int): RoomDescriptor;
19
+ /**
20
+ * Alias for the `Level.GetCurrentRoomDesc` method. Use this to make it more clear what type of
21
+ * `RoomDescriptor` object that you are retrieving.
22
+ */
23
+ export declare function getRoomDescriptorReadOnly(): ReadonlyRoomDescriptor;
24
24
  /**
25
25
  * Helper function to get the grid index of the current room.
26
26
  *
@@ -12,12 +12,6 @@ local ____enums = require("functions.enums")
12
12
  local getEnumValues = ____enums.getEnumValues
13
13
  local ____flag = require("functions.flag")
14
14
  local hasFlag = ____flag.hasFlag
15
- --- Alias for the `Level.GetCurrentRoomDesc` method. Use this to make it more clear what type of
16
- -- `RoomDescriptor` object that you are retrieving.
17
- function ____exports.getCurrentRoomDescriptorReadOnly(self)
18
- local level = game:GetLevel()
19
- return level:GetCurrentRoomDesc()
20
- end
21
15
  --- Helper function to get the room data for the provided room.
22
16
  --
23
17
  -- @param roomGridIndex Optional. Default is the current room index.
@@ -35,6 +29,12 @@ function ____exports.getRoomDescriptor(self, roomGridIndex)
35
29
  end
36
30
  return level:GetRoomByIdx(roomGridIndex)
37
31
  end
32
+ --- Alias for the `Level.GetCurrentRoomDesc` method. Use this to make it more clear what type of
33
+ -- `RoomDescriptor` object that you are retrieving.
34
+ function ____exports.getRoomDescriptorReadOnly(self)
35
+ local level = game:GetLevel()
36
+ return level:GetCurrentRoomDesc()
37
+ end
38
38
  --- Helper function to get the grid index of the current room.
39
39
  --
40
40
  -- - If the current room is inside of the grid, this function will return the `SafeGridIndex` from
@@ -55,7 +55,7 @@ function ____exports.getRoomGridIndex(self)
55
55
  if currentRoomIndex < 0 then
56
56
  return currentRoomIndex
57
57
  end
58
- local roomDescriptor = ____exports.getCurrentRoomDescriptorReadOnly(nil)
58
+ local roomDescriptor = ____exports.getRoomDescriptorReadOnly(nil)
59
59
  return roomDescriptor.SafeGridIndex
60
60
  end
61
61
  --- Helper function to get the set of allowed door slots for the room at the supplied grid index.
@@ -13,11 +13,8 @@ export declare function getAllRoomGridIndexes(): int[];
13
13
  /**
14
14
  * Helper function to get the current dimension. Most of the time, this will be `Dimension.MAIN`,
15
15
  * but it can change if e.g. the player is in the mirror world of Downpour/Dross.
16
- *
17
- * Note that this function correctly handles detecting the Death Certificate dimension, which is
18
- * tricky to properly detect.
19
16
  */
20
- export declare function getCurrentDimension(): Dimension;
17
+ export declare function getDimension(): Dimension;
21
18
  /**
22
19
  * Helper function to get the number of rooms that are currently on the floor layout. This does not
23
20
  * include off-grid rooms, like the Devil Room.
@@ -51,10 +51,10 @@ local getEntityVelocities = ____positionVelocity.getEntityVelocities
51
51
  local setEntityPositions = ____positionVelocity.setEntityPositions
52
52
  local setEntityVelocities = ____positionVelocity.setEntityVelocities
53
53
  local ____roomData = require("functions.roomData")
54
- local getCurrentRoomDescriptorReadOnly = ____roomData.getCurrentRoomDescriptorReadOnly
55
54
  local getRoomAllowedDoors = ____roomData.getRoomAllowedDoors
56
55
  local getRoomData = ____roomData.getRoomData
57
56
  local getRoomDescriptor = ____roomData.getRoomDescriptor
57
+ local getRoomDescriptorReadOnly = ____roomData.getRoomDescriptorReadOnly
58
58
  local getRoomGridIndex = ____roomData.getRoomGridIndex
59
59
  local getRoomName = ____roomData.getRoomName
60
60
  local getRoomShape = ____roomData.getRoomShape
@@ -103,13 +103,6 @@ function ____exports.getRooms(self, includeExtraDimensionalRooms)
103
103
  end
104
104
  return {__TS__Spread(roomsMap:values())}
105
105
  end
106
- --- We cannot use the standard code in the `inDimension` function for this purpose since it is bugged
107
- -- with the Death Certificate area.
108
- function ____exports.inDeathCertificateArea(self)
109
- local roomStageID = getRoomStageID(nil)
110
- local roomSubType = getRoomSubType(nil)
111
- return roomStageID == StageID.HOME and (roomSubType == HomeRoomSubType.DEATH_CERTIFICATE_ENTRANCE or roomSubType == HomeRoomSubType.DEATH_CERTIFICATE_ITEMS)
112
- end
113
106
  --- Helper function to check if a room exists at the given room grid index.
114
107
  function ____exports.roomExists(self, roomGridIndex)
115
108
  local roomData = getRoomData(nil, roomGridIndex)
@@ -140,25 +133,19 @@ function ____exports.getAllRoomGridIndexes(self)
140
133
  end
141
134
  --- Helper function to get the current dimension. Most of the time, this will be `Dimension.MAIN`,
142
135
  -- but it can change if e.g. the player is in the mirror world of Downpour/Dross.
143
- --
144
- -- Note that this function correctly handles detecting the Death Certificate dimension, which is
145
- -- tricky to properly detect.
146
- function ____exports.getCurrentDimension(self)
136
+ function ____exports.getDimension(self)
147
137
  local level = game:GetLevel()
148
- if ____exports.inDeathCertificateArea(nil) then
149
- return Dimension.DEATH_CERTIFICATE
150
- end
151
- local startingRoomGridIndex = level:GetStartingRoomIndex()
152
- local startingRoomDescription = level:GetRoomByIdx(startingRoomGridIndex, Dimension.CURRENT)
153
- local startingRoomHash = GetPtrHash(startingRoomDescription)
138
+ local roomGridIndex = getRoomGridIndex(nil)
139
+ local roomDescription = level:GetRoomByIdx(roomGridIndex, Dimension.CURRENT)
140
+ local currentRoomHash = GetPtrHash(roomDescription)
154
141
  for ____, dimension in ipairs(____exports.getAllDimensions(nil)) do
155
- local dimensionRoomDescription = level:GetRoomByIdx(startingRoomGridIndex, dimension)
142
+ local dimensionRoomDescription = level:GetRoomByIdx(roomGridIndex, dimension)
156
143
  local dimensionRoomHash = GetPtrHash(dimensionRoomDescription)
157
- if dimensionRoomHash == startingRoomHash then
144
+ if dimensionRoomHash == currentRoomHash then
158
145
  return dimension
159
146
  end
160
147
  end
161
- return error("Failed to get the current dimension using the starting room index of: " .. tostring(startingRoomGridIndex))
148
+ return error("Failed to get the current dimension.")
162
149
  end
163
150
  --- Helper function to get the number of rooms that are currently on the floor layout. This does not
164
151
  -- include off-grid rooms, like the Devil Room.
@@ -277,15 +264,22 @@ function ____exports.inCrawlspace(self)
277
264
  local roomSubType = getRoomSubType(nil)
278
265
  return roomType == RoomType.DUNGEON and roomSubType == DungeonSubType.NORMAL
279
266
  end
267
+ --- We cannot use the standard code in the `inDimension` function for this purpose since it is bugged
268
+ -- with the Death Certificate area.
269
+ function ____exports.inDeathCertificateArea(self)
270
+ local roomStageID = getRoomStageID(nil)
271
+ local roomSubType = getRoomSubType(nil)
272
+ return roomStageID == StageID.HOME and (roomSubType == HomeRoomSubType.DEATH_CERTIFICATE_ENTRANCE or roomSubType == HomeRoomSubType.DEATH_CERTIFICATE_ITEMS)
273
+ end
280
274
  --- Helper function to detect if the current room is a Treasure Room created when entering with a
281
275
  -- Devil's Crown trinket. Under the hood, this checks for the `RoomDescriptorFlag.DEVIL_TREASURE`
282
276
  -- flag.
283
277
  function ____exports.inDevilsCrownTreasureRoom(self)
284
- local roomDescriptor = getCurrentRoomDescriptorReadOnly(nil)
278
+ local roomDescriptor = getRoomDescriptorReadOnly(nil)
285
279
  return hasFlag(nil, roomDescriptor.Flags, RoomDescriptorFlag.DEVIL_TREASURE)
286
280
  end
287
281
  function ____exports.inDimension(self, dimension)
288
- return dimension == ____exports.getCurrentDimension(nil)
282
+ return dimension == ____exports.getDimension(nil)
289
283
  end
290
284
  function ____exports.inDoubleTrouble(self)
291
285
  local room = game:GetRoom()
@@ -438,12 +432,12 @@ function ____exports.setRoomCleared(self)
438
432
  for ____, door in ipairs(getDoors(nil)) do
439
433
  do
440
434
  if isHiddenSecretRoomDoor(nil, door) then
441
- goto __continue68
435
+ goto __continue67
442
436
  end
443
437
  openDoorFast(nil, door)
444
438
  door.ExtraVisible = false
445
439
  end
446
- ::__continue68::
440
+ ::__continue67::
447
441
  end
448
442
  sfxManager:Stop(SoundEffect.DOOR_HEAVY_OPEN)
449
443
  game:ShakeScreen(0)
@@ -1,7 +1,6 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local Map = ____lualib.Map
3
3
  local __TS__New = ____lualib.__TS__New
4
- local Set = ____lualib.Set
5
4
  local __TS__Iterator = ____lualib.__TS__Iterator
6
5
  local ____exports = {}
7
6
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
package/index.d.ts CHANGED
@@ -21,7 +21,7 @@ export { disableFastReset, enableFastReset } from "./features/fastReset";
21
21
  export { forgottenSwitch } from "./features/forgottenSwitch";
22
22
  export { getCollectibleItemPoolType } from "./features/getCollectibleItemPoolType";
23
23
  export { removePersistentEntity, spawnPersistentEntity, } from "./features/persistentEntities";
24
- export { addCollectible, getPlayerInventory } from "./features/playerInventory";
24
+ export { getPlayerInventory } from "./features/playerInventory";
25
25
  export * from "./features/ponyDetection";
26
26
  export { preventCollectibleRotation } from "./features/preventCollectibleRotation";
27
27
  export { runInNGameFrames, runInNRenderFrames, runNextGameFrame, runNextRenderFrame, } from "./features/runInNFrames";
package/index.lua CHANGED
@@ -176,9 +176,7 @@ do
176
176
  end
177
177
  do
178
178
  local ____playerInventory = require("features.playerInventory")
179
- local addCollectible = ____playerInventory.addCollectible
180
179
  local getPlayerInventory = ____playerInventory.getPlayerInventory
181
- ____exports.addCollectible = addCollectible
182
180
  ____exports.getPlayerInventory = getPlayerInventory
183
181
  end
184
182
  do
@@ -65,6 +65,8 @@ local ____postPlayerChangeHealth = require("callbacks.postPlayerChangeHealth")
65
65
  local postPlayerChangeHealthCallbackInit = ____postPlayerChangeHealth.postPlayerChangeHealthCallbackInit
66
66
  local ____postPlayerChangeType = require("callbacks.postPlayerChangeType")
67
67
  local postPlayerChangeTypeCallbackInit = ____postPlayerChangeType.postPlayerChangeTypeCallbackInit
68
+ local ____postPlayerCollectible = require("callbacks.postPlayerCollectible")
69
+ local postPlayerCollectibleCallbackInit = ____postPlayerCollectible.postPlayerCollectibleCallbackInit
68
70
  local ____postPlayerFatalDamage = require("callbacks.postPlayerFatalDamage")
69
71
  local postPlayerFatalDamageCallbackInit = ____postPlayerFatalDamage.postPlayerFatalDamageCallbackInit
70
72
  local ____postPlayerInitLate = require("callbacks.postPlayerInitLate")
@@ -153,6 +155,7 @@ function ____exports.initCustomCallbacks(self, mod)
153
155
  postPitUpdateInit(nil, mod)
154
156
  postPlayerChangeHealthCallbackInit(nil, mod)
155
157
  postPlayerChangeTypeCallbackInit(nil, mod)
158
+ postPlayerCollectibleCallbackInit(nil, mod)
156
159
  postPlayerFatalDamageCallbackInit(nil, mod)
157
160
  postPlayerInitLateCallbackInit(nil, mod)
158
161
  postPlayerReorderedCallbacksInit(nil, mod)