isaacscript-common 1.2.109 → 1.2.112

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.
@@ -1,132 +1,48 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____lualib = require("lualib_bundle")
3
- local Map = ____lualib.Map
4
3
  local __TS__New = ____lualib.__TS__New
5
- local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
6
- local __TS__ArrayMap = ____lualib.__TS__ArrayMap
7
- local Set = ____lualib.Set
8
- local __TS__Iterator = ____lualib.__TS__Iterator
9
4
  local __TS__ArrayFind = ____lualib.__TS__ArrayFind
10
5
  local ____exports = {}
11
- local hasSubscriptions, postUpdate, checkPickupsPurchased, checkCollectiblesPurchased, getPlayerThatIsNoLongerHoldingAnItem, storePickupsInMap, storeCollectiblesInMap, storePlayersInMap, v
6
+ local hasSubscriptions, postPEffectUpdate, playerPickedUpNewItem, v
12
7
  local ____exports = require("features.saveDataManager.exports")
13
8
  local saveDataManager = ____exports.saveDataManager
14
9
  local ____pickups = require("functions.pickups")
15
10
  local getPickups = ____pickups.getPickups
16
11
  local ____player = require("functions.player")
17
12
  local getPlayerIndex = ____player.getPlayerIndex
18
- local getPlayers = ____player.getPlayers
19
13
  local ____DefaultMap = require("types.DefaultMap")
20
14
  local DefaultMap = ____DefaultMap.DefaultMap
21
- local ____PickupDescription = require("types.PickupDescription")
22
- local getPickupDescription = ____PickupDescription.getPickupDescription
23
15
  local ____postPurchase = require("callbacks.subscriptions.postPurchase")
24
16
  local postPurchaseFire = ____postPurchase.postPurchaseFire
25
17
  local postPurchaseHasSubscriptions = ____postPurchase.postPurchaseHasSubscriptions
26
18
  function hasSubscriptions(self)
27
19
  return postPurchaseHasSubscriptions(nil)
28
20
  end
29
- function postUpdate(self)
21
+ function postPEffectUpdate(self, player)
30
22
  if not hasSubscriptions(nil) then
31
23
  return
32
24
  end
33
- local pickups = getPickups(nil)
34
- local pickupsWithPrice = __TS__ArrayFilter(
35
- pickups,
36
- function(____, pickup) return pickup:Exists() and pickup.Price ~= 0 end
37
- )
38
- local nonCollectiblesWithPrice = __TS__ArrayFilter(
39
- pickupsWithPrice,
40
- function(____, pickup) return pickup.Variant ~= PickupVariant.PICKUP_COLLECTIBLE end
41
- )
42
- local collectiblesWithPrice = __TS__ArrayFilter(
43
- pickupsWithPrice,
44
- function(____, pickup) return pickup.Variant == PickupVariant.PICKUP_COLLECTIBLE end
45
- )
46
- local players = getPlayers(nil)
47
- checkPickupsPurchased(nil, nonCollectiblesWithPrice, players)
48
- checkCollectiblesPurchased(nil, collectiblesWithPrice, players)
49
- storePickupsInMap(nil, nonCollectiblesWithPrice)
50
- storeCollectiblesInMap(nil, collectiblesWithPrice)
51
- storePlayersInMap(nil, players)
52
- end
53
- function checkPickupsPurchased(self, nonCollectiblesWithPrice, players)
54
- local pickupIndexes = __TS__ArrayMap(
55
- nonCollectiblesWithPrice,
56
- function(____, pickup) return pickup.Index end
57
- )
58
- local pickupIndexSet = __TS__New(Set, pickupIndexes)
59
- for ____, ____value in __TS__Iterator(v.room.pickupMap:entries()) do
60
- local index = ____value[1]
61
- local pickupDescription = ____value[2]
62
- do
63
- if pickupIndexSet:has(index) then
64
- goto __continue11
65
- end
66
- local player = getPlayerThatIsNoLongerHoldingAnItem(nil, players)
67
- if player ~= nil then
68
- postPurchaseFire(nil, player, pickupDescription)
69
- end
70
- end
71
- ::__continue11::
72
- end
73
- end
74
- function checkCollectiblesPurchased(self, collectiblesWithPrice, players)
75
- for ____, collectible in ipairs(collectiblesWithPrice) do
76
- do
77
- local pickupDescription = v.room.collectibleMap:get(collectible.Index)
78
- if pickupDescription == nil then
79
- goto __continue16
80
- end
81
- if pickupDescription.subType ~= collectible.SubType and collectible.SubType == CollectibleType.COLLECTIBLE_NULL then
82
- local player = getPlayerThatIsNoLongerHoldingAnItem(nil, players)
83
- if player ~= nil then
84
- postPurchaseFire(nil, player, pickupDescription)
85
- end
86
- end
87
- end
88
- ::__continue16::
25
+ local isHoldingItem = player:IsHoldingItem()
26
+ local playerIndex = getPlayerIndex(nil, player)
27
+ local wasHoldingItemOnLastFrame = v.room.playersHoldingItemOnLastFrameMap:getAndSetDefault(playerIndex)
28
+ v.room.playersHoldingItemOnLastFrameMap:set(playerIndex, isHoldingItem)
29
+ if not wasHoldingItemOnLastFrame and isHoldingItem then
30
+ playerPickedUpNewItem(nil, player)
89
31
  end
90
32
  end
91
- function getPlayerThatIsNoLongerHoldingAnItem(self, players)
92
- return __TS__ArrayFind(
93
- players,
94
- function(____, player)
95
- local playerHoldingItemNow = player:IsHoldingItem()
96
- local playerIndex = getPlayerIndex(nil, player)
97
- local playerHoldingItemOnLastFrame = v.room.playersHoldingItemOnLastFrameMap:getAndSetDefault(playerIndex)
98
- return not playerHoldingItemOnLastFrame and playerHoldingItemNow
99
- end
33
+ function playerPickedUpNewItem(self, player)
34
+ local pickups = getPickups(nil)
35
+ local disappearingPickup = __TS__ArrayFind(
36
+ pickups,
37
+ function(____, pickup) return not pickup:Exists() and pickup.Price ~= 0 end
100
38
  )
101
- end
102
- function storePickupsInMap(self, nonCollectiblesWithPrice)
103
- v.room.pickupMap:clear()
104
- for ____, pickup in ipairs(nonCollectiblesWithPrice) do
105
- local pickupDescription = getPickupDescription(nil, pickup)
106
- v.room.pickupMap:set(pickup.Index, pickupDescription)
107
- end
108
- end
109
- function storeCollectiblesInMap(self, collectiblesWithPrice)
110
- v.room.collectibleMap:clear()
111
- for ____, collectible in ipairs(collectiblesWithPrice) do
112
- local pickupDescription = getPickupDescription(nil, collectible)
113
- v.room.collectibleMap:set(collectible.Index, pickupDescription)
114
- end
115
- end
116
- function storePlayersInMap(self, players)
117
- for ____, player in ipairs(players) do
118
- local playerIndex = getPlayerIndex(nil, player)
119
- local holdingItem = player:IsHoldingItem()
120
- v.room.playersHoldingItemOnLastFrameMap:set(playerIndex, holdingItem)
39
+ if disappearingPickup ~= nil then
40
+ postPurchaseFire(nil, player, disappearingPickup)
121
41
  end
122
42
  end
123
- v = {room = {
124
- pickupMap = __TS__New(Map),
125
- collectibleMap = __TS__New(Map),
126
- playersHoldingItemOnLastFrameMap = __TS__New(DefaultMap, false)
127
- }}
43
+ v = {room = {playersHoldingItemOnLastFrameMap = __TS__New(DefaultMap, false)}}
128
44
  function ____exports.postPurchaseCallbackInit(self, mod)
129
45
  saveDataManager(nil, "postPurchase", v, hasSubscriptions)
130
- mod:AddCallback(ModCallbacks.MC_POST_UPDATE, postUpdate)
46
+ mod:AddCallback(ModCallbacks.MC_POST_PEFFECT_UPDATE, postPEffectUpdate)
131
47
  end
132
48
  return ____exports
@@ -1,3 +1,2 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
- import { PickupDescription } from "../../types/PickupDescription";
3
- export declare type PostPurchaseCallbackType = (player: EntityPlayer, pickupDescription: PickupDescription) => void;
2
+ export declare type PostPurchaseCallbackType = (player: EntityPlayer, pickup: EntityPickup) => void;
@@ -9,10 +9,10 @@ end
9
9
  function ____exports.postPurchaseRegister(self, callback, pickupVariant, pickupSubType)
10
10
  __TS__ArrayPush(subscriptions, {callback, pickupVariant, pickupSubType})
11
11
  end
12
- function ____exports.postPurchaseFire(self, player, pickupDescription)
12
+ function ____exports.postPurchaseFire(self, player, pickup)
13
13
  for ____, ____value in ipairs(subscriptions) do
14
14
  local callback = ____value[1]
15
- callback(nil, player, pickupDescription)
15
+ callback(nil, player, pickup)
16
16
  end
17
17
  end
18
18
  return ____exports
@@ -208,6 +208,17 @@ export declare function getSoulHearts(player: EntityPlayer): int;
208
208
  * return undefined.
209
209
  */
210
210
  export declare function getSubPlayerParent(subPlayer: EntitySubPlayer): EntityPlayer | undefined;
211
+ /**
212
+ * Helper function to determine how many heart containers that Tainted Magdalene has that will not
213
+ * be automatically depleted over time. By default, this is 2, but this function will return 4 so
214
+ * that it is consistent with the `player.GetHearts` and `player.GetMaxHearts` methods.
215
+ *
216
+ * If Tainted Magdalene has Birthright, she will gained an additional non-temporary heart container.
217
+ *
218
+ * This function does not validate whether or not the provided player is Tainted Magdalene; that
219
+ * should be accomplished before invoking this function.
220
+ */
221
+ export declare function getTaintedMagdaleneNonTemporaryMaxHearts(player: EntityPlayer): 4 | 6;
211
222
  /**
212
223
  * Helper function to return the active charge and the battery charge combined. This is useful
213
224
  * because you are not able to set the battery charge directly.
@@ -503,6 +503,10 @@ function ____exports.getSoulHearts(self, player)
503
503
  local blackHearts = ____exports.getBlackHearts(nil, player)
504
504
  return soulHearts - blackHearts
505
505
  end
506
+ function ____exports.getTaintedMagdaleneNonTemporaryMaxHearts(self, player)
507
+ local hasBirthright = player:HasCollectible(CollectibleType.COLLECTIBLE_BIRTHRIGHT)
508
+ return hasBirthright and 6 or 4
509
+ end
506
510
  function ____exports.getTotalCharge(self, player, activeSlot)
507
511
  local activeCharge = player:GetActiveCharge(activeSlot)
508
512
  local batteryCharge = player:GetBatteryCharge(activeSlot)
@@ -597,9 +601,9 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
597
601
  itemPool:RemoveCollectible(collectibleType)
598
602
  end
599
603
  repeat
600
- local ____switch127 = activeSlot
601
- local ____cond127 = ____switch127 == ActiveSlot.SLOT_PRIMARY
602
- if ____cond127 then
604
+ local ____switch128 = activeSlot
605
+ local ____cond128 = ____switch128 == ActiveSlot.SLOT_PRIMARY
606
+ if ____cond128 then
603
607
  do
604
608
  if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
605
609
  player:RemoveCollectible(primaryCollectibleType)
@@ -608,8 +612,8 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
608
612
  break
609
613
  end
610
614
  end
611
- ____cond127 = ____cond127 or ____switch127 == ActiveSlot.SLOT_SECONDARY
612
- if ____cond127 then
615
+ ____cond128 = ____cond128 or ____switch128 == ActiveSlot.SLOT_SECONDARY
616
+ if ____cond128 then
613
617
  do
614
618
  if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
615
619
  player:RemoveCollectible(primaryCollectibleType)
@@ -624,16 +628,16 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
624
628
  break
625
629
  end
626
630
  end
627
- ____cond127 = ____cond127 or ____switch127 == ActiveSlot.SLOT_POCKET
628
- if ____cond127 then
631
+ ____cond128 = ____cond128 or ____switch128 == ActiveSlot.SLOT_POCKET
632
+ if ____cond128 then
629
633
  do
630
634
  player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
631
635
  player:SetActiveCharge(charge, activeSlot)
632
636
  break
633
637
  end
634
638
  end
635
- ____cond127 = ____cond127 or ____switch127 == ActiveSlot.SLOT_POCKET2
636
- if ____cond127 then
639
+ ____cond128 = ____cond128 or ____switch128 == ActiveSlot.SLOT_POCKET2
640
+ if ____cond128 then
637
641
  do
638
642
  player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
639
643
  break
@@ -21,4 +21,4 @@ export declare function spawnCollectible(collectibleType: CollectibleType | int,
21
21
  * Instead, this function arbitrarily spawns a collectible with
22
22
  * `CollectibleType.COLLECTIBLE_SAD_ONION`, and then converts it to an empty pedestal afterward.
23
23
  */
24
- export declare function spawnEmptyCollectible(position: Vector, seed?: number): void;
24
+ export declare function spawnEmptyCollectible(position: Vector, seed?: number): EntityPickup;
@@ -60,5 +60,6 @@ function ____exports.spawnEmptyCollectible(self, position, seed)
60
60
  true
61
61
  )
62
62
  setCollectibleEmpty(nil, collectible)
63
+ return collectible
63
64
  end
64
65
  return ____exports
package/dist/index.d.ts CHANGED
@@ -90,7 +90,6 @@ export * from "./types/JSONSpawn";
90
90
  export * from "./types/ModCallbacksCustom";
91
91
  export * from "./types/ModUpgraded";
92
92
  export * from "./types/PickingUpItem";
93
- export * from "./types/PickupDescription";
94
93
  export * from "./types/PillEffectClass";
95
94
  export * from "./types/PillEffectType";
96
95
  export * from "./types/PlayerHealth";
package/dist/index.lua CHANGED
@@ -674,14 +674,6 @@ do
674
674
  end
675
675
  end
676
676
  end
677
- do
678
- local ____export = require("types.PickupDescription")
679
- for ____exportKey, ____exportValue in pairs(____export) do
680
- if ____exportKey ~= "default" then
681
- ____exports[____exportKey] = ____exportValue
682
- end
683
- end
684
- end
685
677
  do
686
678
  local ____export = require("types.PillEffectClass")
687
679
  for ____exportKey, ____exportValue in pairs(____export) do
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.109",
3
+ "version": "1.2.112",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",