Flecs v3.1
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
8namespace flecs
9{
10
14template <typename Self>
16
17 using entity_view::entity_view;
18
24 template <typename T>
25 Self& add() {
26 flecs_static_assert(is_flecs_constructible<T>::value,
27 "cannot default construct type: add T::T() or use emplace<T>()");
28 ecs_add_id(this->m_world, this->m_id, _::cpp_type<T>::id(this->m_world));
29 return to_base();
30 }
31
37 Self& add(id_t component) {
38 ecs_add_id(this->m_world, this->m_id, component);
39 return to_base();
40 }
41
48 Self& add(entity_t first, entity_t second) {
49 ecs_add_pair(this->m_world, this->m_id, first, second);
50 return to_base();
51 }
52
59 template<typename First, typename Second>
60 Self& add() {
61 return this->add<First>(_::cpp_type<Second>::id(this->m_world));
62 }
63
70 template<typename First, typename Second, if_not_t< is_enum<Second>::value > = 0>
71 Self& add(Second second) {
72 flecs_static_assert(is_flecs_constructible<First>::value,
73 "cannot default construct type: add T::T() or use emplace<T>()");
74 return this->add(_::cpp_type<First>::id(this->m_world), second);
75 }
76
84 template<typename First, typename Second, if_t< is_enum<Second>::value > = 0>
85 Self& add(Second constant) {
86 flecs_static_assert(is_flecs_constructible<First>::value,
87 "cannot default construct type: add T::T() or use emplace<T>()");
88 const auto& et = enum_type<Second>(this->m_world);
89 return this->add<First>(et.entity(constant));
90 }
91
98 template<typename Second>
99 Self& add_second(flecs::entity_t first) {
100 return this->add(first, _::cpp_type<Second>::id(this->m_world));
101 }
102
109 Self& add_if(bool cond, flecs::id_t component) {
110 if (cond) {
111 return this->add(component);
112 } else {
113 return this->remove(component);
114 }
115 }
116
123 template <typename T>
124 Self& add_if(bool cond) {
125 if (cond) {
126 return this->add<T>();
127 } else {
128 return this->remove<T>();
129 }
130 }
131
139 Self& add_if(bool cond, flecs::entity_t first, flecs::entity_t second) {
140 if (cond) {
141 return this->add(first, second);
142 } else {
143 /* If second is 0 or if relationship is exclusive, use wildcard for
144 * second which will remove all instances of the relationship.
145 * Replacing 0 with Wildcard will make it possible to use the second
146 * as the condition. */
147 if (!second || ecs_has_id(this->m_world, first, flecs::Exclusive)) {
148 second = flecs::Wildcard;
149 }
150 return this->remove(first, second);
151 }
152 }
153
161 template <typename First>
162 Self& add_if(bool cond, flecs::entity_t second) {
163 return this->add_if(cond, _::cpp_type<First>::id(this->m_world), second);
164 }
165
173 template <typename First, typename Second>
174 Self& add_if(bool cond) {
175 return this->add_if<First>(cond, _::cpp_type<Second>::id(this->m_world));
176 }
177
184 template <typename E, if_t< is_enum<E>::value > = 0>
185 Self& add_if(bool cond, E constant) {
186 const auto& et = enum_type<E>(this->m_world);
187 return this->add_if<E>(cond, et.entity(constant));
188 }
189
194 Self& is_a(entity_t second) {
195 return this->add(flecs::IsA, second);
196 }
197
202 template <typename T>
203 Self& is_a() {
204 return this->add(flecs::IsA, _::cpp_type<T>::id(this->m_world));
205 }
206
211 Self& child_of(entity_t second) {
212 return this->add(flecs::ChildOf, second);
213 }
214
219 Self& depends_on(entity_t second) {
220 return this->add(flecs::DependsOn, second);
221 }
222
227 Self& slot_of(entity_t second) {
228 return this->add(flecs::SlotOf, second);
229 }
230
233 Self& slot() {
234 ecs_check(ecs_get_target(m_world, m_id, flecs::ChildOf, 0),
235 ECS_INVALID_PARAMETER, "add ChildOf pair before using slot()");
236 return this->slot_of(this->target(flecs::ChildOf));
237 error:
238 return to_base();
239 }
240
245 template <typename T>
246 Self& child_of() {
247 return this->child_of(_::cpp_type<T>::id(this->m_world));
248 }
249
254 template <typename T>
255 Self& depends_on() {
256 return this->depends_on(_::cpp_type<T>::id(this->m_world));
257 }
258
263 template <typename T>
264 Self& slot_of() {
265 return this->slot_of(_::cpp_type<T>::id(this->m_world));
266 }
267
272 template <typename T, if_not_t< is_enum<T>::value > = 0>
273 Self& remove() {
274 ecs_remove_id(this->m_world, this->m_id, _::cpp_type<T>::id(this->m_world));
275 return to_base();
276 }
277
282 Self& remove(entity_t entity) {
283 ecs_remove_id(this->m_world, this->m_id, entity);
284 return to_base();
285 }
286
293 Self& remove(entity_t first, entity_t second) {
294 ecs_remove_pair(this->m_world, this->m_id, first, second);
295 return to_base();
296 }
297
304 template<typename First, typename Second>
305 Self& remove() {
306 return this->remove<First>(_::cpp_type<Second>::id(this->m_world));
307 }
308
315 template<typename First, typename Second, if_not_t< is_enum<Second>::value > = 0>
316 Self& remove(Second second) {
317 return this->remove(_::cpp_type<First>::id(this->m_world), second);
318 }
319
326 template<typename Second>
327 Self& remove_second(flecs::entity_t first) {
328 return this->remove(first, _::cpp_type<Second>::id(this->m_world));
329 }
330
337 template<typename First, typename Second, if_t< is_enum<Second>::value > = 0>
338 Self& remove(Second constant) {
339 const auto& et = enum_type<Second>(this->m_world);
340 flecs::entity_t second = et.entity(constant);
341 return this->remove<First>(second);
342 }
343
351 Self& override(flecs::id_t id) {
352 return this->add(ECS_OVERRIDE | id);
353 }
354
361 Self& override(flecs::entity_t first, flecs::entity_t second) {
362 return this->override(ecs_pair(first, second));
363 }
364
370 template <typename T>
371 Self& override() {
372 return this->override(_::cpp_type<T>::id(this->m_world));
373 }
374
381 template <typename First>
382 Self& override(flecs::entity_t second) {
383 return this->override(_::cpp_type<First>::id(this->m_world), second);
384 }
385
392 template <typename First, typename Second>
393 Self& override() {
394 return this->override<First>(_::cpp_type<Second>::id(this->m_world));
395 }
396
402 template <typename T>
403 Self& set_override(const T& val) {
404 this->override<T>();
405 return this->set<T>(val);
406 }
407
413 template <typename T>
414 Self& set_override(T&& val) {
415 this->override<T>();
416 return this->set<T>(FLECS_FWD(val));
417 }
418
425 template <typename First>
426 Self& set_override(flecs::entity_t second, const First& val) {
427 this->override<First>(second);
428 return this->set<First>(second, val);
429 }
430
437 template <typename First>
438 Self& set_override(flecs::entity_t second, First&& val) {
439 this->override<First>(second);
440 return this->set<First>(second, FLECS_FWD(val));
441 }
442
449 template <typename First, typename Second, typename P = pair<First, Second>,
450 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value> = 0>
451 Self& set_override(const A& val) {
452 this->override<First, Second>();
453 return this->set<First, Second>(val);
454 }
455
462 template <typename First, typename Second, typename P = pair<First, Second>,
463 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value> = 0>
464 Self& set_override(A&& val) {
465 this->override<First, Second>();
466 return this->set<First, Second>(FLECS_FWD(val));
467 }
468
474 template <typename T, typename ... Args>
475 Self& emplace_override(Args&&... args) {
476 this->override<T>();
477
478 flecs::emplace<T>(this->m_world, this->m_id,
479 _::cpp_type<T>::id(this->m_world), FLECS_FWD(args)...);
480
481 return to_base();
482 }
483
490 template <typename First, typename Second, typename P = pair<First, Second>,
491 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value> = 0,
492 typename ... Args>
493 Self& emplace_override(Args&&... args) {
494 this->override<First, Second>();
495
496 flecs::emplace<A>(this->m_world, this->m_id,
497 ecs_pair(_::cpp_type<First>::id(this->m_world),
498 _::cpp_type<Second>::id(this->m_world)),
499 FLECS_FWD(args)...);
500
501 return to_base();
502 }
503
513 template <typename E, if_t< is_enum<E>::value > = 0>
514 Self& add(E value) {
515 flecs::entity_t first = _::cpp_type<E>::id(this->m_world);
516 const auto& et = enum_type<E>(this->m_world);
517 flecs::entity_t second = et.entity(value);
518 return this->add(first, second);
519 }
520
526 template <typename E, if_t< is_enum<E>::value > = 0>
527 Self& remove() {
528 flecs::entity_t first = _::cpp_type<E>::id(this->m_world);
529 return this->remove(first, flecs::Wildcard);
530 }
531
536 Self& enable() {
537 ecs_enable(this->m_world, this->m_id, true);
538 return to_base();
539 }
540
545 Self& disable() {
546 ecs_enable(this->m_world, this->m_id, false);
547 return to_base();
548 }
549
557 Self& enable(flecs::id_t id, bool toggle = true) {
558 ecs_enable_id(this->m_world, this->m_id, id, toggle);
559 return to_base();
560 }
561
567 template<typename T>
568 Self& enable() {
569 return this->enable(_::cpp_type<T>::id());
570 }
571
578 Self& enable(flecs::id_t first, flecs::id_t second) {
579 return this->enable(ecs_pair(first, second));
580 }
581
588 template<typename First>
589 Self& enable(flecs::id_t second) {
590 return this->enable(_::cpp_type<First>::id(), second);
591 }
592
599 template<typename First, typename Second>
600 Self& enable() {
601 return this->enable<First>(_::cpp_type<Second>::id());
602 }
603
610 Self& disable(flecs::id_t id) {
611 return this->enable(id, false);
612 }
613
619 template<typename T>
620 Self& disable() {
621 return this->disable(_::cpp_type<T>::id());
622 }
623
630 Self& disable(flecs::id_t first, flecs::id_t second) {
631 return this->disable(ecs_pair(first, second));
632 }
633
640 template<typename First>
641 Self& disable(flecs::id_t second) {
642 return this->disable(_::cpp_type<First>::id(), second);
643 }
644
651 template<typename First, typename Second>
652 Self& disable() {
653 return this->disable<First>(_::cpp_type<Second>::id());
654 }
655
656 Self& set_ptr(entity_t comp, size_t size, const void *ptr) {
657 ecs_set_id(this->m_world, this->m_id, comp, size, ptr);
658 return to_base();
659 }
660
661 Self& set_ptr(entity_t comp, const void *ptr) {
662 const flecs::Component *cptr = ecs_get(
663 this->m_world, comp, EcsComponent);
664
665 /* Can't set if it's not a component */
666 ecs_assert(cptr != NULL, ECS_INVALID_PARAMETER, NULL);
667
668 return set_ptr(comp, cptr->size, ptr);
669 }
670
671 template<typename T, if_t<
672 !is_callable<T>::value && is_actual<T>::value> = 0 >
673 Self& set(T&& value) {
674 flecs::set<T>(this->m_world, this->m_id, FLECS_FWD(value));
675 return to_base();
676 }
677
678 template<typename T, if_t<
679 !is_callable<T>::value && is_actual<T>::value > = 0>
680 Self& set(const T& value) {
681 flecs::set<T>(this->m_world, this->m_id, value);
682 return to_base();
683 }
684
685 template<typename T, typename A = actual_type_t<T>, if_not_t<
686 is_callable<T>::value || is_actual<T>::value > = 0>
687 Self& set(A&& value) {
688 flecs::set<T>(this->m_world, this->m_id, FLECS_FWD(value));
689 return to_base();
690 }
691
692 template<typename T, typename A = actual_type_t<T>, if_not_t<
693 is_callable<T>::value || is_actual<T>::value > = 0>
694 Self& set(const A& value) {
695 flecs::set<T>(this->m_world, this->m_id, value);
696 return to_base();
697 }
698
707 template <typename First, typename Second, typename P = pair<First, Second>,
708 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value> = 0>
709 Self& set(A&& value) {
710 flecs::set<P>(this->m_world, this->m_id, FLECS_FWD(value));
711 return to_base();
712 }
713
722 template <typename First, typename Second, typename P = pair<First, Second>,
723 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value> = 0>
724 Self& set(const A& value) {
725 flecs::set<P>(this->m_world, this->m_id, value);
726 return to_base();
727 }
728
737 template <typename First, typename Second, if_not_t< is_enum<Second>::value > = 0>
738 Self& set(Second second, const First& value) {
739 auto first = _::cpp_type<First>::id(this->m_world);
740 flecs::set(this->m_world, this->m_id, value,
741 ecs_pair(first, second));
742 return to_base();
743 }
744
753 template <typename First, typename Second, if_not_t< is_enum<Second>::value > = 0>
754 Self& set(Second second, First&& value) {
755 auto first = _::cpp_type<First>::id(this->m_world);
756 flecs::set(this->m_world, this->m_id, FLECS_FWD(value),
757 ecs_pair(first, second));
758 return to_base();
759 }
760
769 template <typename First, typename Second, if_t< is_enum<Second>::value > = 0>
770 Self& set(Second constant, const First& value) {
771 const auto& et = enum_type<Second>(this->m_world);
772 flecs::entity_t second = et.entity(constant);
773 return set<First>(second, value);
774 }
775
784 template <typename Second>
785 Self& set_second(entity_t first, const Second& value) {
786 auto second = _::cpp_type<Second>::id(this->m_world);
787 flecs::set(this->m_world, this->m_id, value,
788 ecs_pair(first, second));
789 return to_base();
790 }
791
800 template <typename Second>
801 Self& set_second(entity_t first, Second&& value) {
802 auto second = _::cpp_type<Second>::id(this->m_world);
803 flecs::set(this->m_world, this->m_id, FLECS_FWD(value),
804 ecs_pair(first, second));
805 return to_base();
806 }
807
808 template <typename First, typename Second>
809 Self& set_second(const Second& value) {
810 flecs::set<pair_object<First, Second>>(this->m_world, this->m_id, value);
811 return to_base();
812 }
813
829 template <typename Func, if_t< is_callable<Func>::value > = 0>
830 Self& set(const Func& func);
831
850 template<typename T, typename ... Args, typename A = actual_type_t<T>>
851 Self& emplace(Args&&... args) {
852 flecs::emplace<A>(this->m_world, this->m_id,
853 _::cpp_type<T>::id(this->m_world), FLECS_FWD(args)...);
854 return to_base();
855 }
856
857 template <typename First, typename Second, typename ... Args, typename P = pair<First, Second>,
858 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value> = 0>
859 Self& emplace(Args&&... args) {
860 flecs::emplace<A>(this->m_world, this->m_id,
861 ecs_pair(_::cpp_type<First>::id(this->m_world),
862 _::cpp_type<Second>::id(this->m_world)),
863 FLECS_FWD(args)...);
864 return to_base();
865 }
866
867 template <typename First, typename ... Args>
868 Self& emplace_first(flecs::entity_t second, Args&&... args) {
869 flecs::emplace<First>(this->m_world, this->m_id,
870 ecs_pair(_::cpp_type<First>::id(this->m_world), second),
871 FLECS_FWD(args)...);
872 return to_base();
873 }
874
875 template <typename Second, typename ... Args>
876 Self& emplace_second(flecs::entity_t first, Args&&... args) {
877 flecs::emplace<Second>(this->m_world, this->m_id,
878 ecs_pair(first, _::cpp_type<Second>::id(this->m_world)),
879 FLECS_FWD(args)...);
880 return to_base();
881 }
882
887 template <typename Func>
888 Self& with(const Func& func) {
889 ecs_id_t prev = ecs_set_with(this->m_world, this->m_id);
890 func();
891 ecs_set_with(this->m_world, prev);
892 return to_base();
893 }
894
901 template <typename First, typename Func>
902 Self& with(const Func& func) {
903 with(_::cpp_type<First>::id(this->m_world), func);
904 return to_base();
905 }
906
912 template <typename Func>
913 Self& with(entity_t first, const Func& func) {
914 ecs_id_t prev = ecs_set_with(this->m_world,
915 ecs_pair(first, this->m_id));
916 func();
917 ecs_set_with(this->m_world, prev);
918 return to_base();
919 }
920
922 template <typename Func>
923 Self& scope(const Func& func) {
924 ecs_entity_t prev = ecs_set_scope(this->m_world, this->m_id);
925 func();
926 ecs_set_scope(this->m_world, prev);
927 return to_base();
928 }
929
930 /* Set the entity name.
931 */
932 Self& set_name(const char *name) {
933 ecs_set_name(this->m_world, this->m_id, name);
934 return to_base();
935 }
936
937# ifdef FLECS_DOC
938# include "../doc/entity_builder.inl"
939# endif
940
941# ifdef FLECS_META
942# include "../meta/entity_builder.inl"
943# endif
944
945protected:
946 Self& to_base() {
947 return *static_cast<Self*>(this);
948 }
949};
950
951}
ecs_entity_t ecs_set_with(ecs_world_t *world, ecs_id_t id)
Set current with id.
void ecs_add_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
Add a (component) id to an entity.
void ecs_remove_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
Remove a (component) id from an entity.
#define ecs_assert(condition, error_code,...)
Assert.
Definition: log.h:352
#define ecs_check(condition, error_code,...)
Check.
Definition: log.h:388
ecs_id_t ecs_entity_t
An entity identifier.
Definition: flecs.h:220
uint64_t ecs_id_t
An id.
Definition: flecs.h:217
void ecs_enable_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t id, bool enable)
Enable or disable component.
void ecs_enable(ecs_world_t *world, ecs_entity_t entity, bool enabled)
Enable or disable entity.
ecs_entity_t ecs_get_target(const ecs_world_t *world, ecs_entity_t entity, ecs_entity_t rel, int32_t index)
Get the target of a relationship.
bool ecs_has_id(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
Test if an entity has an entity.
ecs_entity_t ecs_set_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t id, size_t size, const void *ptr)
Set the value of a component.
const ecs_id_t ECS_OVERRIDE
Automatically override component when it is inherited.
ecs_entity_t ecs_set_name(ecs_world_t *world, ecs_entity_t entity, const char *name)
Set the name of an entity.
ecs_entity_t ecs_set_scope(ecs_world_t *world, ecs_entity_t scope)
Set the current scope.
Component information.
Definition: flecs.h:1017
ecs_size_t size
Component size.
Definition: flecs.h:1018
Component class.
Definition: component.hpp:363
Entity builder.
Definition: builder.hpp:15
Self & add(Second constant)
Add a pair.
Definition: builder.hpp:85
Self & child_of(entity_t second)
Shortcut for add(ChildOf, entity).
Definition: builder.hpp:211
Self & set(Second constant, const First &value)
Set a pair for an entity.
Definition: builder.hpp:770
Self & child_of()
Shortcut for add(ChildOf, entity).
Definition: builder.hpp:246
Self & enable(flecs::id_t first, flecs::id_t second)
Enable a pair.
Definition: builder.hpp:578
Self & disable(flecs::id_t id)
Disable an id.
Definition: builder.hpp:610
Self & with(entity_t first, const Func &func)
Entities created in function will have (first, this).
Definition: builder.hpp:913
Self & add_if(bool cond)
Conditional add.
Definition: builder.hpp:124
Self & depends_on()
Shortcut for add(DependsOn, entity).
Definition: builder.hpp:255
Self & add_second(flecs::entity_t first)
Add a pair.
Definition: builder.hpp:99
Self & with(const Func &func)
Entities created in function will have the current entity.
Definition: builder.hpp:888
Self & set_override(T &&val)
Set component, mark component for auto-overriding.
Definition: builder.hpp:414
Self & scope(const Func &func)
The function will be ran with the scope set to the current entity.
Definition: builder.hpp:923
Self & add()
Add a component to an entity.
Definition: builder.hpp:25
Self & add_if(bool cond, flecs::entity_t second)
Conditional add.
Definition: builder.hpp:162
Self & set_second(entity_t first, Second &&value)
Set a pair for an entity.
Definition: builder.hpp:801
Self & depends_on(entity_t second)
Shortcut for add(DependsOn, entity).
Definition: builder.hpp:219
Self & add()
Add a pair.
Definition: builder.hpp:60
Self & enable()
Enable a component.
Definition: builder.hpp:568
Self & set(A &&value)
Set a pair for an entity.
Definition: builder.hpp:709
Self & set(Second second, const First &value)
Set a pair for an entity.
Definition: builder.hpp:738
Self & disable(flecs::id_t first, flecs::id_t second)
Disable a pair.
Definition: builder.hpp:630
Self & add(entity_t first, entity_t second)
Add a pair.
Definition: builder.hpp:48
Self & enable()
Enable an entity.
Definition: builder.hpp:536
Self & is_a(entity_t second)
Shortcut for add(IsA, entity).
Definition: builder.hpp:194
Self & add(Second second)
Add a pair.
Definition: builder.hpp:71
Self & add(id_t component)
Add an entity to an entity.
Definition: builder.hpp:37
Self & disable()
Disable an entity.
Definition: builder.hpp:545
Self & disable()
Disable a pair.
Definition: builder.hpp:652
Self & set_override(flecs::entity_t second, First &&val)
Set pair, mark component for auto-overriding.
Definition: builder.hpp:438
Self & remove(Second constant)
Remove a pair.
Definition: builder.hpp:338
Self & with(const Func &func)
Entities created in function will have (First, this).
Definition: builder.hpp:902
Self & add_if(bool cond, flecs::id_t component)
Conditional add.
Definition: builder.hpp:109
Self & remove(Second second)
Remove a pair.
Definition: builder.hpp:316
Self & enable(flecs::id_t second)
Enable a pair.
Definition: builder.hpp:589
Self & remove()
Remove a component from an entity.
Definition: builder.hpp:273
Self & disable(flecs::id_t second)
Disable a pair.
Definition: builder.hpp:641
Self & set_override(const T &val)
Set component, mark component for auto-overriding.
Definition: builder.hpp:403
Self & emplace_override(Args &&... args)
Emplace component, mark component for auto-overriding.
Definition: builder.hpp:475
Self & set(Second second, First &&value)
Set a pair for an entity.
Definition: builder.hpp:754
Self & add_if(bool cond)
Conditional add.
Definition: builder.hpp:174
Self & remove(entity_t first, entity_t second)
Remove a pair.
Definition: builder.hpp:293
Self & disable()
Disable a component.
Definition: builder.hpp:620
Self & slot_of(entity_t second)
Shortcut for add(SlotOf, entity).
Definition: builder.hpp:227
Self & set_override(flecs::entity_t second, const First &val)
Set pair, mark component for auto-overriding.
Definition: builder.hpp:426
Self & enable()
Enable a pair.
Definition: builder.hpp:600
Self & add_if(bool cond, flecs::entity_t first, flecs::entity_t second)
Conditional add.
Definition: builder.hpp:139
Self & set_second(entity_t first, const Second &value)
Set a pair for an entity.
Definition: builder.hpp:785
Self & enable(flecs::id_t id, bool toggle=true)
Enable an id.
Definition: builder.hpp:557
Self & emplace_override(Args &&... args)
Emplace pair, mark pair for auto-overriding.
Definition: builder.hpp:493
Self & set_override(const A &val)
Set component, mark component for auto-overriding.
Definition: builder.hpp:451
Self & set(const A &value)
Set a pair for an entity.
Definition: builder.hpp:724
Self & remove_second(flecs::entity_t first)
Removes a pair.
Definition: builder.hpp:327
Self & slot()
Shortcut for add(SlotOf, target(ChildOf)).
Definition: builder.hpp:233
Self & is_a()
Shortcut for add(IsA, entity).
Definition: builder.hpp:203
Self & slot_of()
Shortcut for add(SlotOf, entity).
Definition: builder.hpp:264
Self & add(E value)
Add pair for enum constant.
Definition: builder.hpp:514
Self & set_override(A &&val)
Set component, mark component for auto-overriding.
Definition: builder.hpp:464
Self & add_if(bool cond, E constant)
Conditional add.
Definition: builder.hpp:185
Self & remove(entity_t entity)
Remove an entity from an entity.
Definition: builder.hpp:282
Self & emplace(Args &&... args)
Emplace component.
Definition: builder.hpp:851
Entity view.
Definition: entity_view.hpp:28
flecs::string_view name() const
Return the entity name.
Definition: entity_view.hpp:78
entity_t id() const
Get entity id.
Definition: entity_view.hpp:50
flecs::entity target(int32_t index=0) const
Get target for a given pair.
Definition: impl.hpp:41
Entity.
Definition: entity.hpp:30
flecs::entity second() const
Get second element from a pair.
Definition: impl.hpp:31
flecs::entity first() const
Get first element from a pair.
Definition: impl.hpp:20
Type that represents a pair.
Definition: pair.hpp:36