local playerInside = false

function onBegin()
    local heart = getFirstEntity("FakeHeart")
    local visible = heart and heart.Visible

    while playerInside and visible do
        visible = heart and heart.Visible

        wait(0)
    end

    if playerInside then
        disableRetry()

        wait(0.4)

        makeUnskippable()

        local room = getRoom()

        cassetteFlyTo(room.Bounds.Left + 1776, room.Bounds.Top + 544) --, room.Bounds.Left + 1576, room.Bounds.Top + 340)
        wait(1)

        while getPlayerState() == 21 do
            wait(1 / 60)
        end

        disableMovement()

        say("SpringCollab2020Cruor_cruor_03_bp_cassette")
    end
end

function onEnd(level, wasSkipped)
    enableMovement()
    enableRetry()

    if wasSkipped then
        local room = getRoom()

        teleportTo(room.Bounds.Left + 1776, room.Bounds.Top + 544)
    end
end

function onEnter()
    playerInside = true
end

function onLeave()
    playerInside = false
end