1#include <typed_prefabs.h>
2#include <iostream>
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17struct Turret {
18 struct Base {};
19 struct Head {};
20};
21
22struct Railgun {
23 struct Beam {};
24};
25
26int main() {
28
29
31 ecs.
prefab<Turret::Base>();
32 ecs.
prefab<Turret::Head>();
33
34 ecs.
prefab<Railgun>().is_a<Turret>();
35 ecs.
prefab<Railgun::Beam>();
36
37
39
40
44
45 std::cout <<
"instance base: " << inst_base.
path() <<
"\n";
46 std::cout <<
"instance head: " << inst_head.
path() <<
"\n";
47 std::cout <<
"instance beam: " << inst_beam.
path() <<
"\n";
48
49
50
51
52
53}
flecs::entity entity(Args &&... args) const
Create an entity.
flecs::entity prefab(const char *name=nullptr) const
Create a prefab that's associated with a type.
const Self & is_a(entity_t second) const
Shortcut for add(IsA, entity).
flecs::string path(const char *sep="::", const char *init_sep="::") const
Return the entity path.
flecs::entity lookup(const char *path, bool search_path=false) const
Lookup an entity by name.