Config and save system almost there.
This commit is contained in:
parent
71bc97a016
commit
da63f006c2
4 changed files with 31 additions and 26 deletions
22
save.cpp
22
save.cpp
|
@ -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"]
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue