|
|
@ -192,54 +192,11 @@ TEST_CASE("confirm copying and constants", "[ecs-constants]") { |
|
|
|
REQUIRE(player2.eid == player_info.eid); |
|
|
|
REQUIRE(player2.eid == player_info.eid); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TEST_CASE("can destroy all entity", "[ecs-destroy]") { |
|
|
|
TEST_CASE("test serialization with nlohmann::json", "[ecs-serialize]") { |
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
DinkyECS::ComponentMap component_map; |
|
|
|
|
|
|
|
DinkyECS::Component<Position>(component_map); |
|
|
|
|
|
|
|
DinkyECS::Component<Velocity>(component_map); |
|
|
|
|
|
|
|
DinkyECS::Component<Motion>(component_map); |
|
|
|
|
|
|
|
DinkyECS::Component<Gravity>(component_map); |
|
|
|
|
|
|
|
DinkyECS::Component<DaGUI>(component_map); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto data = R"( |
|
|
|
|
|
|
|
[ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
"_type": "Position", |
|
|
|
|
|
|
|
"location": { |
|
|
|
|
|
|
|
"x": 10, |
|
|
|
|
|
|
|
"y": 5 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
"_type": "Motion", |
|
|
|
|
|
|
|
"dx": 0, |
|
|
|
|
|
|
|
"dy": 1 |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
"_type": "Velocity", |
|
|
|
|
|
|
|
"x": 0.1, |
|
|
|
|
|
|
|
"y": 10.2 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
)"_json; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DinkyECS::World world; |
|
|
|
DinkyECS::World world; |
|
|
|
DinkyECS::Entity ent1 = world.entity(); |
|
|
|
auto entity = world.entity(); |
|
|
|
DinkyECS::Entity ent2 = world.entity(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DinkyECS::configure(component_map, world, ent1, data); |
|
|
|
|
|
|
|
DinkyECS::configure(component_map, world, ent2, data); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
world.query<Position, Motion>([&](const auto ent, auto &pos, auto &motion) { |
|
|
|
world.set<Velocity>(entity, {10,10}); |
|
|
|
fmt::println("entity: {}; position={},{} and motion={},{} motion.random={}", |
|
|
|
world.set<Gravity>(entity, {1}); |
|
|
|
ent, pos.location.x, pos.location.y, |
|
|
|
world.set<Motion>(entity, {0,0}); |
|
|
|
motion.dx, motion.dy, motion.random); |
|
|
|
|
|
|
|
REQUIRE(pos.location.x == 10); |
|
|
|
|
|
|
|
REQUIRE(pos.location.y == 5); |
|
|
|
|
|
|
|
REQUIRE(motion.dx == 0); |
|
|
|
|
|
|
|
REQUIRE(motion.dy == 1); |
|
|
|
|
|
|
|
REQUIRE(motion.random == false); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|