1#include <each_callback.h>
2#include <iostream>
3
4
5
6
7struct Position {
8 double x, y;
9};
10
11struct Velocity {
12 double x, y;
13};
14
15int main(int, char *[]) {
17
19
20 .
each([](Position& p,
const Velocity& v) {
21 p.x += v.x;
22 p.y += v.y;
23 std::cout << "{" << p.x << ", " << p.y << "}\n";
24 });
25
26
28 .set<Position>({10, 20})
29 .set<Velocity>({1, 2});
30
32 .set<Position>({10, 20})
33 .set<Velocity>({3, 4});
34
35
37 .set<Position>({10, 20});
38
39
41
42
43
44
45}
flecs::system system(flecs::entity e) const
Upcast an entity to a system.
flecs::entity entity(Args &&... args) const
Create an entity.
system & run(Func &&func)
Replace the system's run callback.
void each(Func &&func) const
Iterate over all entities with components in the argument list of the function.