Flecs v3.2
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
entity_builder.inl
Go to the documentation of this file.
1
14Self& unit(
15 const char *symbol,
16 flecs::entity_t prefix = 0,
17 flecs::entity_t base = 0,
18 flecs::entity_t over = 0,
19 int32_t factor = 0,
20 int32_t power = 0)
21{
22 ecs_unit_desc_t desc = {};
23 desc.entity = this->m_id;
24 desc.symbol = const_cast<char*>(symbol); /* safe, will be copied in */
25 desc.base = base;
26 desc.over = over;
27 desc.prefix = prefix;
28 desc.translation.factor = factor;
29 desc.translation.power = power;
30 ecs_unit_init(this->world(), &desc);
31
32 return to_base();
33}
34
36Self& unit(
37 flecs::entity_t prefix = 0,
38 flecs::entity_t base = 0,
39 flecs::entity_t over = 0,
40 int32_t factor = 0,
41 int32_t power = 0)
42{
43 ecs_unit_desc_t desc = {};
44 desc.entity = this->m_id;
45 desc.base = base;
46 desc.over = over;
47 desc.prefix = prefix;
48 desc.translation.factor = factor;
49 desc.translation.power = power;
50 ecs_unit_init(this->world(), &desc);
51
52 return to_base();
53}
54
57 const char *symbol,
58 int32_t factor = 0,
59 int32_t power = 0)
60{
61 ecs_unit_prefix_desc_t desc = {};
62 desc.entity = this->m_id;
63 desc.symbol = const_cast<char*>(symbol); /* safe, will be copied in */
64 desc.translation.factor = factor;
65 desc.translation.power = power;
66 ecs_unit_prefix_init(this->world(), &desc);
67
68 return to_base();
69}
70
72Self& quantity(flecs::entity_t quantity) {
73 ecs_add_pair(this->world(), this->id(), flecs::Quantity, quantity);
74 return to_base();
75}
76
78template <typename Quantity>
79Self& quantity() {
80 return this->quantity(_::cpp_type<Quantity>::id(this->world()));
81}
82
84Self& quantity() {
85 ecs_add_id(this->world(), this->id(), flecs::Quantity);
86 return to_base();
87}
88
void ecs_add_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
Add a (component) id to an entity.
FLECS_API ecs_entity_t ecs_unit_prefix_init(ecs_world_t *world, const ecs_unit_prefix_desc_t *desc)
Create a new unit prefix.
FLECS_API ecs_entity_t ecs_unit_init(ecs_world_t *world, const ecs_unit_desc_t *desc)
Create a new unit.
Self & quantity(flecs::entity_t quantity)
Add quantity to unit.
Self & unit(flecs::entity_t prefix=0, flecs::entity_t base=0, flecs::entity_t over=0, int32_t factor=0, int32_t power=0)
Make entity a derived unit.
Self & unit_prefix(const char *symbol, int32_t factor=0, int32_t power=0)
Make entity a derived unit.
Self & quantity()
Make entity a unity prefix.
Self & quantity()
Make entity a quantity.
Self & unit(const char *symbol, flecs::entity_t prefix=0, flecs::entity_t base=0, flecs::entity_t over=0, int32_t factor=0, int32_t power=0)
Make entity a unit.
Used with ecs_unit_init().
Definition meta.h:858
ecs_entity_t base
Base unit, e.g.
Definition meta.h:869
ecs_entity_t over
Over unit, e.g.
Definition meta.h:872
const char * symbol
Unit symbol, e.g.
Definition meta.h:863
ecs_entity_t prefix
Prefix indicating order of magnitude relative to the derived unit.
Definition meta.h:883
ecs_unit_translation_t translation
Translation to apply to derived unit (optional)
Definition meta.h:875
ecs_entity_t entity
Existing entity to associate with unit (optional)
Definition meta.h:860
Used with ecs_unit_prefix_init().
Definition meta.h:893
ecs_entity_t entity
Existing entity to associate with unit prefix (optional)
Definition meta.h:895
const char * symbol
Unit symbol, e.g.
Definition meta.h:898
ecs_unit_translation_t translation
Translation to apply to derived unit (optional)
Definition meta.h:901
int32_t power
Power to apply to factor (e.g.
Definition meta.h:453
int32_t factor
Factor to apply (e.g.
Definition meta.h:452
The world.
Definition world.hpp:132