1#include <each_w_iter_callback.h>
2#include <iostream>
3
4
5
6
7
8
9struct Position {
10 double x, y;
11};
12
13struct Velocity {
14 double x, y;
15};
16
17int main(int, char *[]) {
19
21
24 p.x += v.x;
25 p.y += v.y;
26 std::cout << e.
name() <<
": {" << p.x <<
", " << p.y <<
"}\n";
27 });
28
29
31 .set<Position>({10, 20})
32 .set<Velocity>({1, 2});
33
35 .set<Position>({10, 20})
36 .set<Velocity>({3, 4});
37
38
40 .set<Position>({10, 20});
41
42
44
45
46
47
48}
flecs::system system(flecs::entity e) const
Upcast an entity to a system.
flecs::entity entity(Args &&... args) const
Create an entity.
flecs::string_view name() const
Return the entity name.
Class for iterating over query results.
flecs::entity entity(size_t row) const
Obtain a mutable handle to the entity being iterated over.
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.