#include "../../config/events.lua"
#include "../../script/helpers/entity.lua"

function draw()
    if disabled then return end
    if GetInt("level.garage.open") == 0 then
        SetPlayerScreen(0)
        ClearKey("level.screen")
        local screen = UiGetScreen()
        SetScreenEnabled(screen, false)
        cEntity:EnqueueDeletion(screen)
        local shape = GetScreenShape(screen)
        if shape > 0 then
            local body = GetShapeBody(shape)
            if body > 0 and body ~= GetWorldBody() then
                cEntity:EnqueueDeletion(body)
            else
                cEntity:EnqueueDeletion(shape)
            end
        end
        disabled = true
        TriggerEvent(EVENTS.FORCE_DELETE)
    end
end
