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
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
41 template <typename E, if_t< is_enum<E>::value > = 0>
42 Self& add(E value) {
43 flecs::entity_t first = _::cpp_type<E>::id(this->m_world);
44 const auto& et = enum_type<E>(this->m_world);
45 flecs::entity_t second = et.entity(value);
46
47 ecs_assert(second, ECS_INVALID_PARAMETER, "Component was not found in reflection data.");
48 return this->add(first, second);
49 }
50
56 Self& add(id_t component) {
57 ecs_add_id(this->m_world, this->m_id, component);
58 return to_base();
59 }
60
67 Self& add(entity_t first, entity_t second) {
68 ecs_add_pair(this->m_world, this->m_id, first, second);
69 return to_base();
70 }
71
78 template<typename First, typename Second>
79 Self& add() {
80 return this->add<First>(_::cpp_type<Second>::id(this->m_world));
81 }
82
89 template<typename First, typename Second, if_not_t< is_enum<Second>::value > = 0>
90 Self& add(Second second) {
91 flecs_static_assert(is_flecs_constructible<First>::value,
92 "cannot default construct type: add T::T() or use emplace<T>()");
93 return this->add(_::cpp_type<First>::id(this->m_world), second);
94 }
95
103 template<typename First, typename Second, if_t< is_enum<Second>::value > = 0>
104 Self& add(Second constant) {
105 flecs_static_assert(is_flecs_constructible<First>::value,
106 "cannot default construct type: add T::T() or use emplace<T>()");
107 const auto& et = enum_type<Second>(this->m_world);
108 return this->add<First>(et.entity(constant));
109 }
110
117 template<typename Second>
118 Self& add_second(flecs::entity_t first) {
119 return this->add(first, _::cpp_type<Second>::id(this->m_world));
120 }
121
128 Self& add_if(bool cond, flecs::id_t component) {
129 if (cond) {
130 return this->add(component);
131 } else {
132 return this->remove(component);
133 }
134 }
135
142 template <typename T>
143 Self& add_if(bool cond) {
144 if (cond) {
145 return this->add<T>();
146 } else {
147 return this->remove<T>();
148 }
149 }
150
158 Self& add_if(bool cond, flecs::entity_t first, flecs::entity_t second) {
159 if (cond) {
160 return this->add(first, second);
161 } else {
162 /* If second is 0 or if relationship is exclusive, use wildcard for
163 * second which will remove all instances of the relationship.
164 * Replacing 0 with Wildcard will make it possible to use the second
165 * as the condition. */
166 if (!second || ecs_has_id(this->m_world, first, flecs::Exclusive)) {
167 second = flecs::Wildcard;
168 }
169 return this->remove(first, second);
170 }
171 }
172
180 template <typename First>
181 Self& add_if(bool cond, flecs::entity_t second) {
182 return this->add_if(cond, _::cpp_type<First>::id(this->m_world), second);
183 }
184
192 template <typename First, typename Second>
193 Self& add_if(bool cond) {
194 return this->add_if<First>(cond, _::cpp_type<Second>::id(this->m_world));
195 }
196
203 template <typename E, if_t< is_enum<E>::value > = 0>
204 Self& add_if(bool cond, E constant) {
205 const auto& et = enum_type<E>(this->m_world);
206 return this->add_if<E>(cond, et.entity(constant));
207 }
208
213 Self& is_a(entity_t second) {
214 return this->add(flecs::IsA, second);
215 }
216
221 template <typename T>
222 Self& is_a() {
223 return this->add(flecs::IsA, _::cpp_type<T>::id(this->m_world));
224 }
225
230 Self& child_of(entity_t second) {
231 return this->add(flecs::ChildOf, second);
232 }
233
238 Self& depends_on(entity_t second) {
239 return this->add(flecs::DependsOn, second);
240 }
241
246 template <typename E, if_t<is_enum<E>::value> = 0>
248 {
249 const auto& et = enum_type<E>(this->m_world);
250 flecs::entity_t target = et.entity(second);
251 return depends_on(target);
252 }
253
258 Self& slot_of(entity_t second) {
259 return this->add(flecs::SlotOf, second);
260 }
261
264 Self& slot() {
265 ecs_check(ecs_get_target(m_world, m_id, flecs::ChildOf, 0),
266 ECS_INVALID_PARAMETER, "add ChildOf pair before using slot()");
267 return this->slot_of(this->target(flecs::ChildOf));
268 error:
269 return to_base();
270 }
271
276 template <typename T>
277 Self& child_of() {
278 return this->child_of(_::cpp_type<T>::id(this->m_world));
279 }
280
285 template <typename T>
286 Self& depends_on() {
287 return this->depends_on(_::cpp_type<T>::id(this->m_world));
288 }
289
294 template <typename T>
295 Self& slot_of() {
296 return this->slot_of(_::cpp_type<T>::id(this->m_world));
297 }
298
303 template <typename T, if_not_t< is_enum<T>::value > = 0>
304 Self& remove() {
305 ecs_remove_id(this->m_world, this->m_id, _::cpp_type<T>::id(this->m_world));
306 return to_base();
307 }
308
314 template <typename E, if_t< is_enum<E>::value > = 0>
315 Self& remove() {
316 flecs::entity_t first = _::cpp_type<E>::id(this->m_world);
317 return this->remove(first, flecs::Wildcard);
318 }
319
324 Self& remove(entity_t entity) {
325 ecs_remove_id(this->m_world, this->m_id, entity);
326 return to_base();
327 }
328
335 Self& remove(entity_t first, entity_t second) {
336 ecs_remove_pair(this->m_world, this->m_id, first, second);
337 return to_base();
338 }
339
346 template<typename First, typename Second>
347 Self& remove() {
348 return this->remove<First>(_::cpp_type<Second>::id(this->m_world));
349 }
350
357 template<typename First, typename Second, if_not_t< is_enum<Second>::value > = 0>
358 Self& remove(Second second) {
359 return this->remove(_::cpp_type<First>::id(this->m_world), second);
360 }
361
368 template<typename Second>
369 Self& remove_second(flecs::entity_t first) {
370 return this->remove(first, _::cpp_type<Second>::id(this->m_world));
371 }
372
379 template<typename First, typename Second, if_t< is_enum<Second>::value > = 0>
380 Self& remove(Second constant) {
381 const auto& et = enum_type<Second>(this->m_world);
382 flecs::entity_t second = et.entity(constant);
383 return this->remove<First>(second);
384 }
385
393 Self& override(flecs::id_t id) {
394 return this->add(ECS_OVERRIDE | id);
395 }
396
403 Self& override(flecs::entity_t first, flecs::entity_t second) {
404 return this->override(ecs_pair(first, second));
405 }
406
412 template <typename T>
413 Self& override() {
414 return this->override(_::cpp_type<T>::id(this->m_world));
415 }
416
423 template <typename First>
424 Self& override(flecs::entity_t second) {
425 return this->override(_::cpp_type<First>::id(this->m_world), second);
426 }
427
434 template <typename First, typename Second>
435 Self& override() {
436 return this->override<First>(_::cpp_type<Second>::id(this->m_world));
437 }
438
444 template <typename T>
445 Self& set_override(const T& val) {
446 this->override<T>();
447 return this->set<T>(val);
448 }
449
455 template <typename T>
456 Self& set_override(T&& val) {
457 this->override<T>();
458 return this->set<T>(FLECS_FWD(val));
459 }
460
467 template <typename First>
468 Self& set_override(flecs::entity_t second, const First& val) {
469 this->override<First>(second);
470 return this->set<First>(second, val);
471 }
472
479 template <typename First>
480 Self& set_override(flecs::entity_t second, First&& val) {
481 this->override<First>(second);
482 return this->set<First>(second, FLECS_FWD(val));
483 }
484
491 template <typename First, typename Second, typename P = pair<First, Second>,
492 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value> = 0>
493 Self& set_override(const A& val) {
494 this->override<First, Second>();
495 return this->set<First, Second>(val);
496 }
497
504 template <typename First, typename Second, typename P = pair<First, Second>,
505 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value> = 0>
506 Self& set_override(A&& val) {
507 this->override<First, Second>();
508 return this->set<First, Second>(FLECS_FWD(val));
509 }
510
516 template <typename T, typename ... Args>
517 Self& emplace_override(Args&&... args) {
518 this->override<T>();
519
520 flecs::emplace<T>(this->m_world, this->m_id,
521 _::cpp_type<T>::id(this->m_world), FLECS_FWD(args)...);
522
523 return to_base();
524 }
525
532 template <typename First, typename Second, typename P = pair<First, Second>,
533 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value> = 0,
534 typename ... Args>
535 Self& emplace_override(Args&&... args) {
536 this->override<First, Second>();
537
538 flecs::emplace<A>(this->m_world, this->m_id,
539 ecs_pair(_::cpp_type<First>::id(this->m_world),
540 _::cpp_type<Second>::id(this->m_world)),
541 FLECS_FWD(args)...);
542
543 return to_base();
544 }
545
550 Self& enable() {
551 ecs_enable(this->m_world, this->m_id, true);
552 return to_base();
553 }
554
559 Self& disable() {
560 ecs_enable(this->m_world, this->m_id, false);
561 return to_base();
562 }
563
571 Self& enable(flecs::id_t id, bool toggle = true) {
572 ecs_enable_id(this->m_world, this->m_id, id, toggle);
573 return to_base();
574 }
575
581 template<typename T>
582 Self& enable() {
583 return this->enable(_::cpp_type<T>::id(this->m_world));
584 }
585
592 Self& enable(flecs::id_t first, flecs::id_t second) {
593 return this->enable(ecs_pair(first, second));
594 }
595
602 template<typename First>
603 Self& enable(flecs::id_t second) {
604 return this->enable(_::cpp_type<First>::id(), second);
605 }
606
613 template<typename First, typename Second>
614 Self& enable() {
615 return this->enable<First>(_::cpp_type<Second>::id());
616 }
617
624 Self& disable(flecs::id_t id) {
625 return this->enable(id, false);
626 }
627
633 template<typename T>
634 Self& disable() {
635 return this->disable(_::cpp_type<T>::id());
636 }
637
644 Self& disable(flecs::id_t first, flecs::id_t second) {
645 return this->disable(ecs_pair(first, second));
646 }
647
654 template<typename First>
655 Self& disable(flecs::id_t second) {
656 return this->disable(_::cpp_type<First>::id(), second);
657 }
658
665 template<typename First, typename Second>
666 Self& disable() {
667 return this->disable<First>(_::cpp_type<Second>::id());
668 }
669
670 Self& set_ptr(entity_t comp, size_t size, const void *ptr) {
671 ecs_set_id(this->m_world, this->m_id, comp, size, ptr);
672 return to_base();
673 }
674
675 Self& set_ptr(entity_t comp, const void *ptr) {
676 const flecs::Component *cptr = ecs_get(
677 this->m_world, comp, EcsComponent);
678
679 /* Can't set if it's not a component */
680 ecs_assert(cptr != NULL, ECS_INVALID_PARAMETER, NULL);
681
682 return set_ptr(comp, cptr->size, ptr);
683 }
684
685 template<typename T, if_t<
686 !is_callable<T>::value && is_actual<T>::value> = 0 >
687 Self& set(T&& value) {
688 flecs::set<T>(this->m_world, this->m_id, FLECS_FWD(value));
689 return to_base();
690 }
691
692 template<typename T, if_t<
693 !is_callable<T>::value && is_actual<T>::value > = 0>
694 Self& set(const T& value) {
695 flecs::set<T>(this->m_world, this->m_id, value);
696 return to_base();
697 }
698
699 template<typename T, typename A = actual_type_t<T>, if_not_t<
700 is_callable<T>::value || is_actual<T>::value > = 0>
701 Self& set(A&& value) {
702 flecs::set<T>(this->m_world, this->m_id, FLECS_FWD(value));
703 return to_base();
704 }
705
706 template<typename T, typename A = actual_type_t<T>, if_not_t<
707 is_callable<T>::value || is_actual<T>::value > = 0>
708 Self& set(const A& value) {
709 flecs::set<T>(this->m_world, this->m_id, value);
710 return to_base();
711 }
712
721 template <typename First, typename Second, typename P = pair<First, Second>,
722 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value> = 0>
723 Self& set(A&& value) {
724 flecs::set<P>(this->m_world, this->m_id, FLECS_FWD(value));
725 return to_base();
726 }
727
736 template <typename First, typename Second, typename P = pair<First, Second>,
737 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value> = 0>
738 Self& set(const A& value) {
739 flecs::set<P>(this->m_world, this->m_id, value);
740 return to_base();
741 }
742
751 template <typename First, typename Second, if_not_t< is_enum<Second>::value > = 0>
752 Self& set(Second second, const First& value) {
753 auto first = _::cpp_type<First>::id(this->m_world);
754 flecs::set(this->m_world, this->m_id, value,
755 ecs_pair(first, second));
756 return to_base();
757 }
758
767 template <typename First, typename Second, if_not_t< is_enum<Second>::value > = 0>
768 Self& set(Second second, First&& value) {
769 auto first = _::cpp_type<First>::id(this->m_world);
770 flecs::set(this->m_world, this->m_id, FLECS_FWD(value),
771 ecs_pair(first, second));
772 return to_base();
773 }
774
783 template <typename First, typename Second, if_t< is_enum<Second>::value > = 0>
784 Self& set(Second constant, const First& value) {
785 const auto& et = enum_type<Second>(this->m_world);
786 flecs::entity_t second = et.entity(constant);
787 return set<First>(second, value);
788 }
789
798 template <typename Second>
799 Self& set_second(entity_t first, const Second& value) {
800 auto second = _::cpp_type<Second>::id(this->m_world);
801 flecs::set(this->m_world, this->m_id, value,
802 ecs_pair(first, second));
803 return to_base();
804 }
805
814 template <typename Second>
815 Self& set_second(entity_t first, Second&& value) {
816 auto second = _::cpp_type<Second>::id(this->m_world);
817 flecs::set(this->m_world, this->m_id, FLECS_FWD(value),
818 ecs_pair(first, second));
819 return to_base();
820 }
821
822 template <typename First, typename Second>
823 Self& set_second(const Second& value) {
824 flecs::set<pair_object<First, Second>>(this->m_world, this->m_id, value);
825 return to_base();
826 }
827
843 template <typename Func, if_t< is_callable<Func>::value > = 0>
844 Self& set(const Func& func);
845
867 template<typename T, typename ... Args, typename A = actual_type_t<T>>
868 Self& emplace(Args&&... args) {
869 flecs::emplace<A>(this->m_world, this->m_id,
870 _::cpp_type<T>::id(this->m_world), FLECS_FWD(args)...);
871 return to_base();
872 }
873
874 template <typename First, typename Second, typename ... Args, typename P = pair<First, Second>,
875 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value> = 0>
876 Self& emplace(Args&&... args) {
877 flecs::emplace<A>(this->m_world, this->m_id,
878 ecs_pair(_::cpp_type<First>::id(this->m_world),
879 _::cpp_type<Second>::id(this->m_world)),
880 FLECS_FWD(args)...);
881 return to_base();
882 }
883
884 template <typename First, typename ... Args>
885 Self& emplace_first(flecs::entity_t second, Args&&... args) {
886 flecs::emplace<First>(this->m_world, this->m_id,
887 ecs_pair(_::cpp_type<First>::id(this->m_world), second),
888 FLECS_FWD(args)...);
889 return to_base();
890 }
891
892 template <typename Second, typename ... Args>
893 Self& emplace_second(flecs::entity_t first, Args&&... args) {
894 flecs::emplace<Second>(this->m_world, this->m_id,
895 ecs_pair(first, _::cpp_type<Second>::id(this->m_world)),
896 FLECS_FWD(args)...);
897 return to_base();
898 }
899
905 template <typename Func>
906 Self& with(const Func& func) {
907 ecs_id_t prev = ecs_set_with(this->m_world, this->m_id);
908 func();
909 ecs_set_with(this->m_world, prev);
910 return to_base();
911 }
912
919 template <typename First, typename Func>
920 Self& with(const Func& func) {
921 with(_::cpp_type<First>::id(this->m_world), func);
922 return to_base();
923 }
924
931 template <typename Func>
932 Self& with(entity_t first, const Func& func) {
933 ecs_id_t prev = ecs_set_with(this->m_world,
934 ecs_pair(first, this->m_id));
935 func();
936 ecs_set_with(this->m_world, prev);
937 return to_base();
938 }
939
941 template <typename Func>
942 Self& scope(const Func& func) {
943 ecs_entity_t prev = ecs_set_scope(this->m_world, this->m_id);
944 func();
945 ecs_set_scope(this->m_world, prev);
946 return to_base();
947 }
948
951 return scoped_world(m_world, m_id);
952 }
953
954 /* Set the entity name.
955 */
956 Self& set_name(const char *name) {
957 ecs_set_name(this->m_world, this->m_id, name);
958 return to_base();
959 }
960
961 /* Set entity alias.
962 */
963 Self& set_alias(const char *name) {
964 ecs_set_alias(this->m_world, this->m_id, name);
965 return to_base();
966 }
967
968# ifdef FLECS_DOC
970# endif
971
972# ifdef FLECS_META
974# endif
975
976# ifdef FLECS_JSON
978# endif
979
981
982protected:
983 Self& to_base() {
984 return *static_cast<Self*>(this);
985 }
986};
987
988}
Doc entity builder mixin.
Event entity mixin.
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:351
#define ecs_check(condition, error_code,...)
Check.
Definition log.h:398
ecs_id_t ecs_entity_t
An entity identifier.
Definition flecs.h:318
uint64_t ecs_id_t
Ids are the things that can be added to an entity.
Definition flecs.h:311
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 id.
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.
void ecs_set_alias(ecs_world_t *world, ecs_entity_t entity, const char *alias)
Set alias for entity.
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.
JSON entity mixin.
Meta entity builder mixin.
Component information.
Definition flecs.h:1316
ecs_size_t size
Component size.
Definition flecs.h:1317
Component class.
Entity builder.
Definition builder.hpp:15
Self & add(Second constant)
Add a pair.
Definition builder.hpp:104
Self & child_of(entity_t second)
Shortcut for add(ChildOf, entity).
Definition builder.hpp:230
Self & set(Second constant, const First &value)
Set a pair for an entity.
Definition builder.hpp:784
Self & child_of()
Shortcut for add(ChildOf, entity).
Definition builder.hpp:277
Self & enable(flecs::id_t first, flecs::id_t second)
Enable a pair.
Definition builder.hpp:592
Self & disable(flecs::id_t id)
Disable an id.
Definition builder.hpp:624
Self & with(entity_t first, const Func &func)
Entities created in function will have (first, this).
Definition builder.hpp:932
Self & add_if(bool cond)
Conditional add.
Definition builder.hpp:143
Self & depends_on()
Shortcut for add(DependsOn, entity).
Definition builder.hpp:286
Self & add_second(flecs::entity_t first)
Add a pair.
Definition builder.hpp:118
Self & with(const Func &func)
Entities created in function will have the current entity.
Definition builder.hpp:906
Self & set_override(T &&val)
Set component, mark component for auto-overriding.
Definition builder.hpp:456
Self & scope(const Func &func)
The function will be ran with the scope set to the current entity.
Definition builder.hpp:942
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:181
Self & set_second(entity_t first, Second &&value)
Set a pair for an entity.
Definition builder.hpp:815
Self & depends_on(entity_t second)
Shortcut for add(DependsOn, entity).
Definition builder.hpp:238
Self & add()
Add a pair.
Definition builder.hpp:79
Self & enable()
Enable a component.
Definition builder.hpp:582
scoped_world scope() const
Return world scoped to entity.
Definition builder.hpp:950
Self & set(A &&value)
Set a pair for an entity.
Definition builder.hpp:723
Self & set(Second second, const First &value)
Set a pair for an entity.
Definition builder.hpp:752
Self & disable(flecs::id_t first, flecs::id_t second)
Disable a pair.
Definition builder.hpp:644
Self & add(entity_t first, entity_t second)
Add a pair.
Definition builder.hpp:67
Self & enable()
Enable an entity.
Definition builder.hpp:550
Self & is_a(entity_t second)
Shortcut for add(IsA, entity).
Definition builder.hpp:213
Self & add(Second second)
Add a pair.
Definition builder.hpp:90
Self & add(id_t component)
Add an entity to an entity.
Definition builder.hpp:56
Self & disable()
Disable an entity.
Definition builder.hpp:559
Self & disable()
Disable a pair.
Definition builder.hpp:666
Self & set_override(flecs::entity_t second, First &&val)
Set pair, mark component for auto-overriding.
Definition builder.hpp:480
Self & remove(Second constant)
Remove a pair.
Definition builder.hpp:380
Self & with(const Func &func)
Entities created in function will have (First, this).
Definition builder.hpp:920
Self & add_if(bool cond, flecs::id_t component)
Conditional add.
Definition builder.hpp:128
Self & remove(Second second)
Remove a pair.
Definition builder.hpp:358
Self & enable(flecs::id_t second)
Enable a pair.
Definition builder.hpp:603
Self & remove()
Remove a component from an entity.
Definition builder.hpp:304
Self & disable(flecs::id_t second)
Disable a pair.
Definition builder.hpp:655
Self & depends_on(E second)
Shortcut for add(DependsOn, entity).
Definition builder.hpp:247
Self & set_override(const T &val)
Set component, mark component for auto-overriding.
Definition builder.hpp:445
Self & emplace_override(Args &&... args)
Emplace component, mark component for auto-overriding.
Definition builder.hpp:517
Self & set(Second second, First &&value)
Set a pair for an entity.
Definition builder.hpp:768
Self & add_if(bool cond)
Conditional add.
Definition builder.hpp:193
Self & remove(entity_t first, entity_t second)
Remove a pair.
Definition builder.hpp:335
Self & disable()
Disable a component.
Definition builder.hpp:634
Self & slot_of(entity_t second)
Shortcut for add(SlotOf, entity).
Definition builder.hpp:258
Self & set_override(flecs::entity_t second, const First &val)
Set pair, mark component for auto-overriding.
Definition builder.hpp:468
Self & enable()
Enable a pair.
Definition builder.hpp:614
Self & add_if(bool cond, flecs::entity_t first, flecs::entity_t second)
Conditional add.
Definition builder.hpp:158
Self & set_second(entity_t first, const Second &value)
Set a pair for an entity.
Definition builder.hpp:799
Self & enable(flecs::id_t id, bool toggle=true)
Enable an id.
Definition builder.hpp:571
Self & emplace_override(Args &&... args)
Emplace pair, mark pair for auto-overriding.
Definition builder.hpp:535
Self & set_override(const A &val)
Set component, mark component for auto-overriding.
Definition builder.hpp:493
Self & set(const A &value)
Set a pair for an entity.
Definition builder.hpp:738
Self & remove_second(flecs::entity_t first)
Removes a pair.
Definition builder.hpp:369
Self & slot()
Shortcut for add(SlotOf, target(ChildOf)).
Definition builder.hpp:264
Self & is_a()
Shortcut for add(IsA, entity).
Definition builder.hpp:222
Self & slot_of()
Shortcut for add(SlotOf, entity).
Definition builder.hpp:295
Self & add(E value)
Add pair for enum constant.
Definition builder.hpp:42
Self & set_override(A &&val)
Set component, mark component for auto-overriding.
Definition builder.hpp:506
Self & add_if(bool cond, E constant)
Conditional add.
Definition builder.hpp:204
Self & remove(entity_t entity)
Remove an entity from an entity.
Definition builder.hpp:324
Self & emplace(Args &&... args)
Emplace component.
Definition builder.hpp:868
flecs::string_view name() const
Return the entity name.
entity_t id() const
Get entity id.
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
Scoped world.
Definition world.hpp:1093