#pragma once

#include "map.hpp"
#include "dinkyecs.hpp"
#include "components.hpp"
#include "spatialmap.hpp"

class WorldBuilder {
  public:
  Map& $map;
  components::ComponentMap& $components;
  SpatialMap $collision;

  WorldBuilder(Map &map, components::ComponentMap& components) :
    $map(map),
    $components(components)
  { }

  void generate_map();

  DinkyECS::Entity configure_entity_in_map(DinkyECS::World &world, nlohmann::json &entity_data, Point pos);

  DinkyECS::Entity configure_entity_in_room(DinkyECS::World &world, nlohmann::json &entity_data, int in_room);

  bool find_open_spot(Point& pos_out);
  void place_entities(DinkyECS::World &world);
  void generate(DinkyECS::World &world);
  void randomize_entities(DinkyECS::World &world, components::GameConfig &config);
  void place_stairs(DinkyECS::World& world, components::GameConfig& config);
  void configure_starting_items(DinkyECS::World &world);
};