#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(entity, {config["damage"]}); } else if(comp_type == "LightSource") { world.set(entity, {config["strength"], config["radius"]}); } else if(comp_type == "Loot") { world.set(entity, {config["amount"]}); } else if(comp_type == "Tile") { world.set(entity, {config["chr"]}); } else if(comp_type == "EnemyConfig") { world.set(entity, {config["hearing_distance"]}); } else if(comp_type == "Combat") { world.set(entity, {config["hp"], config["damage"]}); } else if(comp_type == "Curative") { world.set(entity, {config["hp"]}); } else if(comp_type == "Motion") { world.set(entity, {config["dx"], config["dy"], config["random"]}); } else if(comp_type == "Device") { Device device{.config=config, .events={}}; device.configure_events(comp["events"]); world.set(entity, device); } else { dbc::sentinel(fmt::format("ITEM COMPONENT TYPE MISSING: {}", std::string(comp_type))); } // json config variable dies } } }