#pragma once

#include "dinkyecs.hpp"
#include "lights.hpp"
#include "map.hpp"
#include <vector>
#include <memory>
#include "spatialmap.hpp"
#include "components.hpp"
#include "gui/boss_fight_ui.hpp"

using std::shared_ptr;

struct GameLevel {
  size_t index;
  DinkyECS::Entity player;
  shared_ptr<Map> map = nullptr;
  shared_ptr<DinkyECS::World> world = nullptr;
  shared_ptr<lighting::LightRender> lights = nullptr;
  shared_ptr<SpatialMap> collision = nullptr;
};

struct LevelScaling {
  int map_width=20;
  int map_height=20;
};

class LevelManager {
  public:
  std::vector<GameLevel> $levels;
  size_t $current_level = 0;

  LevelManager();

  shared_ptr<gui::BossFightUI> create_bossfight(shared_ptr<DinkyECS::World> prev_world);
  size_t create_level(shared_ptr<DinkyECS::World> prev_world = nullptr);
  GameLevel &next();
  GameLevel &previous();
  GameLevel &current();
  size_t current_index() { return $current_level; }
  GameLevel &get(size_t index);
  LevelScaling scale_level();

  DinkyECS::Entity spawn_enemy(const std::string& named);
};
