Config and save system almost there.

This commit is contained in:
Zed A. Shaw 2024-11-05 21:33:28 -05:00
parent 71bc97a016
commit da63f006c2
4 changed files with 31 additions and 26 deletions

View file

@ -2,6 +2,7 @@
#include <fstream>
#include "dbc.hpp"
#include <fmt/core.h>
#include "config.hpp"
using namespace components;
@ -62,4 +63,25 @@ void save::from_file(std::string path, DinkyECS::World &world_out) {
inject<Position>(world_out, save_data.position);
inject<Combat>(world_out, save_data.combat);
inject<Motion>(world_out, save_data.motion);
save::load_configs(world_out);
}
void save::load_configs(DinkyECS::World &world) {
Config config("./assets/config.json");
world.set_the<Config>(config);
auto map = config["map"];
world.set_the<MapConfig>({
map["WALL_TILE"],
map["FLOOR_TILE"],
map["PLAYER_TILE"],
map["ENEMY_TILE"],
map["BG_TILE"]
});
auto enemy = config["enemy"];
world.set_the<EnemyConfig>({
enemy["HEARING_DISTANCE"]
});
}