isaacscript-common 1.0.592 → 1.0.596

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.
@@ -142,7 +142,13 @@ export declare function getPlayerNumAllHearts(player: EntityPlayer): int;
142
142
  * the player (i.e. Esau & Tainted Soul). False by default.
143
143
  */
144
144
  export declare function getPlayers(performExclusions?: boolean): EntityPlayer[];
145
- export declare function getPlayersOfType(playerType: PlayerType): EntityPlayer[];
145
+ /**
146
+ * Helper function to get all of the players that are a certain character.
147
+ *
148
+ * This function is variadic, meaning that you can supply as many characters as you want to check
149
+ * for. Returns true if any of the characters supplied are present.
150
+ */
151
+ export declare function getPlayersOfType(...characters: PlayerType[]): EntityPlayer[];
146
152
  /**
147
153
  * Helper function to return the active charge and the battery charge combined. This is useful
148
154
  * because you are not able to set the battery charge directly.
@@ -302,11 +302,13 @@ function ____exports.getPlayerNumAllHearts(self, player)
302
302
  local rottenHearts = player:GetRottenHearts()
303
303
  return hearts + soulHearts + boneHearts + eternalHearts - rottenHearts
304
304
  end
305
- function ____exports.getPlayersOfType(self, playerType)
305
+ function ____exports.getPlayersOfType(self, ...)
306
+ local characters = {...}
307
+ local charactersSet = __TS__New(Set, characters)
306
308
  local players = {}
307
309
  for ____, player in ipairs(____exports.getPlayers(nil)) do
308
310
  local character = player:GetPlayerType()
309
- if character == playerType then
311
+ if charactersSet:has(character) then
310
312
  __TS__ArrayPush(players, player)
311
313
  end
312
314
  end
@@ -5,6 +5,11 @@
5
5
  * combination with the `getHUDOffsetVector()` helper function.
6
6
  */
7
7
  export declare function getHeartsUIWidth(): int;
8
+ /**
9
+ * Returns how many hearts are in the heart UI row. If the player has more than 6 hearts, this
10
+ * function will return 6.
11
+ */
12
+ export declare function getHeartRowLength(player: EntityPlayer): int;
8
13
  /**
9
14
  * In the options menu, players have the ability to set a HUD offset. However, mods do not have
10
15
  * access to this value. To get around this, Mod Config Menu provides a separate HUD offset setting
@@ -2,6 +2,14 @@
2
2
  local ____exports = {}
3
3
  local ____constants = require("constants")
4
4
  local UI_HEART_WIDTH = ____constants.UI_HEART_WIDTH
5
+ function ____exports.getHeartRowLength(self, player)
6
+ local maxHearts = player:GetMaxHearts()
7
+ local soulHearts = player:GetSoulHearts()
8
+ local boneHearts = player:GetBoneHearts()
9
+ local combinedHearts = maxHearts + soulHearts + boneHearts * 2
10
+ local heartRowLength = combinedHearts / 2
11
+ return math.min(heartRowLength, 6)
12
+ end
5
13
  function ____exports.getScreenBottomRightPos(self)
6
14
  local screenWidth = Isaac.GetScreenWidth()
7
15
  local screenHeight = Isaac.GetScreenHeight()
@@ -12,18 +20,17 @@ function ____exports.getHeartsUIWidth(self)
12
20
  local level = game:GetLevel()
13
21
  local curses = level:GetCurses()
14
22
  local player = Isaac.GetPlayer()
15
- local maxHearts = player:GetMaxHearts()
16
- local soulHearts = player:GetSoulHearts()
17
- local boneHearts = player:GetBoneHearts()
18
23
  local extraLives = player:GetExtraLives()
19
- local combinedHearts = maxHearts + soulHearts + boneHearts * 2
20
- if combinedHearts > 12 then
21
- combinedHearts = 12
24
+ local effects = player:GetEffects()
25
+ local hasHolyMantleEffect = effects:HasCollectibleEffect(CollectibleType.COLLECTIBLE_HOLY_MANTLE)
26
+ local heartRowLength = ____exports.getHeartRowLength(nil, player)
27
+ if hasHolyMantleEffect then
28
+ heartRowLength = heartRowLength + 1
22
29
  end
23
30
  if curses == LevelCurse.CURSE_OF_THE_UNKNOWN then
24
- combinedHearts = 2
31
+ heartRowLength = 1
25
32
  end
26
- local width = combinedHearts / 2 * UI_HEART_WIDTH
33
+ local width = heartRowLength * UI_HEART_WIDTH
27
34
  if extraLives > 9 then
28
35
  width = width + 20
29
36
  if player:HasCollectible(CollectibleType.COLLECTIBLE_GUPPYS_COLLAR) then
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.0.592",
3
+ "version": "1.0.596",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",