RGON: Fixed bag content tracking desyncs

This commit is contained in:
Wofsauge committed 2024-01-12 21:38:59 +01:00
1 parent f3871a1d1c
commit 91f88f160f
2 files changed
+23 -6

No files matched your search

+6 -6
View File
@@ -569,7 +569,7 @@ EID:AddCallback(ModCallbacks.MC_PRE_PICKUP_COLLISION, function(_, pickup,collide
end) end)
-- Formerly a MC_POST_PICKUP_UPDATE, but moved to this so that it's only called when we own a bag -- Formerly a MC_POST_PICKUP_UPDATE, but moved to this so that it's only called when we own a bag
local function checkForPickups() function EID:BoCCheckForPickups()
for _,pickup in ipairs(Isaac.FindByType(EntityType.ENTITY_PICKUP, -1, -1, false, false)) do for _,pickup in ipairs(Isaac.FindByType(EntityType.ENTITY_PICKUP, -1, -1, false, false)) do
if pickup:GetSprite():GetAnimation() == "Collect" and not pickupsCollected[pickup.Index] then if pickup:GetSprite():GetAnimation() == "Collect" and not pickupsCollected[pickup.Index] then
pickupsCollected[pickup.Index] = true pickupsCollected[pickup.Index] = true
@@ -606,7 +606,7 @@ end)
--Tainted Cain "hold to craft" check --Tainted Cain "hold to craft" check
local holdCounter = 0 local holdCounter = 0
local icount = 0 local icount = 0
local function trackBagHolding() function EID:BoCTrackBagHolding()
if not IsTaintedCain() then return end if not IsTaintedCain() then return end
local isCardHold = Input.IsActionPressed(ButtonAction.ACTION_PILLCARD, EID.bagPlayer.ControllerIndex) local isCardHold = Input.IsActionPressed(ButtonAction.ACTION_PILLCARD, EID.bagPlayer.ControllerIndex)
local animationName = EID.bagPlayer:GetSprite():GetAnimation() local animationName = EID.bagPlayer:GetSprite():GetAnimation()
@@ -639,7 +639,7 @@ local function shiftBagContent()
EID.BoC.BagItems = newContent EID.BoC.BagItems = newContent
end end
-- only Tainted Cain's consumable slot bag can have its ingredients shifted -- only Tainted Cain's consumable slot bag can have its ingredients shifted
local function detectBagContentShift() function EID:BoCDetectBagContentShift()
if Input.IsActionTriggered(ButtonAction.ACTION_DROP, EID.bagPlayer.ControllerIndex) and IsTaintedCain() then if Input.IsActionTriggered(ButtonAction.ACTION_DROP, EID.bagPlayer.ControllerIndex) and IsTaintedCain() then
shiftBagContent() shiftBagContent()
end end
@@ -914,9 +914,9 @@ function EID:handleBagOfCraftingUpdating()
lastSeedUsed = curSeed lastSeedUsed = curSeed
-- watch for holding the Craft button, and pressing the ingredient shift button -- watch for holding the Craft button, and pressing the ingredient shift button
trackBagHolding() EID:BoCTrackBagHolding()
detectBagContentShift() EID:BoCDetectBagContentShift()
if EID.GameRenderCount % 2 == 0 then checkForPickups() end if EID.GameRenderCount % 2 == 0 then EID:BoCCheckForPickups() end
-- Check for Hide/Preview hotkeys; prevent them from triggering while in MCM -- Check for Hide/Preview hotkeys; prevent them from triggering while in MCM
if not ModConfigMenu or not ModConfigMenu.IsVisible then if not ModConfigMenu or not ModConfigMenu.IsVisible then
+17
View File
@@ -81,3 +81,20 @@ function EID:OnMenuRender()
end end
EID:AddCallback(ModCallbacks.MC_MAIN_MENU_RENDER, EID.OnMenuRender) EID:AddCallback(ModCallbacks.MC_MAIN_MENU_RENDER, EID.OnMenuRender)
---------------------------BAG OF CRAFTING-------------------------------
-- Directly read bag of crafting content
function EID:BoCCheckForPickups()
EID.BoC.BagItems = {}
for key, value in pairs(EID.bagPlayer:GetBagOfCraftingContent()) do
if value <= 0 then return end -- no more items in the bag
EID.BoC.BagItems[key] = value
end
end
-- Deactivate manual tracking code
function EID:BoCTrackBagHolding() end
function EID:BoCDetectBagContentShift() end