Track recently touched items

This commit is contained in:
Buurazu authored and GitHub committed 2022-06-10 20:00:27 -04:00
1 parent 02c32bd2a9
commit 04477507bb
1 file changed
+11 -2
+11 -2
View File
@@ -1624,7 +1624,9 @@ function EID:evaluateTransformationProgress(transformation)
end end
-- Watch for a player's queued item (holding an item over their head) to track active item touches -- Watch for a player's queued item (holding an item over their head) to track active item touches
-- Used for Transformation Progress and for tracking Recently Touched Items
EID.PlayerItemInteractions = {} EID.PlayerItemInteractions = {}
EID.RecentlyTouchedItems = {}
local hadQueuedItem = {} local hadQueuedItem = {}
function EID:evaluateQueuedItems() function EID:evaluateQueuedItems()
--initialize the interactions table for all players if it isn't already --initialize the interactions table for all players if it isn't already
@@ -1633,6 +1635,7 @@ function EID:evaluateQueuedItems()
if not EID.PlayerItemInteractions[i] then if not EID.PlayerItemInteractions[i] then
EID.PlayerItemInteractions[i] = {LastTouch = 0, actives = {}, pills = {}, altActives = {}, altPills = {}} EID.PlayerItemInteractions[i] = {LastTouch = 0, actives = {}, pills = {}, altActives = {}, altPills = {}}
end end
EID.RecentlyTouchedItems[i] = EID.RecentlyTouchedItems[i] or {}
end end
for i = 0, game:GetNumPlayers() - 1 do for i = 0, game:GetNumPlayers() - 1 do
local player = Isaac.GetPlayer(i) local player = Isaac.GetPlayer(i)
@@ -1648,7 +1651,10 @@ function EID:evaluateQueuedItems()
EID.PlayerItemInteractions[i].LastTouch = 0 EID.PlayerItemInteractions[i].LastTouch = 0
end end
if not player.QueuedItem.Touched and player.QueuedItem.Item and player.QueuedItem.Item.Type == ItemType.ITEM_ACTIVE then if not player.QueuedItem.Touched and player.QueuedItem.Item then
EID.PlayerItemInteractions[i].LastTouch = game:GetFrameCount()
if player.QueuedItem.Item.Type == ItemType.ITEM_ACTIVE then
local itemID = tostring(player.QueuedItem.Item.ID) local itemID = tostring(player.QueuedItem.Item.ID)
-- A new active item was touched; initiate its touch count to 0 for all players -- A new active item was touched; initiate its touch count to 0 for all players
-- (Fixes co-op bugs, compared to only initiating it for the toucher) -- (Fixes co-op bugs, compared to only initiating it for the toucher)
@@ -1665,7 +1671,10 @@ function EID:evaluateQueuedItems()
end end
EID.ForceRefreshCache = true EID.ForceRefreshCache = true
activesTable[itemID] = activesTable[itemID] + 1 activesTable[itemID] = activesTable[itemID] + 1
EID.PlayerItemInteractions[i].LastTouch = game:GetFrameCount() elseif player.QueuedItem.Item.Type ~= ItemType.ITEM_TRINKET then
-- Put non-active item pickups into the recent item list, for printing in the Item Reminder
table.insert(EID.RecentlyTouchedItems[i], player.QueuedItem.Item.ID)
end
end end
end end
end end