-
Notifications
You must be signed in to change notification settings - Fork 54
/
main.cpp
58 lines (49 loc) · 1.1 KB
/
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <UECS/UECS.hpp>
#include <iostream>
using namespace Ubpa;
using namespace Ubpa::UECS;
using namespace std;
struct A {};
struct B {};
struct C {};
struct MySystem {
static void OnUpdate(Schedule& schedule) {
schedule.RegisterEntityJob(
[](World* w, Entity e, const A* a, const B* b, CommandBufferPtr cb) {
cb->AddCommand(
[e, w]() {
if (!w->entityMngr.Have(e, TypeID_of<C>)) {
cout << "Attach C" << endl;
w->entityMngr.Attach(e, TypeIDs_of<C>);
}
}
);
},
"AB"
);
schedule.RegisterEntityJob(
[](World* w, Entity e, const A* a, const B* b, const C* c, CommandBufferPtr cb) {
cb->AddCommand(
[e, w]() {
if (w->entityMngr.Have(e, TypeID_of<C>)) {
cout << "Dettach C" << endl;
w->entityMngr.Detach(e, TypeIDs_of<C>);
}
}
);
},
"ABC"
);
}
};
int main() {
World w;
w.entityMngr.cmptTraits.Register<A, B, C>();
w.systemMngr.RegisterAndActivate<MySystem>();
w.entityMngr.Create(Ubpa::TypeIDs_of<A, B>);
w.Update();
w.Update();
w.Update();
cout << w.DumpUpdateJobGraph() << endl;
return 0;
}