Track recently touched items
This commit is contained in:
1 parent
02c32bd2a9
commit
04477507bb
1 file changed
+27
-18
+27
-18
@@ -1624,7 +1624,9 @@ function EID:evaluateTransformationProgress(transformation)
|
||||
end
|
||||
|
||||
-- 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.RecentlyTouchedItems = {}
|
||||
local hadQueuedItem = {}
|
||||
function EID:evaluateQueuedItems()
|
||||
--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
|
||||
EID.PlayerItemInteractions[i] = {LastTouch = 0, actives = {}, pills = {}, altActives = {}, altPills = {}}
|
||||
end
|
||||
EID.RecentlyTouchedItems[i] = EID.RecentlyTouchedItems[i] or {}
|
||||
end
|
||||
for i = 0, game:GetNumPlayers() - 1 do
|
||||
local player = Isaac.GetPlayer(i)
|
||||
@@ -1647,25 +1650,31 @@ function EID:evaluateQueuedItems()
|
||||
else
|
||||
EID.PlayerItemInteractions[i].LastTouch = 0
|
||||
end
|
||||
|
||||
if not player.QueuedItem.Touched and player.QueuedItem.Item and player.QueuedItem.Item.Type == ItemType.ITEM_ACTIVE then
|
||||
local itemID = tostring(player.QueuedItem.Item.ID)
|
||||
-- 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)
|
||||
for j = 0, game:GetNumPlayers() - 1 do
|
||||
local player = Isaac.GetPlayer(j)
|
||||
EID.PlayerItemInteractions[j].actives[itemID] = EID.PlayerItemInteractions[j].actives[itemID] or 0
|
||||
EID.PlayerItemInteractions[j].altActives[itemID] = EID.PlayerItemInteractions[j].altActives[itemID] or 0
|
||||
end
|
||||
|
||||
-- Dead Tainted Lazarus exceptions
|
||||
local activesTable = EID.PlayerItemInteractions[i].actives
|
||||
if player:GetPlayerType() == 38 then
|
||||
activesTable = EID.PlayerItemInteractions[i].altActives or activesTable
|
||||
end
|
||||
EID.ForceRefreshCache = true
|
||||
activesTable[itemID] = activesTable[itemID] + 1
|
||||
|
||||
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)
|
||||
-- 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)
|
||||
for j = 0, game:GetNumPlayers() - 1 do
|
||||
local player = Isaac.GetPlayer(j)
|
||||
EID.PlayerItemInteractions[j].actives[itemID] = EID.PlayerItemInteractions[j].actives[itemID] or 0
|
||||
EID.PlayerItemInteractions[j].altActives[itemID] = EID.PlayerItemInteractions[j].altActives[itemID] or 0
|
||||
end
|
||||
|
||||
-- Dead Tainted Lazarus exceptions
|
||||
local activesTable = EID.PlayerItemInteractions[i].actives
|
||||
if player:GetPlayerType() == 38 then
|
||||
activesTable = EID.PlayerItemInteractions[i].altActives or activesTable
|
||||
end
|
||||
EID.ForceRefreshCache = true
|
||||
activesTable[itemID] = activesTable[itemID] + 1
|
||||
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
|
||||
|
||||
Reference in new issue
Block a user