ryondinkus / duke

isaac duke mod smile
1 stars 0 forks source link

Weird bug where sometimes Duke cannot collide with pickups #132

Closed ryondinkus closed 2 years ago

ryondinkus commented 2 years ago

No idea how this happens. We have a few OBS clips about it happening. Seemingly random.

ryondinkus commented 2 years ago

ADDITIONAL INFO: Something is setting the pickup's EntityCollisionClass to ENTCOLL_NONE. This still happens with no other mods on so its 100% us.

The one place we set a pickup's collision class to ENTCOLL_NONE is DukeHelpers.AnimateHeartPickup() in helpers/players.lua.

if pickup.Price == 0 then
    pickup:GetSprite():Play("Collect")
    local function removePickupCallback()
        pickup.EntityCollisionClass = EntityCollisionClass.ENTCOLL_NONE

        local sprite = pickup:GetSprite()
        if sprite:IsFinished("Collect") then
            pickup:Remove()
            dukeMod:RemoveCallback(ModCallbacks.MC_POST_PICKUP_UPDATE, removePickupCallback)
        end
    end

    dukeMod:AddCallback(ModCallbacks.MC_POST_PICKUP_UPDATE, removePickupCallback)

Basically, we start the animation and set collision to ENTCOLL_NONE. Then, we set a callback to remove the pickup once its Collect animation finishes. This is good, BUT should the animation get interrupted and not finish, then it never gets removed but its collision stays ENTCOLL_NONE. In my latest push, there's a fix that just sets collision to ENTCOLL_PLAYERONLY if its not playing the Collect animation (only runs within the removePickupCallback)

Since the conditions to set this thing off are unknown, I won't close this until we can get a good few runs without the bug. I played two runs that both encountered the bug, so its relatively common enough that we should know after a few runs.