isaacscript-common 1.2.52 → 1.2.55

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.
@@ -10,6 +10,9 @@ local ____player = require("functions.player")
10
10
  local getPlayerIndex = ____player.getPlayerIndex
11
11
  local ____ModCallbacksCustom = require("types.ModCallbacksCustom")
12
12
  local ModCallbacksCustom = ____ModCallbacksCustom.ModCallbacksCustom
13
+ local ____PickingUpItem = require("types.PickingUpItem")
14
+ local newPickingUpItem = ____PickingUpItem.newPickingUpItem
15
+ local resetPickingUpItem = ____PickingUpItem.resetPickingUpItem
13
16
  local ____postItemPickup = require("callbacks.subscriptions.postItemPickup")
14
17
  local postItemPickupFire = ____postItemPickup.postItemPickupFire
15
18
  local postItemPickupHasSubscriptions = ____postItemPickup.postItemPickupHasSubscriptions
@@ -25,35 +28,52 @@ function postPEffectUpdateReordered(self, player)
25
28
  end
26
29
  local pickingUpItem = getPickingUpItemForPlayer(nil, player)
27
30
  if player:IsItemQueueEmpty() then
31
+ if player:GetPlayerType() == PlayerType.PLAYER_THESOUL then
32
+ Isaac.DebugString((("GETTING HERE - EMPTY - " .. tostring(pickingUpItem.itemType)) .. ", ") .. tostring(pickingUpItem.subType))
33
+ end
28
34
  queueEmpty(nil, player, pickingUpItem)
29
35
  else
36
+ if player:GetPlayerType() == PlayerType.PLAYER_THESOUL then
37
+ Isaac.DebugString((("GETTING HERE - NOT EMPTY - " .. tostring(pickingUpItem.itemType)) .. ", ") .. tostring(pickingUpItem.subType))
38
+ end
30
39
  queueNotEmpty(nil, player, pickingUpItem)
31
40
  end
32
41
  end
33
42
  function queueEmpty(self, player, pickingUpItem)
34
- if pickingUpItem.id ~= CollectibleType.COLLECTIBLE_NULL then
35
- postItemPickupFire(nil, player, pickingUpItem)
36
- pickingUpItem.id = CollectibleType.COLLECTIBLE_NULL
37
- pickingUpItem.type = ItemType.ITEM_NULL
43
+ if pickingUpItem.subType == CollectibleType.COLLECTIBLE_NULL then
44
+ return
38
45
  end
46
+ postItemPickupFire(nil, player, pickingUpItem)
47
+ resetPickingUpItem(nil, pickingUpItem)
39
48
  end
40
49
  function queueNotEmpty(self, player, pickingUpItem)
41
50
  local queuedItem = player.QueuedItem.Item
42
51
  if queuedItem == nil then
43
52
  return
44
53
  end
45
- if queuedItem.Type ~= pickingUpItem.type or queuedItem.ID ~= pickingUpItem.id then
46
- pickingUpItem.type = queuedItem.Type
47
- pickingUpItem.id = queuedItem.ID
54
+ if queuedItem.Type ~= pickingUpItem.itemType or queuedItem.ID ~= pickingUpItem.subType then
55
+ pickingUpItem.itemType = queuedItem.Type
56
+ pickingUpItem.subType = queuedItem.ID
57
+ Isaac.DebugString((("GETTING HERE - SET: " .. tostring(pickingUpItem.itemType)) .. ", ") .. tostring(pickingUpItem.subType))
48
58
  preItemPickupFire(nil, player, pickingUpItem)
49
59
  end
50
60
  end
51
61
  function getPickingUpItemForPlayer(self, player)
52
- local index = getPlayerIndex(nil, player)
53
- local pickingUpItem = v.run.pickingUpItem:get(index)
62
+ local character = player:GetPlayerType()
63
+ local playerIndex
64
+ if character == PlayerType.PLAYER_THESOUL then
65
+ local forgotten = player:GetSubPlayer()
66
+ if forgotten == nil then
67
+ error("Failed")
68
+ end
69
+ playerIndex = getPlayerIndex(nil, forgotten)
70
+ else
71
+ playerIndex = getPlayerIndex(nil, player)
72
+ end
73
+ local pickingUpItem = v.run.pickingUpItem:get(playerIndex)
54
74
  if pickingUpItem == nil then
55
- pickingUpItem = {id = CollectibleType.COLLECTIBLE_NULL, type = ItemType.ITEM_NULL}
56
- v.run.pickingUpItem:set(index, pickingUpItem)
75
+ pickingUpItem = newPickingUpItem(nil)
76
+ v.run.pickingUpItem:set(playerIndex, pickingUpItem)
57
77
  end
58
78
  return pickingUpItem
59
79
  end
@@ -1,4 +1,6 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ local ____lualib = require("lualib_bundle")
3
+ local __TS__ArrayFind = ____lualib.__TS__ArrayFind
2
4
  local ____exports = {}
3
5
  local hasSubscriptions, postUpdate, getPlayerWithControllerIndex, useItemEsauJr, v
4
6
  local ____exports = require("features.saveDataManager.exports")
@@ -39,12 +41,11 @@ function postUpdate(self)
39
41
  postEsauJrFire(nil, player)
40
42
  end
41
43
  function getPlayerWithControllerIndex(self, controllerIndex)
42
- for ____, player in ipairs(getPlayers(nil)) do
43
- if player.ControllerIndex == controllerIndex then
44
- return player
45
- end
46
- end
47
- return nil
44
+ local players = getPlayers(nil)
45
+ return __TS__ArrayFind(
46
+ players,
47
+ function(____, player) return player.ControllerIndex == controllerIndex end
48
+ )
48
49
  end
49
50
  function useItemEsauJr(self, _collectibleType, _rng, player, _useFlags, _activeSlot, _customVarData)
50
51
  if not hasSubscriptions(nil) then
@@ -5,7 +5,7 @@ local __TS__New = ____lualib.__TS__New
5
5
  local __TS__ArrayPush = ____lualib.__TS__ArrayPush
6
6
  local Map = ____lualib.Map
7
7
  local ____exports = {}
8
- local hasSubscriptions, postPEffectUpdateReordered, playerTransformationChanged, updateForgottenOrSoulTransformation, TRANSFORMATIONS, v
8
+ local hasSubscriptions, postPEffectUpdateReordered, TRANSFORMATIONS, v
9
9
  local ____exports = require("features.saveDataManager.exports")
10
10
  local saveDataManager = ____exports.saveDataManager
11
11
  local ____array = require("functions.array")
@@ -40,27 +40,10 @@ function postPEffectUpdateReordered(self, player)
40
40
  end
41
41
  if hasForm ~= storedForm then
42
42
  transformations:set(playerForm, hasForm)
43
- playerTransformationChanged(nil, player, playerForm, hasForm)
43
+ postTransformationFire(nil, player, playerForm, hasForm)
44
44
  end
45
45
  end
46
46
  end
47
- function playerTransformationChanged(self, player, playerForm, hasForm)
48
- postTransformationFire(nil, player, playerForm, hasForm)
49
- updateForgottenOrSoulTransformation(nil, player, playerForm, hasForm)
50
- end
51
- function updateForgottenOrSoulTransformation(self, player, playerForm, hasForm)
52
- local subPlayer = player:GetSubPlayer()
53
- if subPlayer == nil then
54
- return
55
- end
56
- local subPlayerIndex = getPlayerIndex(nil, subPlayer)
57
- local transformations = v.run.transformations:get(subPlayerIndex)
58
- if transformations == nil then
59
- transformations = __TS__New(Map)
60
- v.run.transformations:set(subPlayerIndex, transformations)
61
- end
62
- transformations:set(playerForm, hasForm)
63
- end
64
47
  local UNUSED_TRANSFORMATIONS = __TS__New(Set, {PlayerForm.PLAYERFORM_FLIGHT})
65
48
  local tempTransformations = {}
66
49
  do
@@ -15,10 +15,10 @@ function ____exports.postItemPickupFire(self, player, pickingUpItem)
15
15
  local itemType = ____value[2]
16
16
  local itemID = ____value[3]
17
17
  do
18
- if itemType ~= nil and itemType ~= pickingUpItem.type then
18
+ if itemType ~= nil and itemType ~= pickingUpItem.itemType then
19
19
  goto __continue5
20
20
  end
21
- if itemID ~= nil and itemID ~= pickingUpItem.id then
21
+ if itemID ~= nil and itemID ~= pickingUpItem.subType then
22
22
  goto __continue5
23
23
  end
24
24
  callback(nil, player, pickingUpItem)
@@ -15,10 +15,10 @@ function ____exports.preItemPickupFire(self, player, pickingUpItem)
15
15
  local itemType = ____value[2]
16
16
  local itemID = ____value[3]
17
17
  do
18
- if itemType ~= nil and itemType ~= pickingUpItem.type then
18
+ if itemType ~= nil and itemType ~= pickingUpItem.itemType then
19
19
  goto __continue5
20
20
  end
21
- if itemID ~= nil and itemID ~= pickingUpItem.id then
21
+ if itemID ~= nil and itemID ~= pickingUpItem.subType then
22
22
  goto __continue5
23
23
  end
24
24
  callback(nil, player, pickingUpItem)
@@ -1,6 +1,7 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____lualib = require("lualib_bundle")
3
3
  local __TS__ArrayPush = ____lualib.__TS__ArrayPush
4
+ local __TS__ArrayFind = ____lualib.__TS__ArrayFind
4
5
  local ____exports = {}
5
6
  local postNPCInitSirenHelper, checkReturnFamiliarToPlayer, blacklistEntryExists, getSirenHelper, v
6
7
  local ____errors = require("errors")
@@ -39,14 +40,12 @@ function blacklistEntryExists(self, incomingFamiliarVariant, incomingFamiliarSub
39
40
  return false
40
41
  end
41
42
  function getSirenHelper(self, familiar)
42
- local familiarHash = GetPtrHash(familiar)
43
+ local familiarPtrHash = GetPtrHash(familiar)
43
44
  local sirenHelpers = getEntities(nil, EntityType.ENTITY_SIREN_HELPER)
44
- for ____, sirenHelper in ipairs(sirenHelpers) do
45
- if sirenHelper.Target ~= nil and GetPtrHash(sirenHelper.Target) == familiarHash then
46
- return sirenHelper
47
- end
48
- end
49
- return nil
45
+ return __TS__ArrayFind(
46
+ sirenHelpers,
47
+ function(____, sirenHelper) return sirenHelper.Target ~= nil and GetPtrHash(sirenHelper.Target) == familiarPtrHash end
48
+ )
50
49
  end
51
50
  local FEATURE_NAME = "siren helpers"
52
51
  local initialized = false
@@ -3,6 +3,7 @@ local ____lualib = require("lualib_bundle")
3
3
  local Set = ____lualib.Set
4
4
  local __TS__New = ____lualib.__TS__New
5
5
  local __TS__ArrayPush = ____lualib.__TS__ArrayPush
6
+ local __TS__ArrayFind = ____lualib.__TS__ArrayFind
6
7
  local ____exports = {}
7
8
  local ____constants = require("constants")
8
9
  local MAX_NUM_DOORS = ____constants.MAX_NUM_DOORS
@@ -32,12 +33,6 @@ function ____exports.getDoors(self, ...)
32
33
  end
33
34
  return doors
34
35
  end
35
- function ____exports.isAngelRoomDoor(self, door)
36
- return door.TargetRoomType == RoomType.ROOM_ANGEL
37
- end
38
- function ____exports.isDevilRoomDoor(self, door)
39
- return door.TargetRoomType == RoomType.ROOM_DEVIL
40
- end
41
36
  function ____exports.isRepentanceDoor(self, door)
42
37
  return door.TargetRoomIndex == GridRooms.ROOM_SECRET_EXIT_IDX
43
38
  end
@@ -57,36 +52,47 @@ function ____exports.closeDoorFast(self, door)
57
52
  sprite:Play("Closed", true)
58
53
  end
59
54
  function ____exports.getAngelRoomDoor(self)
60
- for ____, door in ipairs(____exports.getDoors(nil)) do
61
- if ____exports.isAngelRoomDoor(nil, door) then
62
- return door
63
- end
55
+ local angelRoomDoors = ____exports.getDoors(nil, RoomType.ROOM_ANGEL)
56
+ local ____temp_0
57
+ if #angelRoomDoors == 0 then
58
+ ____temp_0 = nil
59
+ else
60
+ ____temp_0 = angelRoomDoors[1]
64
61
  end
65
- return nil
62
+ return ____temp_0
66
63
  end
67
64
  function ____exports.getDevilRoomDoor(self)
68
- for ____, door in ipairs(____exports.getDoors(nil)) do
69
- if ____exports.isDevilRoomDoor(nil, door) then
70
- return door
71
- end
65
+ local devilRoomDoors = ____exports.getDoors(nil, RoomType.ROOM_DEVIL)
66
+ local ____temp_1
67
+ if #devilRoomDoors == 0 then
68
+ ____temp_1 = nil
69
+ else
70
+ ____temp_1 = devilRoomDoors[1]
72
71
  end
73
- return nil
72
+ return ____temp_1
74
73
  end
75
74
  function ____exports.getDevilRoomOrAngelRoomDoor(self)
76
- for ____, door in ipairs(____exports.getDoors(nil)) do
77
- if ____exports.isDevilRoomDoor(nil, door) or ____exports.isAngelRoomDoor(nil, door) then
78
- return door
79
- end
75
+ local devilRoomOrAngelRoomDoors = ____exports.getDoors(nil, RoomType.ROOM_DEVIL, RoomType.ROOM_ANGEL)
76
+ local ____temp_2
77
+ if #devilRoomOrAngelRoomDoors == 0 then
78
+ ____temp_2 = nil
79
+ else
80
+ ____temp_2 = devilRoomOrAngelRoomDoors[1]
80
81
  end
81
- return nil
82
+ return ____temp_2
82
83
  end
83
84
  function ____exports.getRepentanceDoor(self)
84
- for ____, door in ipairs(____exports.getDoors(nil)) do
85
- if ____exports.isRepentanceDoor(nil, door) then
86
- return door
87
- end
88
- end
89
- return nil
85
+ local doors = ____exports.getDoors(nil)
86
+ return __TS__ArrayFind(
87
+ doors,
88
+ function(____, door) return ____exports.isRepentanceDoor(nil, door) end
89
+ )
90
+ end
91
+ function ____exports.isAngelRoomDoor(self, door)
92
+ return door.TargetRoomType == RoomType.ROOM_ANGEL
93
+ end
94
+ function ____exports.isDevilRoomDoor(self, door)
95
+ return door.TargetRoomType == RoomType.ROOM_DEVIL
90
96
  end
91
97
  function ____exports.isHiddenSecretRoomDoor(self, door)
92
98
  local sprite = door:GetSprite()
@@ -52,6 +52,14 @@ export declare function characterGetsBlackHeartFromEternalHeart(character: Playe
52
52
  * The formula for calculating it is: 32 - 2.5 * player.TearHeight
53
53
  */
54
54
  export declare function getAzazelBrimstoneDistance(playerOrTearHeight: EntityPlayer | float): number;
55
+ /**
56
+ * Returns the maximum heart containers that the provided character can have. Normally, this is 12,
57
+ * but with Keeper it is 3, with Tainted Keeper it is 2. Does not account for Birthright or Mother's
58
+ * Kiss; use the `getPlayerMaxHeartContainers()` function for that.
59
+ */
60
+ export declare function getCharacterMaxHeartContainers(character: PlayerType | int): int;
61
+ /** Helper function to get an array containing the characters of all of the current players. */
62
+ export declare function getCharacters(): number[];
55
63
  export declare function getClosestPlayer(position: Vector): EntityPlayer;
56
64
  /**
57
65
  * Most characters have a 56 frame death animation (i.e. the "Death" animation).
@@ -81,14 +89,6 @@ export declare function getNewestPlayer(): EntityPlayer;
81
89
  * hearts and 3 broken hearts, then this function would return 6 (i.e. 12 - 1 - 2 - 3).
82
90
  */
83
91
  export declare function getPlayerAvailableHeartSlots(player: EntityPlayer): int;
84
- /**
85
- * Returns the maximum heart containers that the provided character can have. Normally, this is 12,
86
- * but with Keeper it is 3, with Tainted Keeper it is 2. Does not account for Birthright or Mother's
87
- * Kiss; use the `getPlayerMaxHeartContainers()` function for that.
88
- */
89
- export declare function getCharacterMaxHeartContainers(character: PlayerType | int): int;
90
- /** Helper function to get an array containing the characters of all of the current players. */
91
- export declare function getCharacters(): number[];
92
92
  /**
93
93
  * Iterates over all players and checks if any are close enough to the specified position.
94
94
  *
@@ -122,13 +122,15 @@ export declare function getPlayerFromIndex(playerIndex: PlayerIndex): EntityPlay
122
122
  * Instead, we use `EntityPlayer.GetCollectibleRNG()` with an arbitrary value of Sad Onion (1). This
123
123
  * works even if the player does not have any Sad Onions.
124
124
  *
125
- * Since the RNG value is the same for both The Forgotten and The Soul, we revert to using the RNG
126
- * of Inner Eye (2) for The Soul.
127
- *
128
125
  * Since the RNG value is the same for both Tainted Lazarus and Dead Tainted Lazarus, we revert to
129
- * using the RNG of Spoon Bender (3) for Dead Tainted Lazarus.
126
+ * using the RNG of The Inner Eye (2) for Dead Tainted Lazarus.
127
+ *
128
+ * Note that by default, this returns the same index for both The Forgotten and The Soul. (Even
129
+ * though they are technically different characters, they share the same inventory and InitSeed.) If
130
+ * this is not desired, pass true for the `differentiateForgottenAndSoul` argument, and the RNG of
131
+ * Spoon Bender (3) will be used for The Soul.
130
132
  */
131
- export declare function getPlayerIndex(player: EntityPlayer): PlayerIndex;
133
+ export declare function getPlayerIndex(player: EntityPlayer, differentiateForgottenAndSoul?: boolean): PlayerIndex;
132
134
  /**
133
135
  * Helper function to return the index of this player with respect to the output of the
134
136
  * `Isaac.GetPlayer()` function.
@@ -171,6 +173,12 @@ export declare function getPlayers(performExclusions?: boolean): EntityPlayer[];
171
173
  * for. Returns true if any of the characters supplied are present.
172
174
  */
173
175
  export declare function getPlayersOfType(...characters: Array<PlayerType | int>): EntityPlayer[];
176
+ /**
177
+ * Helper function to get a parent `EntityPlayer` object for a given `EntitySubPlayer` object. This
178
+ * is useful because calling the `EntityPlayer.GetSubPlayer` method on a sub-player object will
179
+ * return undefined.
180
+ */
181
+ export declare function getSubPlayerParent(subPlayer: EntitySubPlayer): EntityPlayer | undefined;
174
182
  /**
175
183
  * Helper function to return the active charge and the battery charge combined. This is useful
176
184
  * because you are not able to set the battery charge directly.
@@ -4,12 +4,13 @@ local Set = ____lualib.Set
4
4
  local __TS__New = ____lualib.__TS__New
5
5
  local __TS__ArraySome = ____lualib.__TS__ArraySome
6
6
  local __TS__ArrayMap = ____lualib.__TS__ArrayMap
7
+ local __TS__ArrayFind = ____lualib.__TS__ArrayFind
7
8
  local Map = ____lualib.Map
8
9
  local __TS__Iterator = ____lualib.__TS__Iterator
9
10
  local __TS__ArrayPush = ____lualib.__TS__ArrayPush
10
11
  local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
11
12
  local ____exports = {}
12
- local getPlayerIndexCollectibleType, getAdjustedPlayerName, isTaintedModded, EXCLUDED_CHARACTERS
13
+ local getPlayerIndexCollectibleType, getAdjustedPlayerName, isTaintedModded, DEFAULT_COLLECTIBLE_TYPE, EXCLUDED_CHARACTERS
13
14
  local ____constants = require("constants")
14
15
  local CHARACTERS_WITH_BLACK_HEART_FROM_ETERNAL_HEART = ____constants.CHARACTERS_WITH_BLACK_HEART_FROM_ETERNAL_HEART
15
16
  local CHARACTERS_WITH_FREE_DEVIL_DEALS = ____constants.CHARACTERS_WITH_FREE_DEVIL_DEALS
@@ -50,31 +51,45 @@ function ____exports.getCharacters(self)
50
51
  function(____, player) return player:GetPlayerType() end
51
52
  )
52
53
  end
53
- function ____exports.getPlayerIndex(self, player)
54
- local character = player:GetPlayerType()
55
- local collectibleType = getPlayerIndexCollectibleType(nil, character)
56
- local collectibleRNG = player:GetCollectibleRNG(collectibleType)
54
+ function ____exports.getPlayerIndex(self, player, differentiateForgottenAndSoul)
55
+ if differentiateForgottenAndSoul == nil then
56
+ differentiateForgottenAndSoul = false
57
+ end
58
+ local isSubPlayer = player:IsSubPlayer()
59
+ local ____isSubPlayer_0
60
+ if isSubPlayer then
61
+ ____isSubPlayer_0 = ____exports.getSubPlayerParent(nil, player)
62
+ else
63
+ ____isSubPlayer_0 = player
64
+ end
65
+ local playerToUse = ____isSubPlayer_0
66
+ if playerToUse == nil then
67
+ error("Failed to get the sub-player parent when determining the index for the player with InitSeed: " .. tostring(player.InitSeed))
68
+ end
69
+ local collectibleType = getPlayerIndexCollectibleType(nil, player, differentiateForgottenAndSoul)
70
+ local collectibleRNG = playerToUse:GetCollectibleRNG(collectibleType)
57
71
  local seed = collectibleRNG:GetSeed()
58
72
  return seed
59
73
  end
60
- function getPlayerIndexCollectibleType(self, character)
74
+ function getPlayerIndexCollectibleType(self, player, differentiateForgottenAndSoul)
75
+ local character = player:GetPlayerType()
61
76
  repeat
62
- local ____switch62 = character
63
- local ____cond62 = ____switch62 == PlayerType.PLAYER_THESOUL
64
- if ____cond62 then
77
+ local ____switch59 = character
78
+ local ____cond59 = ____switch59 == PlayerType.PLAYER_THESOUL
79
+ if ____cond59 then
65
80
  do
66
- return CollectibleType.COLLECTIBLE_INNER_EYE
81
+ return differentiateForgottenAndSoul and CollectibleType.COLLECTIBLE_SPOON_BENDER or DEFAULT_COLLECTIBLE_TYPE
67
82
  end
68
83
  end
69
- ____cond62 = ____cond62 or ____switch62 == PlayerType.PLAYER_LAZARUS2_B
70
- if ____cond62 then
84
+ ____cond59 = ____cond59 or ____switch59 == PlayerType.PLAYER_LAZARUS2_B
85
+ if ____cond59 then
71
86
  do
72
- return CollectibleType.COLLECTIBLE_SPOON_BENDER
87
+ return CollectibleType.COLLECTIBLE_INNER_EYE
73
88
  end
74
89
  end
75
90
  do
76
91
  do
77
- return CollectibleType.COLLECTIBLE_SAD_ONION
92
+ return DEFAULT_COLLECTIBLE_TYPE
78
93
  end
79
94
  end
80
95
  until true
@@ -95,39 +110,39 @@ end
95
110
  function getAdjustedPlayerName(self, player)
96
111
  local character = player:GetPlayerType()
97
112
  repeat
98
- local ____switch75 = character
99
- local ____cond75 = ____switch75 == PlayerType.PLAYER_BLUEBABY or ____switch75 == PlayerType.PLAYER_BLUEBABY_B
100
- if ____cond75 then
113
+ local ____switch72 = character
114
+ local ____cond72 = ____switch72 == PlayerType.PLAYER_BLUEBABY or ____switch72 == PlayerType.PLAYER_BLUEBABY_B
115
+ if ____cond72 then
101
116
  do
102
117
  return "Blue Baby"
103
118
  end
104
119
  end
105
- ____cond75 = ____cond75 or ____switch75 == PlayerType.PLAYER_LAZARUS2
106
- if ____cond75 then
120
+ ____cond72 = ____cond72 or ____switch72 == PlayerType.PLAYER_LAZARUS2
121
+ if ____cond72 then
107
122
  do
108
123
  return "Lazarus II"
109
124
  end
110
125
  end
111
- ____cond75 = ____cond75 or ____switch75 == PlayerType.PLAYER_BLACKJUDAS
112
- if ____cond75 then
126
+ ____cond72 = ____cond72 or ____switch72 == PlayerType.PLAYER_BLACKJUDAS
127
+ if ____cond72 then
113
128
  do
114
129
  return "Dark Judas"
115
130
  end
116
131
  end
117
- ____cond75 = ____cond75 or ____switch75 == PlayerType.PLAYER_JACOB
118
- if ____cond75 then
132
+ ____cond72 = ____cond72 or ____switch72 == PlayerType.PLAYER_JACOB
133
+ if ____cond72 then
119
134
  do
120
135
  return "Jacob & Esau"
121
136
  end
122
137
  end
123
- ____cond75 = ____cond75 or ____switch75 == PlayerType.PLAYER_LAZARUS2_B
124
- if ____cond75 then
138
+ ____cond72 = ____cond72 or ____switch72 == PlayerType.PLAYER_LAZARUS2_B
139
+ if ____cond72 then
125
140
  do
126
141
  return "Dead Tainted Lazarus"
127
142
  end
128
143
  end
129
- ____cond75 = ____cond75 or ____switch75 == PlayerType.PLAYER_JACOB2_B
130
- if ____cond75 then
144
+ ____cond72 = ____cond72 or ____switch72 == PlayerType.PLAYER_JACOB2_B
145
+ if ____cond72 then
131
146
  do
132
147
  return "Dead Tainted Jacob"
133
148
  end
@@ -151,32 +166,47 @@ function ____exports.getPlayers(self, performExclusions)
151
166
  do
152
167
  local player = Isaac.GetPlayer(i)
153
168
  if ____exports.isChildPlayer(nil, player) then
154
- goto __continue85
169
+ goto __continue82
155
170
  end
156
171
  local character = player:GetPlayerType()
157
172
  if performExclusions and EXCLUDED_CHARACTERS:has(character) then
158
- goto __continue85
173
+ goto __continue82
159
174
  end
160
175
  __TS__ArrayPush(players, player)
161
176
  end
162
- ::__continue85::
177
+ ::__continue82::
163
178
  i = i + 1
164
179
  end
165
180
  end
166
181
  return players
167
182
  end
183
+ function ____exports.getSubPlayerParent(self, subPlayer)
184
+ local subPlayerPtrHash = GetPtrHash(subPlayer)
185
+ local players = ____exports.getPlayers(nil)
186
+ return __TS__ArrayFind(
187
+ players,
188
+ function(____, player)
189
+ local thisPlayerSubPlayer = player:GetSubPlayer()
190
+ if thisPlayerSubPlayer == nil then
191
+ return false
192
+ end
193
+ local thisPlayerSubPlayerPtrHash = GetPtrHash(thisPlayerSubPlayer)
194
+ return thisPlayerSubPlayerPtrHash == subPlayerPtrHash
195
+ end
196
+ )
197
+ end
168
198
  function ____exports.isChildPlayer(self, player)
169
199
  return player.Parent ~= nil
170
200
  end
171
201
  function ____exports.isTainted(self, player)
172
202
  local character = player:GetPlayerType()
173
- local ____isVanillaCharacter_result_0
203
+ local ____isVanillaCharacter_result_1
174
204
  if ____exports.isVanillaCharacter(nil, player) then
175
- ____isVanillaCharacter_result_0 = character >= PlayerType.PLAYER_ISAAC_B
205
+ ____isVanillaCharacter_result_1 = character >= PlayerType.PLAYER_ISAAC_B
176
206
  else
177
- ____isVanillaCharacter_result_0 = isTaintedModded(nil, player)
207
+ ____isVanillaCharacter_result_1 = isTaintedModded(nil, player)
178
208
  end
179
- return ____isVanillaCharacter_result_0
209
+ return ____isVanillaCharacter_result_1
180
210
  end
181
211
  function isTaintedModded(self, player)
182
212
  local character = player:GetPlayerType()
@@ -191,6 +221,7 @@ end
191
221
  function ____exports.isVanillaCharacter(self, player)
192
222
  return not ____exports.isModdedCharacter(nil, player)
193
223
  end
224
+ DEFAULT_COLLECTIBLE_TYPE = CollectibleType.COLLECTIBLE_SAD_ONION
194
225
  EXCLUDED_CHARACTERS = __TS__New(Set, {PlayerType.PLAYER_ESAU, PlayerType.PLAYER_THESOUL_B})
195
226
  function ____exports.addCollectibleCostume(self, player, collectibleType)
196
227
  local itemConfig = Isaac.GetItemConfig()
@@ -351,12 +382,11 @@ function ____exports.getPlayerAvailableHeartSlots(self, player)
351
382
  return maxHeartContainers - totalOccupiedHeartSlots
352
383
  end
353
384
  function ____exports.getPlayerCloserThan(self, position, distance)
354
- for ____, player in ipairs(____exports.getPlayers(nil)) do
355
- if player.Position:Distance(position) <= distance then
356
- return player
357
- end
358
- end
359
- return nil
385
+ local players = ____exports.getPlayers(nil)
386
+ return __TS__ArrayFind(
387
+ players,
388
+ function(____, player) return player.Position:Distance(position) <= distance end
389
+ )
360
390
  end
361
391
  function ____exports.getPlayerCollectibleMap(self, player)
362
392
  local collectibleSet = getCollectibleSet(nil)
@@ -370,13 +400,11 @@ function ____exports.getPlayerCollectibleMap(self, player)
370
400
  return collectibleMap
371
401
  end
372
402
  function ____exports.getPlayerFromIndex(self, playerIndex)
373
- for ____, player in ipairs(____exports.getPlayers(nil)) do
374
- local existingPlayerIndex = ____exports.getPlayerIndex(nil, player)
375
- if existingPlayerIndex == playerIndex then
376
- return player
377
- end
378
- end
379
- return nil
403
+ local players = ____exports.getPlayers(nil)
404
+ return __TS__ArrayFind(
405
+ players,
406
+ function(____, player) return ____exports.getPlayerIndex(nil, player) == playerIndex end
407
+ )
380
408
  end
381
409
  function ____exports.getPlayerIndexVanilla(self, playerToFind)
382
410
  local game = Game()
@@ -1,5 +1,6 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____lualib = require("lualib_bundle")
3
+ local __TS__ArrayFind = ____lualib.__TS__ArrayFind
3
4
  local __TS__ArrayPush = ____lualib.__TS__ArrayPush
4
5
  local __TS__ArraySome = ____lualib.__TS__ArraySome
5
6
  local ____exports = {}
@@ -46,12 +47,10 @@ function ____exports.getPocketItems(self, player)
46
47
  end
47
48
  function ____exports.getFirstCardOrPill(self, player)
48
49
  local pocketItems = ____exports.getPocketItems(nil, player)
49
- for ____, pocketItem in ipairs(pocketItems) do
50
- if pocketItem.type == PocketItemType.CARD or pocketItem.type == PocketItemType.PILL then
51
- return pocketItem
52
- end
53
- end
54
- return nil
50
+ return __TS__ArrayFind(
51
+ pocketItems,
52
+ function(____, pocketItem) return pocketItem.type == PocketItemType.CARD or pocketItem.type == PocketItemType.PILL end
53
+ )
55
54
  end
56
55
  function ____exports.hasOpenPocketItemSlot(self, player)
57
56
  local character = player:GetPlayerType()
package/dist/index.d.ts CHANGED
@@ -73,6 +73,7 @@ export * from "./maps/trinketNameMap";
73
73
  export * from "./sets/cards";
74
74
  export * from "./types/AnyEntity";
75
75
  export * from "./types/CallbackParametersCustom";
76
+ export * from "./types/DefaultMap";
76
77
  export * from "./types/HealthType";
77
78
  export * from "./types/JSONDoor";
78
79
  export * from "./types/JSONEntity";
package/dist/index.lua CHANGED
@@ -578,6 +578,14 @@ do
578
578
  end
579
579
  end
580
580
  end
581
+ do
582
+ local ____export = require("types.DefaultMap")
583
+ for ____exportKey, ____exportValue in pairs(____export) do
584
+ if ____exportKey ~= "default" then
585
+ ____exports[____exportKey] = ____exportValue
586
+ end
587
+ end
588
+ end
581
589
  do
582
590
  local ____export = require("types.HealthType")
583
591
  for ____exportKey, ____exportValue in pairs(____export) do
@@ -602,6 +610,14 @@ do
602
610
  end
603
611
  end
604
612
  end
613
+ do
614
+ local ____export = require("types.PickingUpItem")
615
+ for ____exportKey, ____exportValue in pairs(____export) do
616
+ if ____exportKey ~= "default" then
617
+ ____exports[____exportKey] = ____exportValue
618
+ end
619
+ end
620
+ end
605
621
  do
606
622
  local ____export = require("types.PillEffectClass")
607
623
  for ____exportKey, ____exportValue in pairs(____export) do
@@ -1,6 +1,9 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  export interface PickingUpItem {
3
3
  /** Needed so that we can distinguish between picking up a collectible and a trinket. */
4
- type: ItemType;
5
- id: int;
4
+ itemType: ItemType;
5
+ /** Equal to either the collectible type or the trinket type. */
6
+ subType: CollectibleType | TrinketType | int;
6
7
  }
8
+ export declare function newPickingUpItem(): PickingUpItem;
9
+ export declare function resetPickingUpItem(pickingUpItem: PickingUpItem): void;
@@ -1,3 +1,12 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____exports = {}
3
+ local DEFAULT_ITEM_TYPE = ItemType.ITEM_NULL
4
+ local DEFAULT_SUB_TYPE = CollectibleType.COLLECTIBLE_NULL
5
+ function ____exports.newPickingUpItem(self)
6
+ return {itemType = DEFAULT_ITEM_TYPE, subType = DEFAULT_SUB_TYPE}
7
+ end
8
+ function ____exports.resetPickingUpItem(self, pickingUpItem)
9
+ pickingUpItem.itemType = DEFAULT_ITEM_TYPE
10
+ pickingUpItem.subType = DEFAULT_SUB_TYPE
11
+ end
3
12
  return ____exports
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.52",
3
+ "version": "1.2.55",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",
@@ -26,7 +26,7 @@
26
26
  ],
27
27
  "devDependencies": {
28
28
  "@zamiell/typescript-to-lua": "^1.4.0",
29
- "isaac-typescript-definitions": "^1.0.348",
29
+ "isaac-typescript-definitions": "^1.0.349",
30
30
  "isaacscript-lint": "^1.0.79",
31
31
  "isaacscript-tsconfig": "^1.1.8",
32
32
  "typedoc": "^0.22.12",