#pragma once
#include "levelmanager.hpp"
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/System/Clock.hpp>
#include "stats.hpp"
#include <guecs/ui.hpp>
#include "gui/overlay_ui.hpp"
#include "gui/debug_ui.hpp"
#include "raycaster.hpp"
#include <optional>

namespace gui {

  class MainUI {
    public:
    int $compass_dir = 0;
    bool $needs_render = true;
    sf::Clock $clock;
    sf::RenderWindow& $window;
    GameLevel $level;
    OverlayUI $overlay_ui;
    Raycaster $rayview;

    MainUI(sf::RenderWindow& window);

    void mouse(int x, int y, bool hover);
    void debug();
    void render_debug();

    void plan_rotate(int dir, float amount);
    std::optional<Point> play_rotate();
    std::optional<components::Position> play_move();
    Point plan_move(int dir, bool strafe);
    void abort_plan();
    void update_level(GameLevel level);
    DinkyECS::Entity camera_aim();

    void init();
    void render();
    void dirty();
    lel::Cell overlay_cell(const std::string& name);

    void dead_entity(DinkyECS::Entity entity);
  };
}
