dummy systems

This commit is contained in:
2018-12-26 18:36:41 +07:00
parent 7460832dc6
commit f77becd269
2 changed files with 73 additions and 6 deletions

View File

@@ -318,7 +318,6 @@ TEST_CASE("registry") {
}
}
}
SECTION("for_joined_components") {
{
ecs::registry w;
@@ -365,4 +364,38 @@ TEST_CASE("registry") {
}
}
}
SECTION("systems") {
{
class movement_system : public ecs::system {
public:
void process(ecs::registry& owner) override {
owner.for_joined_components<position_c, velocity_c>([](
ecs::entity e, position_c& p, const velocity_c& v)
{
p.x += v.x;
p.y += v.y;
});
}
};
ecs::registry w;
w.add_system<movement_system>();
auto e1 = w.create_entity();
auto e2 = w.create_entity();
e1.assign_component<position_c>(1, 2);
e1.assign_component<velocity_c>(3, 4);
e2.assign_component<position_c>(5, 6);
e2.assign_component<velocity_c>(7, 8);
w.process_systems();
REQUIRE(e1.get_component<position_c>().x == 1 + 3);
REQUIRE(e1.get_component<position_c>().y == 2 + 4);
REQUIRE(e2.get_component<position_c>().x == 5 + 7);
REQUIRE(e2.get_component<position_c>().y == 6 + 8);
}
}
}