BROKEN: Big refactoring happening, so it compiles but game does not run and the tests fail.
This commit is contained in:
parent
96efc990c1
commit
9e91c71125
25 changed files with 128 additions and 526 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue