#include "save.hpp"
#include <fstream>
#include "dbc.hpp"
#include <fmt/core.h>
#include "config.hpp"
#include <filesystem>

using namespace components;
using namespace fmt;

template<typename CompT>
inline void extract(DinkyECS::World &world, std::map<DinkyECS::Entity, CompT> &into) {
  auto from_world = world.entity_map_for<CompT>();
  for(auto [entity, value] : from_world) {
    into[entity] = std::any_cast<CompT>(value);
  }
}

void save::to_file(fs::path path, DinkyECS::World &world, Map &map) {
  (void)path;
  (void)world;
  (void)map;
}


void save::from_file(fs::path path, DinkyECS::World &world_out, Map &map_out) {
  (void)path;
  (void)world_out;
  (void)map_out;
}

void save::load_configs(DinkyECS::World &world) {
  Config game("./assets/config.json");
  Config enemies("./assets/enemies.json");
  Config items("./assets/items.json");
  Config tiles("./assets/tiles.json");
  Config devices("./assets/devices.json");

  world.set_the<GameConfig>({
    game, enemies, items, tiles, devices
  });
}
