isaacscript-common 1.2.110 → 1.2.111

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,97 +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, getPlayerThatIsNoLongerHoldingAnItem, storePickupsInMap, 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 players = getPlayers(nil)
39
- checkPickupsPurchased(nil, pickupsWithPrice, players)
40
- storePickupsInMap(nil, pickupsWithPrice)
41
- storePlayersInMap(nil, players)
42
- end
43
- function checkPickupsPurchased(self, nonCollectiblesWithPrice, players)
44
- local pickupIndexes = __TS__ArrayMap(
45
- nonCollectiblesWithPrice,
46
- function(____, pickup) return pickup.Index end
47
- )
48
- local pickupIndexSet = __TS__New(Set, pickupIndexes)
49
- for ____, ____value in __TS__Iterator(v.room.pickupMap:entries()) do
50
- local index = ____value[1]
51
- local pickupDescription = ____value[2]
52
- do
53
- if pickupIndexSet:has(index) then
54
- goto __continue9
55
- end
56
- local player = getPlayerThatIsNoLongerHoldingAnItem(nil, players)
57
- if player ~= nil then
58
- postPurchaseFire(nil, player, pickupDescription)
59
- end
60
- end
61
- ::__continue9::
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)
62
31
  end
63
32
  end
64
- function getPlayerThatIsNoLongerHoldingAnItem(self, players)
65
- return __TS__ArrayFind(
66
- players,
67
- function(____, player)
68
- local playerHoldingItemNow = player:IsHoldingItem()
69
- local playerIndex = getPlayerIndex(nil, player)
70
- local playerHoldingItemOnLastFrame = v.room.playersHoldingItemOnLastFrameMap:getAndSetDefault(playerIndex)
71
- return not playerHoldingItemOnLastFrame and playerHoldingItemNow
72
- 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
73
38
  )
74
- end
75
- function storePickupsInMap(self, nonCollectiblesWithPrice)
76
- v.room.pickupMap:clear()
77
- for ____, pickup in ipairs(nonCollectiblesWithPrice) do
78
- local pickupDescription = getPickupDescription(nil, pickup)
79
- v.room.pickupMap:set(pickup.Index, pickupDescription)
80
- end
81
- end
82
- function storePlayersInMap(self, players)
83
- for ____, player in ipairs(players) do
84
- local playerIndex = getPlayerIndex(nil, player)
85
- local holdingItem = player:IsHoldingItem()
86
- v.room.playersHoldingItemOnLastFrameMap:set(playerIndex, holdingItem)
39
+ if disappearingPickup ~= nil then
40
+ postPurchaseFire(nil, player, disappearingPickup)
87
41
  end
88
42
  end
89
- v = {room = {
90
- pickupMap = __TS__New(Map),
91
- playersHoldingItemOnLastFrameMap = __TS__New(DefaultMap, false)
92
- }}
43
+ v = {room = {playersHoldingItemOnLastFrameMap = __TS__New(DefaultMap, false)}}
93
44
  function ____exports.postPurchaseCallbackInit(self, mod)
94
45
  saveDataManager(nil, "postPurchase", v, hasSubscriptions)
95
- mod:AddCallback(ModCallbacks.MC_POST_UPDATE, postUpdate)
46
+ mod:AddCallback(ModCallbacks.MC_POST_PEFFECT_UPDATE, postPEffectUpdate)
96
47
  end
97
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
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.110",
3
+ "version": "1.2.111",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",