Flecs v3.2
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
builder.hpp
Go to the documentation of this file.
1
6#pragma once
7
8#include "../filter/builder_i.hpp"
9
10namespace flecs {
11namespace _ {
12 template <typename ... Components>
13 using rule_builder_base = builder<
14 rule, ecs_filter_desc_t, rule_builder<Components...>,
15 filter_builder_i, Components ...>;
16}
17
22template <typename ... Components>
23struct rule_builder final : _::rule_builder_base<Components...> {
24 rule_builder(flecs::world_t* world, const char *name = nullptr)
25 : _::rule_builder_base<Components...>(world)
26 {
27 _::sig<Components...>(world).populate(this);
28 if (name != nullptr) {
29 ecs_entity_desc_t entity_desc = {};
30 entity_desc.name = name;
31 entity_desc.sep = "::";
32 entity_desc.root_sep = "::";
33 this->m_desc.entity = ecs_entity_init(world, &entity_desc);
34 }
35 }
36};
37
38}
ecs_entity_t ecs_entity_init(ecs_world_t *world, const ecs_entity_desc_t *desc)
Find or create an entity.
flecs::rule_builder< Comps... > rule_builder(Args &&... args) const
Create a rule builder.
flecs::rule< Comps... > rule(flecs::rule_base &parent, Args &&... args) const
Create a subrule.
Used with ecs_entity_init.
Definition: flecs.h:876
const char * sep
Optional custom separator for hierarchical names.
Definition: flecs.h:886
const char * root_sep
Optional, used for identifiers relative to root.
Definition: flecs.h:890
const char * name
Name of the entity.
Definition: flecs.h:881
Used with ecs_filter_init.
Definition: flecs.h:961
Rule builder.
Definition: builder.hpp:23
The world.
Definition: world.hpp:132