-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
57 lines (48 loc) · 993 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <UECS/World.h>
#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) {
w->AddCommand(
[e, w]() {
if (!w->entityMngr.Have(e, TypeID_of<C>)) {
cout << "Attach C" << endl;
w->entityMngr.Attach<C>(e);
}
}
);
},
"AB"
);
schedule.RegisterEntityJob(
[](World* w, Entity e, const A* a, const B* b, const C* c) {
w->AddCommand(
[e, w]() {
if (w->entityMngr.Have(e, TypeID_of<C>)) {
cout << "Dettach C" << endl;
w->entityMngr.Detach<C>(e);
}
}
);
},
"ABC"
);
}
};
int main() {
World w;
w.systemMngr.RegisterAndActivate<MySystem>();
w.entityMngr.Create<A, B>();
w.Update();
w.Update();
w.Update();
cout << w.DumpUpdateJobGraph() << endl;
return 0;
}