#include <open_engine/core.hpp>
#include <control_layer.hpp>
#include <e_sandbox2d.hpp>
#include <editor.hpp>

ControlLayer::ControlLayer(OpenEngine::Ref<OpenEngine::Layer> layer)
    : active_layer(layer), OpenEngine::Layer("control_layer")
{
}

void ControlLayer::OnUpdate()
{
}

bool ControlLayer::StopRunning(OpenEngine::KeyPressedEvent& event)
{
    if (event.GetKeyCode() == OE_KEY_ESCAPE) {
        OpenEngine::Application::Get().Close();

        return true;
    }

    return false;
}


void ControlLayer::OnEvent(OpenEngine::Event& event)
{
    OpenEngine::EventDispatcher dispatcher(event);

    dispatcher.Dispatch<OpenEngine::KeyPressedEvent>(BIND_EVENT_FN(ControlLayer::StopRunning));
}

void ControlLayer::OnImGuiRender()
{
}

void ControlLayer::OnAttach()
{
}

void ControlLayer::OnDetach()
{
}
