isaacscript-common 1.0.593 → 1.0.597

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
@@ -11,6 +11,7 @@ export declare function getStage(): LevelStage;
11
11
  export declare function getStageType(): StageType;
12
12
  /** Helper function to directly warp to a specific stage using the "stage" console command. */
13
13
  export declare function goToStage(stage: LevelStage, stageType: StageType): void;
14
+ export declare function isRepentanceStage(stageType: int): boolean;
14
15
  export declare function onCathedral(): boolean;
15
16
  export declare function onChest(): boolean;
16
17
  export declare function onDarkRoom(): boolean;
@@ -2,47 +2,50 @@
2
2
  local ____exports = {}
3
3
  local ____util = require("functions.util")
4
4
  local ensureAllCases = ____util.ensureAllCases
5
+ function ____exports.isRepentanceStage(self, stageType)
6
+ return stageType == StageType.STAGETYPE_REPENTANCE or stageType == StageType.STAGETYPE_REPENTANCE_B
7
+ end
5
8
  function ____exports.onRepentanceStage(self)
6
9
  local game = Game()
7
10
  local level = game:GetLevel()
8
11
  local stageType = level:GetStageType()
9
- return stageType == StageType.STAGETYPE_REPENTANCE or stageType == StageType.STAGETYPE_REPENTANCE_B
12
+ return ____exports.isRepentanceStage(nil, stageType)
10
13
  end
11
14
  function ____exports.stageTypeToLetter(self, stageType)
12
15
  repeat
13
- local ____switch14 = stageType
14
- local ____cond14 = ____switch14 == StageType.STAGETYPE_ORIGINAL
15
- if ____cond14 then
16
+ local ____switch15 = stageType
17
+ local ____cond15 = ____switch15 == StageType.STAGETYPE_ORIGINAL
18
+ if ____cond15 then
16
19
  do
17
20
  return ""
18
21
  end
19
22
  end
20
- ____cond14 = ____cond14 or ____switch14 == StageType.STAGETYPE_WOTL
21
- if ____cond14 then
23
+ ____cond15 = ____cond15 or ____switch15 == StageType.STAGETYPE_WOTL
24
+ if ____cond15 then
22
25
  do
23
26
  return "a"
24
27
  end
25
28
  end
26
- ____cond14 = ____cond14 or ____switch14 == StageType.STAGETYPE_AFTERBIRTH
27
- if ____cond14 then
29
+ ____cond15 = ____cond15 or ____switch15 == StageType.STAGETYPE_AFTERBIRTH
30
+ if ____cond15 then
28
31
  do
29
32
  return "b"
30
33
  end
31
34
  end
32
- ____cond14 = ____cond14 or ____switch14 == StageType.STAGETYPE_GREEDMODE
33
- if ____cond14 then
35
+ ____cond15 = ____cond15 or ____switch15 == StageType.STAGETYPE_GREEDMODE
36
+ if ____cond15 then
34
37
  do
35
38
  return ""
36
39
  end
37
40
  end
38
- ____cond14 = ____cond14 or ____switch14 == StageType.STAGETYPE_REPENTANCE
39
- if ____cond14 then
41
+ ____cond15 = ____cond15 or ____switch15 == StageType.STAGETYPE_REPENTANCE
42
+ if ____cond15 then
40
43
  do
41
44
  return "c"
42
45
  end
43
46
  end
44
- ____cond14 = ____cond14 or ____switch14 == StageType.STAGETYPE_REPENTANCE_B
45
- if ____cond14 then
47
+ ____cond15 = ____cond15 or ____switch15 == StageType.STAGETYPE_REPENTANCE_B
48
+ if ____cond15 then
46
49
  do
47
50
  return "d"
48
51
  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
@@ -1,20 +1,14 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____exports = {}
3
- local getHeartRowLength
4
3
  local ____constants = require("constants")
5
4
  local UI_HEART_WIDTH = ____constants.UI_HEART_WIDTH
6
- function getHeartRowLength(self, player)
7
- local game = Game()
8
- local level = game:GetLevel()
9
- local curses = level:GetCurses()
5
+ function ____exports.getHeartRowLength(self, player)
10
6
  local maxHearts = player:GetMaxHearts()
11
7
  local soulHearts = player:GetSoulHearts()
12
8
  local boneHearts = player:GetBoneHearts()
13
- if curses == LevelCurse.CURSE_OF_THE_UNKNOWN then
14
- return 1
15
- end
16
9
  local combinedHearts = maxHearts + soulHearts + boneHearts * 2
17
- return math.max(combinedHearts / 2, 6)
10
+ local heartRowLength = combinedHearts / 2
11
+ return math.min(heartRowLength, 6)
18
12
  end
19
13
  function ____exports.getScreenBottomRightPos(self)
20
14
  local screenWidth = Isaac.GetScreenWidth()
@@ -22,11 +16,20 @@ function ____exports.getScreenBottomRightPos(self)
22
16
  return Vector(screenWidth, screenHeight)
23
17
  end
24
18
  function ____exports.getHeartsUIWidth(self)
19
+ local game = Game()
20
+ local level = game:GetLevel()
21
+ local curses = level:GetCurses()
25
22
  local player = Isaac.GetPlayer()
26
23
  local extraLives = player:GetExtraLives()
27
24
  local effects = player:GetEffects()
28
25
  local hasHolyMantleEffect = effects:HasCollectibleEffect(CollectibleType.COLLECTIBLE_HOLY_MANTLE)
29
- local heartRowLength = getHeartRowLength(nil, player)
26
+ local heartRowLength = ____exports.getHeartRowLength(nil, player)
27
+ if hasHolyMantleEffect then
28
+ heartRowLength = heartRowLength + 1
29
+ end
30
+ if curses == LevelCurse.CURSE_OF_THE_UNKNOWN then
31
+ heartRowLength = 1
32
+ end
30
33
  local width = heartRowLength * UI_HEART_WIDTH
31
34
  if extraLives > 9 then
32
35
  width = width + 20
@@ -39,9 +42,6 @@ function ____exports.getHeartsUIWidth(self)
39
42
  width = width + 4
40
43
  end
41
44
  end
42
- if hasHolyMantleEffect then
43
- width = width + UI_HEART_WIDTH
44
- end
45
45
  return width
46
46
  end
47
47
  function ____exports.getHUDOffsetVector(self)
@@ -1335,6 +1335,15 @@ Map = Map
1335
1335
 
1336
1336
  __TS__MathAtan2 = math.atan2 or math.atan
1337
1337
 
1338
+ function __TS__MathSign(val)
1339
+ if val > 0 then
1340
+ return 1
1341
+ elseif val < 0 then
1342
+ return -1
1343
+ end
1344
+ return 0
1345
+ end
1346
+
1338
1347
  function __TS__Number(value)
1339
1348
  local valueType = type(value)
1340
1349
  if valueType == "number" then
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.0.593",
3
+ "version": "1.0.597",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",
@@ -28,8 +28,8 @@
28
28
  "isaac-typescript-definitions": "^1.0.331",
29
29
  "isaacscript-lint": "^1.0.79",
30
30
  "isaacscript-tsconfig": "^1.1.8",
31
- "typedoc": "^0.22.10",
32
- "typescript": "^4.5.4",
33
- "typescript-to-lua": "^1.3.1"
31
+ "typedoc": "^0.22.11",
32
+ "typescript": "^4.5.5",
33
+ "typescript-to-lua": "^1.3.3"
34
34
  }
35
35
  }