isaacscript-common 1.2.18 → 1.2.19

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.
@@ -81,6 +81,22 @@ export declare function getNewestPlayer(): EntityPlayer;
81
81
  * hearts and 3 broken hearts, then this function would return 6 (i.e. 12 - 1 - 2 - 3).
82
82
  */
83
83
  export declare function getPlayerAvailableHeartSlots(player: EntityPlayer): int;
84
+ /**
85
+ * Returns an array containing every collectible type that the player has that matches the provided
86
+ * CacheFlag.
87
+ *
88
+ * For example, if a player has one Lord of the Pit and two Transcendences, then this function would
89
+ * return:
90
+ *
91
+ * ```ts
92
+ * [
93
+ * CollectibleType.COLLECTIBLE_LORD_OF_THE_PIT,
94
+ * CollectibleType.COLLECTIBLE_TRANSCENDENCE,
95
+ * CollectibleType.COLLECTIBLE_TRANSCENDENCE,
96
+ * ]
97
+ * ```
98
+ */
99
+ export declare function getPlayerCollectiblesForCacheFlag(player: EntityPlayer, cacheFlag: CacheFlag): Array<CollectibleType | int>;
84
100
  /**
85
101
  * Returns the maximum heart containers that the provided character can have. Normally, this is 12,
86
102
  * but with Keeper it is 3, with Tainted Keeper it is 2. Does not account for Birthright or Mother's
@@ -3,10 +3,10 @@ local ____lualib = require("lualib_bundle")
3
3
  local Set = ____lualib.Set
4
4
  local __TS__New = ____lualib.__TS__New
5
5
  local __TS__ArraySome = ____lualib.__TS__ArraySome
6
+ local __TS__ArrayPush = ____lualib.__TS__ArrayPush
7
+ local __TS__Iterator = ____lualib.__TS__Iterator
6
8
  local __TS__ArrayMap = ____lualib.__TS__ArrayMap
7
9
  local Map = ____lualib.Map
8
- local __TS__Iterator = ____lualib.__TS__Iterator
9
- local __TS__ArrayPush = ____lualib.__TS__ArrayPush
10
10
  local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
11
11
  local ____exports = {}
12
12
  local getAdjustedPlayerName, isTaintedModded, EXCLUDED_CHARACTERS
@@ -25,6 +25,8 @@ local arraySum = ____array.arraySum
25
25
  local ____bitwise = require("functions.bitwise")
26
26
  local getKBitOfN = ____bitwise.getKBitOfN
27
27
  local getNumBitsOfN = ____bitwise.getNumBitsOfN
28
+ local ____collectibleCacheFlag = require("functions.collectibleCacheFlag")
29
+ local getCollectiblesForCacheFlag = ____collectibleCacheFlag.getCollectiblesForCacheFlag
28
30
  local ____collectibles = require("functions.collectibles")
29
31
  local getCollectibleMaxCharges = ____collectibles.getCollectibleMaxCharges
30
32
  local ____collectibleSet = require("functions.collectibleSet")
@@ -72,39 +74,39 @@ end
72
74
  function getAdjustedPlayerName(self, player)
73
75
  local character = player:GetPlayerType()
74
76
  repeat
75
- local ____switch71 = character
76
- local ____cond71 = ____switch71 == PlayerType.PLAYER_BLUEBABY or ____switch71 == PlayerType.PLAYER_BLUEBABY_B
77
- if ____cond71 then
77
+ local ____switch75 = character
78
+ local ____cond75 = ____switch75 == PlayerType.PLAYER_BLUEBABY or ____switch75 == PlayerType.PLAYER_BLUEBABY_B
79
+ if ____cond75 then
78
80
  do
79
81
  return "Blue Baby"
80
82
  end
81
83
  end
82
- ____cond71 = ____cond71 or ____switch71 == PlayerType.PLAYER_LAZARUS2
83
- if ____cond71 then
84
+ ____cond75 = ____cond75 or ____switch75 == PlayerType.PLAYER_LAZARUS2
85
+ if ____cond75 then
84
86
  do
85
87
  return "Lazarus II"
86
88
  end
87
89
  end
88
- ____cond71 = ____cond71 or ____switch71 == PlayerType.PLAYER_BLACKJUDAS
89
- if ____cond71 then
90
+ ____cond75 = ____cond75 or ____switch75 == PlayerType.PLAYER_BLACKJUDAS
91
+ if ____cond75 then
90
92
  do
91
93
  return "Dark Judas"
92
94
  end
93
95
  end
94
- ____cond71 = ____cond71 or ____switch71 == PlayerType.PLAYER_JACOB
95
- if ____cond71 then
96
+ ____cond75 = ____cond75 or ____switch75 == PlayerType.PLAYER_JACOB
97
+ if ____cond75 then
96
98
  do
97
99
  return "Jacob & Esau"
98
100
  end
99
101
  end
100
- ____cond71 = ____cond71 or ____switch71 == PlayerType.PLAYER_LAZARUS2_B
101
- if ____cond71 then
102
+ ____cond75 = ____cond75 or ____switch75 == PlayerType.PLAYER_LAZARUS2_B
103
+ if ____cond75 then
102
104
  do
103
105
  return "Dead Tainted Lazarus"
104
106
  end
105
107
  end
106
- ____cond71 = ____cond71 or ____switch71 == PlayerType.PLAYER_JACOB2_B
107
- if ____cond71 then
108
+ ____cond75 = ____cond75 or ____switch75 == PlayerType.PLAYER_JACOB2_B
109
+ if ____cond75 then
108
110
  do
109
111
  return "Dead Tainted Jacob"
110
112
  end
@@ -128,18 +130,18 @@ function ____exports.getPlayers(self, performExclusions)
128
130
  do
129
131
  local player = Isaac.GetPlayer(i)
130
132
  if player == nil then
131
- goto __continue81
133
+ goto __continue85
132
134
  end
133
135
  if ____exports.isChildPlayer(nil, player) then
134
- goto __continue81
136
+ goto __continue85
135
137
  end
136
138
  local character = player:GetPlayerType()
137
139
  if performExclusions and EXCLUDED_CHARACTERS:has(character) then
138
- goto __continue81
140
+ goto __continue85
139
141
  end
140
142
  __TS__ArrayPush(players, player)
141
143
  end
142
- ::__continue81::
144
+ ::__continue85::
143
145
  i = i + 1
144
146
  end
145
147
  end
@@ -330,6 +332,21 @@ function ____exports.getPlayerAvailableHeartSlots(self, player)
330
332
  local totalOccupiedHeartSlots = totalHeartContainers + brokenHearts
331
333
  return maxHeartContainers - totalOccupiedHeartSlots
332
334
  end
335
+ function ____exports.getPlayerCollectiblesForCacheFlag(self, player, cacheFlag)
336
+ local collectiblesForCacheFlag = getCollectiblesForCacheFlag(nil, cacheFlag)
337
+ local playerCollectibles = {}
338
+ for ____, collectibleType in __TS__Iterator(collectiblesForCacheFlag:values()) do
339
+ local numCollectibles = player:GetCollectibleNum(collectibleType)
340
+ do
341
+ local i = 0
342
+ while i < numCollectibles do
343
+ __TS__ArrayPush(playerCollectibles, collectibleType)
344
+ i = i + 1
345
+ end
346
+ end
347
+ end
348
+ return playerCollectibles
349
+ end
333
350
  function ____exports.getPlayerCloserThan(self, position, distance)
334
351
  for ____, player in ipairs(____exports.getPlayers(nil)) do
335
352
  if player.Position:Distance(position) <= distance then
@@ -367,14 +384,14 @@ function ____exports.getPlayerIndexVanilla(self, playerToFind)
367
384
  do
368
385
  local player = Isaac.GetPlayer(i)
369
386
  if player == nil then
370
- goto __continue62
387
+ goto __continue66
371
388
  end
372
389
  local playerHash = GetPtrHash(player)
373
390
  if playerHash == playerToFindHash then
374
391
  return i
375
392
  end
376
393
  end
377
- ::__continue62::
394
+ ::__continue66::
378
395
  i = i + 1
379
396
  end
380
397
  end
@@ -544,9 +561,9 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
544
561
  itemPool:RemoveCollectible(collectibleType)
545
562
  end
546
563
  repeat
547
- local ____switch124 = activeSlot
548
- local ____cond124 = ____switch124 == ActiveSlot.SLOT_PRIMARY
549
- if ____cond124 then
564
+ local ____switch128 = activeSlot
565
+ local ____cond128 = ____switch128 == ActiveSlot.SLOT_PRIMARY
566
+ if ____cond128 then
550
567
  do
551
568
  if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
552
569
  player:RemoveCollectible(primaryCollectibleType)
@@ -555,8 +572,8 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
555
572
  break
556
573
  end
557
574
  end
558
- ____cond124 = ____cond124 or ____switch124 == ActiveSlot.SLOT_SECONDARY
559
- if ____cond124 then
575
+ ____cond128 = ____cond128 or ____switch128 == ActiveSlot.SLOT_SECONDARY
576
+ if ____cond128 then
560
577
  do
561
578
  if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
562
579
  player:RemoveCollectible(primaryCollectibleType)
@@ -571,16 +588,16 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
571
588
  break
572
589
  end
573
590
  end
574
- ____cond124 = ____cond124 or ____switch124 == ActiveSlot.SLOT_POCKET
575
- if ____cond124 then
591
+ ____cond128 = ____cond128 or ____switch128 == ActiveSlot.SLOT_POCKET
592
+ if ____cond128 then
576
593
  do
577
594
  player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
578
595
  player:SetActiveCharge(charge, activeSlot)
579
596
  break
580
597
  end
581
598
  end
582
- ____cond124 = ____cond124 or ____switch124 == ActiveSlot.SLOT_POCKET2
583
- if ____cond124 then
599
+ ____cond128 = ____cond128 or ____switch128 == ActiveSlot.SLOT_POCKET2
600
+ if ____cond128 then
584
601
  do
585
602
  player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
586
603
  break
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.18",
3
+ "version": "1.2.19",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",