-
Notifications
You must be signed in to change notification settings - Fork 54
/
main.cpp
65 lines (55 loc) · 1.5 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
59
60
61
62
63
64
65
#include <UECS/UECS.hpp>
#include <iostream>
using namespace Ubpa;
using namespace Ubpa::UECS;
using namespace std;
struct RTDSystem {
static void OnUpdate(Schedule& schedule) {
std::array cmpts_write = {
AccessTypeID{ "LuaCmpt", AccessMode::WRITE }
};
std::array cmpts_read = {
AccessTypeID{ "LuaCmpt", AccessMode::LATEST }
};
CmptLocator locator_write(cmpts_write);
CmptLocator locator_read(cmpts_read);
schedule.RegisterEntityJob(
[](CmptsView cmpts) {
auto luaCmpt = cmpts.GetCmpt(AccessTypeID{ "LuaCmpt", AccessMode::WRITE });
double& val = *reinterpret_cast<double*>(luaCmpt.Ptr());
val = 520.;
},
"write",
true,
ArchetypeFilter{},
locator_write
);
schedule.RegisterEntityJob(
[](CmptsView cmpts) {
auto luaCmpt = cmpts.GetCmpt(AccessTypeID{ "LuaCmpt", AccessMode::LATEST });
const double& val = *reinterpret_cast<const double*>(luaCmpt.Ptr());
cout << "value : " << val << endl;
},
"read",
true,
ArchetypeFilter{},
locator_read
);
}
};
int main() {
TypeID type("LuaCmpt");
// LuaCmpt {
// number value;
// }
World w;
w.systemMngr.RegisterAndActivate<RTDSystem>();
w.entityMngr.cmptTraits
.RegisterSize(type, 8)
.RegisterDefaultConstructor(type, [](void*, std::pmr::memory_resource*) { cout << "construct" << endl; })
.RegisterDestructor(type, [](void*) { cout << "destruct" << endl; });
auto e = w.entityMngr.Create(Ubpa::TempTypeIDs{ type });
w.Update();
cout << w.DumpUpdateJobGraph() << endl;
return 0;
}