isaacscript-common 1.2.290 → 1.2.291
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.
|
@@ -27,21 +27,28 @@ function postPEffectUpdate(self, player)
|
|
|
27
27
|
if not hasSubscriptions(nil) then
|
|
28
28
|
return
|
|
29
29
|
end
|
|
30
|
-
local
|
|
30
|
+
local activeItemMap = defaultMapGetPlayer(nil, v.run.playersActiveItemMap, player)
|
|
31
|
+
local chargeMap = defaultMapGetPlayer(nil, v.run.playersActiveChargeMap, player)
|
|
31
32
|
for ____, activeSlot in ipairs(getEnumValues(nil, ActiveSlot)) do
|
|
32
33
|
do
|
|
34
|
+
local currentActiveItem = player:GetActiveItem()
|
|
35
|
+
local previousActiveItem = activeItemMap:getAndSetDefault(activeSlot, currentActiveItem)
|
|
36
|
+
activeItemMap:set(activeSlot, currentActiveItem)
|
|
37
|
+
if currentActiveItem ~= previousActiveItem then
|
|
38
|
+
goto __continue10
|
|
39
|
+
end
|
|
33
40
|
local currentCharge = getTotalCharge(nil, player, activeSlot)
|
|
34
41
|
local previousCharge = chargeMap:getAndSetDefault(activeSlot, currentCharge)
|
|
35
42
|
chargeMap:set(activeSlot, currentCharge)
|
|
36
43
|
if playerRecentlyCollidedWithBulb(nil, player) then
|
|
37
|
-
goto
|
|
44
|
+
goto __continue10
|
|
38
45
|
end
|
|
39
46
|
if currentCharge < previousCharge then
|
|
40
47
|
local collectibleType = player:GetActiveItem(activeSlot)
|
|
41
48
|
postItemDischargeFire(nil, player, collectibleType, activeSlot)
|
|
42
49
|
end
|
|
43
50
|
end
|
|
44
|
-
::
|
|
51
|
+
::__continue10::
|
|
45
52
|
end
|
|
46
53
|
end
|
|
47
54
|
function playerRecentlyCollidedWithBulb(self, player)
|
|
@@ -66,13 +73,22 @@ function preNPCCollision(self, npc, collider)
|
|
|
66
73
|
mapSetPlayer(nil, v.room.playersBulbLastCollisionFrame, player, gameFrameCount)
|
|
67
74
|
end
|
|
68
75
|
v = {
|
|
69
|
-
run = {
|
|
70
|
-
|
|
71
|
-
|
|
76
|
+
run = {
|
|
77
|
+
playersActiveItemMap = __TS__New(
|
|
78
|
+
DefaultMap,
|
|
79
|
+
function() return __TS__New(
|
|
80
|
+
DefaultMap,
|
|
81
|
+
function(____, _playerIndex, collectibleType) return collectibleType end
|
|
82
|
+
) end
|
|
83
|
+
),
|
|
84
|
+
playersActiveChargeMap = __TS__New(
|
|
72
85
|
DefaultMap,
|
|
73
|
-
function(
|
|
74
|
-
|
|
75
|
-
|
|
86
|
+
function() return __TS__New(
|
|
87
|
+
DefaultMap,
|
|
88
|
+
function(____, _playerIndex, charge) return charge end
|
|
89
|
+
) end
|
|
90
|
+
)
|
|
91
|
+
},
|
|
76
92
|
room = {playersBulbLastCollisionFrame = __TS__New(Map)}
|
|
77
93
|
}
|
|
78
94
|
function ____exports.postItemDischargeCallbackInit(self, mod)
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
2
|
import { PocketItemDescription } from "../types/PocketItemDescription";
|
|
3
|
+
/**
|
|
4
|
+
* Helper function to get the `PocketItemSlot` that the player's pocket active item is in, if any.
|
|
5
|
+
* Returns undefined if the player does not have a pocket active item.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getActivePocketItemSlot(player: EntityPlayer): PocketItemSlot | undefined;
|
|
3
8
|
export declare function getFirstCardOrPill(player: EntityPlayer): PocketItemDescription | undefined;
|
|
4
9
|
/**
|
|
5
10
|
* Use this helper function as a workaround for the `EntityPlayer.GetPocketItem` method not working
|
|
@@ -43,6 +43,15 @@ function ____exports.getPocketItems(self, player)
|
|
|
43
43
|
end
|
|
44
44
|
return pocketItems
|
|
45
45
|
end
|
|
46
|
+
function ____exports.getActivePocketItemSlot(self, player)
|
|
47
|
+
local pocketItems = ____exports.getPocketItems(nil, player)
|
|
48
|
+
for ____, pocketItem in ipairs(pocketItems) do
|
|
49
|
+
if pocketItem.type == PocketItemType.ACTIVE_ITEM then
|
|
50
|
+
return pocketItem.slot
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
return nil
|
|
54
|
+
end
|
|
46
55
|
function ____exports.getFirstCardOrPill(self, player)
|
|
47
56
|
local pocketItems = ____exports.getPocketItems(nil, player)
|
|
48
57
|
return __TS__ArrayFind(
|