-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDummy.cpp
More file actions
64 lines (50 loc) · 1.58 KB
/
Dummy.cpp
File metadata and controls
64 lines (50 loc) · 1.58 KB
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
#include <iostream>
#include "sim/Simulation.h"
using namespace sim;
struct Component1 {
int a;
};
struct Component2 {
int b;
};
struct SystemA {
void operator()(const event::SimStart) const {
std::cout << "System A starting" << std::endl;
}
void operator()(const event::SimEnd) const {
std::cout << "System A ending" << std::endl;
}
void operator()(const event::Cycle) const {
std::cout << "[A]: Simple cycle" << std::endl;
}
void operator()(const event::Cycle, Context ctx) const {
ctx.view<Component1>().for_each([&](const Entity entity, const Component1& a) {
std::cout << "[A]: Cycle " << ctx.cycle() << " "
"for entity #" << entity.id() << " "
"with TestComponent1(" << a.a << ")" << std::endl;
});
}
};
struct SystemB {
void operator()(const event::Cycle, Context ctx) const {
for (Entity entity: ctx.view<Component1, Component2>()) {
std::cout << "[B]: Cycle " << ctx.cycle() << " "
"for entity #" << entity.id() << " "
"with TestComponent1(" << entity.get<Component1>().a << ") "
"and TestComponent2(" << entity.get<Component2>().b << ")" << std::endl;
}
}
};
int main() {
auto s = Simulation<SystemA>()
.with_systems<SystemB>();
s.create()
.emplace<Component1>(1);
s.create()
.emplace<Component2>(2);
s.create()
.emplace<Component1>(10)
.emplace<Component2>(20);
s.run(3);
return 0;
}