-
Notifications
You must be signed in to change notification settings - Fork 54
/
main.cpp
39 lines (35 loc) · 919 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>
using namespace Ubpa::UECS;
struct Position { float val; };
struct Velocity { float val; };
struct MoverSystem {
static void OnCreate(World* w) {
std::cout << "OnCreate" << std::endl;
}
static void OnActivate(World* w) {
std::cout << "OnActivate" << std::endl;
}
static void OnUpdate(Schedule& schedule) {
std::cout << "OnUpdate" << std::endl;
schedule.RegisterEntityJob(
[](const Velocity* v, Position* p) {
p->val += v->val;
},
"Mover"
);
}
static void OnDeactivate(World* w) {
std::cout << "OnDeactivate" << std::endl;
}
static void OnDestroy(World* w) {
std::cout << "OnDestroy" << std::endl;
}
};
int main() {
World w;
w.entityMngr.cmptTraits.Register<Position, Velocity>();
auto [move] = w.systemMngr.systemTraits.Register<MoverSystem>();
w.entityMngr.Create(Ubpa::TypeIDs_of<Position, Velocity>);
w.systemMngr.Activate(move);
w.Update();
}