-
Notifications
You must be signed in to change notification settings - Fork 54
/
main.cpp
39 lines (32 loc) · 832 Bytes
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <UECS/UECS.hpp>
#include <iostream>
using namespace Ubpa::UECS;
struct Position { float val{ 0.f }; };
struct Velocity { float val{ 1.f }; };
struct MoverSystem {
static void OnUpdate(Schedule& schedule) {
schedule.RegisterEntityJob(
[](const Velocity* v, Position* p) {
p->val += v->val;
},
"Mover"
);
schedule.RegisterEntityJob(
[](const Velocity* v, const Position* p) {
std::cout << "v:" << v->val << std::endl;
std::cout << "p:" << p->val << std::endl;
},
"Print"
);
}
};
int main() {
World w;
w.entityMngr.cmptTraits.Register<Position, Velocity>();
w.systemMngr.RegisterAndActivate<MoverSystem>();
w.entityMngr.Create(Ubpa::TypeIDs_of<Position, Velocity>);
World cpW = w;
cpW.Update();
w.entityMngr.Create(Ubpa::TypeIDs_of<Position, Velocity>);
cpW.Update();
}