BROKEN: Big refactoring happening, so it compiles but game does not run and the tests fail.

This commit is contained in:
Zed A. Shaw 2025-02-08 14:03:09 -05:00
parent 96efc990c1
commit 9e91c71125
25 changed files with 128 additions and 526 deletions

View file

@ -1,45 +0,0 @@
#include "components.hpp"
namespace components {
void configure(DinkyECS::World &world, DinkyECS::Entity entity, json& entity_data) {
for(auto &comp : entity_data["components"]) {
json& config = comp["config"];
const string comp_type = comp["type"];
if(comp_type == "Weapon") {
world.set<Weapon>(entity, {config["damage"]});
} else if(comp_type == "LightSource") {
world.set<LightSource>(entity, {config["strength"], config["radius"]});
} else if(comp_type == "Loot") {
world.set<Loot>(entity, {config["amount"]});
} else if(comp_type == "Tile") {
world.set<Tile>(entity, {
config["chr"],
entity_data["foreground"][0],
entity_data["foreground"][1],
entity_data["foreground"][2],
entity_data["background"][0],
entity_data["background"][1],
entity_data["background"][2]});
} else if(comp_type == "EnemyConfig") {
world.set<EnemyConfig>(entity, {config["hearing_distance"]});
} else if(comp_type == "Combat") {
world.set<Combat>(entity, {config["hp"], config["damage"]});
} else if(comp_type == "Curative") {
world.set<Curative>(entity, {config["hp"]});
} else if(comp_type == "Motion") {
world.set<Motion>(entity, {config["dx"], config["dy"], config["random"]});
} else if(comp_type == "Device") {
Device device{.config=config, .events={}};
device.configure_events(comp["events"]);
world.set<Device>(entity, device);
} else {
dbc::sentinel(fmt::format("ITEM COMPONENT TYPE MISSING: {}",
std::string(comp_type)));
}
// json config variable dies
}
}
}