Made the components module work like textures and sound so that there's just one constant map of components.

This commit is contained in:
Zed A. Shaw 2025-06-02 23:33:59 -04:00
parent ab391aaa97
commit f208ca946e
10 changed files with 42 additions and 41 deletions

View file

@ -12,8 +12,7 @@ TEST_CASE("confirm component loading works", "[components]") {
std::vector<std::string> test_list{
"assets/enemies.json", "assets/items.json", "assets/devices.json"};
components::ComponentMap comp_map;
components::configure(comp_map);
components::init();
DinkyECS::World world;
for(auto test_data : test_list) {
@ -24,7 +23,7 @@ TEST_CASE("confirm component loading works", "[components]") {
auto& components = data["components"];
fmt::println("TEST COMPONENT: {} from file {}", key, test_data);
auto ent = world.entity();
components::configure_entity(comp_map, world, ent, components);
components::configure_entity(world, ent, components);
}
}
}
@ -42,21 +41,19 @@ TEST_CASE("make sure json_mods works", "[components]") {
}
// this then confirms everything else about the json conversion
ComponentMap comp_map;
components::configure(comp_map);
components::init();
DinkyECS::World world;
auto rat_king = world.entity();
components::configure_entity(comp_map, world, rat_king, config["RAT_KING"]["components"]);
components::configure_entity(world, rat_king, config["RAT_KING"]["components"]);
auto boss = world.get<BossFight>(rat_king);
REQUIRE(boss.stage == std::nullopt);
// now load the other one for the other way optional is used
auto devils_fingers = world.entity();
components::configure_entity(comp_map, world, devils_fingers, config["DEVILS_FINGERS"]["components"]);
components::configure_entity(world, devils_fingers, config["DEVILS_FINGERS"]["components"]);
auto boss2 = world.get<BossFight>(devils_fingers);
REQUIRE(boss2.stage != std::nullopt);
}