#pragma once

#include "algos/dinkyecs.hpp"
#include "graphics/lights.hpp"
#include "game/map.hpp"
#include <memory>
#include "algos/spatialmap.hpp"

namespace components {
  struct Position;
}

namespace GameDB {
  struct Level {
    size_t index = 0;
    DinkyECS::Entity player = DinkyECS::NONE;
    std::shared_ptr<Map> map = nullptr;
    std::shared_ptr<DinkyECS::World> world = nullptr;
    std::shared_ptr<lighting::LightRender> lights = nullptr;
    std::shared_ptr<SpatialMap> collision = nullptr;
  };

  Level& create_level();

  void init();
  void reset();

  Level &current_level();
  void new_level(std::shared_ptr<DinkyECS::World> prev_world);
  std::shared_ptr<DinkyECS::World> current_world();
  components::Position& player_position();
  DinkyECS::Entity the_player();

  std::shared_ptr<DinkyECS::World> clone_load_world(std::shared_ptr<DinkyECS::World> prev_world);
  void load_configs(DinkyECS::World &world);
  void register_level(Level level);
}
