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 return this->add(first, second);
47 }
48
54 Self& add(id_t component) {
55 ecs_add_id(this->m_world, this->m_id, component);
56 return to_base();
57 }
58
65 Self& add(entity_t first, entity_t second) {
66 ecs_add_pair(this->m_world, this->m_id, first, second);
67 return to_base();
68 }
69
76 template<typename First, typename Second>
77 Self& add() {
78 return this->add<First>(_::cpp_type<Second>::id(this->m_world));
79 }
80
87 template<typename First, typename Second, if_not_t< is_enum<Second>::value > = 0>
88 Self& add(Second second) {
89 flecs_static_assert(is_flecs_constructible<First>::value,
90 "cannot default construct type: add T::T() or use emplace<T>()");
91 return this->add(_::cpp_type<First>::id(this->m_world), second);
92 }
93
101 template<typename First, typename Second, if_t< is_enum<Second>::value > = 0>
102 Self& add(Second constant) {
103 flecs_static_assert(is_flecs_constructible<First>::value,
104 "cannot default construct type: add T::T() or use emplace<T>()");
105 const auto& et = enum_type<Second>(this->m_world);
106 return this->add<First>(et.entity(constant));
107 }
108
115 template<typename Second>
116 Self& add_second(flecs::entity_t first) {
117 return this->add(first, _::cpp_type<Second>::id(this->m_world));
118 }
119
126 Self& add_if(bool cond, flecs::id_t component) {
127 if (cond) {
128 return this->add(component);
129 } else {
130 return this->remove(component);
131 }
132 }
133
140 template <typename T>
141 Self& add_if(bool cond) {
142 if (cond) {
143 return this->add<T>();
144 } else {
145 return this->remove<T>();
146 }
147 }
148
156 Self& add_if(bool cond, flecs::entity_t first, flecs::entity_t second) {
157 if (cond) {
158 return this->add(first, second);
159 } else {
160 /* If second is 0 or if relationship is exclusive, use wildcard for
161 * second which will remove all instances of the relationship.
162 * Replacing 0 with Wildcard will make it possible to use the second
163 * as the condition. */
164 if (!second || ecs_has_id(this->m_world, first, flecs::Exclusive)) {
165 second = flecs::Wildcard;
166 }
167 return this->remove(first, second);
168 }
169 }
170
178 template <typename First>
179 Self& add_if(bool cond, flecs::entity_t second) {
180 return this->add_if(cond, _::cpp_type<First>::id(this->m_world), second);
181 }
182
190 template <typename First, typename Second>
191 Self& add_if(bool cond) {
192 return this->add_if<First>(cond, _::cpp_type<Second>::id(this->m_world));
193 }
194
201 template <typename E, if_t< is_enum<E>::value > = 0>
202 Self& add_if(bool cond, E constant) {
203 const auto& et = enum_type<E>(this->m_world);
204 return this->add_if<E>(cond, et.entity(constant));
205 }
206
211 Self& is_a(entity_t second) {
212 return this->add(flecs::IsA, second);
213 }
214
219 template <typename T>
220 Self& is_a() {
221 return this->add(flecs::IsA, _::cpp_type<T>::id(this->m_world));
222 }
223
228 Self& child_of(entity_t second) {
229 return this->add(flecs::ChildOf, second);
230 }
231
236 Self& depends_on(entity_t second) {
237 return this->add(flecs::DependsOn, second);
238 }
239
244 Self& slot_of(entity_t second) {
245 return this->add(flecs::SlotOf, second);
246 }
247
250 Self& slot() {
251 ecs_check(ecs_get_target(m_world, m_id, flecs::ChildOf, 0),
252 ECS_INVALID_PARAMETER, "add ChildOf pair before using slot()");
253 return this->slot_of(this->target(flecs::ChildOf));
254 error:
255 return to_base();
256 }
257
262 template <typename T>
263 Self& child_of() {
264 return this->child_of(_::cpp_type<T>::id(this->m_world));
265 }
266
271 template <typename T>
272 Self& depends_on() {
273 return this->depends_on(_::cpp_type<T>::id(this->m_world));
274 }
275
280 template <typename T>
281 Self& slot_of() {
282 return this->slot_of(_::cpp_type<T>::id(this->m_world));
283 }
284
289 template <typename T, if_not_t< is_enum<T>::value > = 0>
290 Self& remove() {
291 ecs_remove_id(this->m_world, this->m_id, _::cpp_type<T>::id(this->m_world));
292 return to_base();
293 }
294
300 template <typename E, if_t< is_enum<E>::value > = 0>
301 Self& remove() {
302 flecs::entity_t first = _::cpp_type<E>::id(this->m_world);
303 return this->remove(first, flecs::Wildcard);
304 }
305
310 Self& remove(entity_t entity) {
311 ecs_remove_id(this->m_world, this->m_id, entity);
312 return to_base();
313 }
314
321 Self& remove(entity_t first, entity_t second) {
322 ecs_remove_pair(this->m_world, this->m_id, first, second);
323 return to_base();
324 }
325
332 template<typename First, typename Second>
333 Self& remove() {
334 return this->remove<First>(_::cpp_type<Second>::id(this->m_world));
335 }
336
343 template<typename First, typename Second, if_not_t< is_enum<Second>::value > = 0>
344 Self& remove(Second second) {
345 return this->remove(_::cpp_type<First>::id(this->m_world), second);
346 }
347
354 template<typename Second>
355 Self& remove_second(flecs::entity_t first) {
356 return this->remove(first, _::cpp_type<Second>::id(this->m_world));
357 }
358
365 template<typename First, typename Second, if_t< is_enum<Second>::value > = 0>
366 Self& remove(Second constant) {
367 const auto& et = enum_type<Second>(this->m_world);
368 flecs::entity_t second = et.entity(constant);
369 return this->remove<First>(second);
370 }
371
379 Self& override(flecs::id_t id) {
380 return this->add(ECS_OVERRIDE | id);
381 }
382
389 Self& override(flecs::entity_t first, flecs::entity_t second) {
390 return this->override(ecs_pair(first, second));
391 }
392
398 template <typename T>
399 Self& override() {
400 return this->override(_::cpp_type<T>::id(this->m_world));
401 }
402
409 template <typename First>
410 Self& override(flecs::entity_t second) {
411 return this->override(_::cpp_type<First>::id(this->m_world), second);
412 }
413
420 template <typename First, typename Second>
421 Self& override() {
422 return this->override<First>(_::cpp_type<Second>::id(this->m_world));
423 }
424
430 template <typename T>
431 Self& set_override(const T& val) {
432 this->override<T>();
433 return this->set<T>(val);
434 }
435
441 template <typename T>
442 Self& set_override(T&& val) {
443 this->override<T>();
444 return this->set<T>(FLECS_FWD(val));
445 }
446
453 template <typename First>
454 Self& set_override(flecs::entity_t second, const First& val) {
455 this->override<First>(second);
456 return this->set<First>(second, val);
457 }
458
465 template <typename First>
466 Self& set_override(flecs::entity_t second, First&& val) {
467 this->override<First>(second);
468 return this->set<First>(second, FLECS_FWD(val));
469 }
470
477 template <typename First, typename Second, typename P = pair<First, Second>,
478 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value> = 0>
479 Self& set_override(const A& val) {
480 this->override<First, Second>();
481 return this->set<First, Second>(val);
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 Self& set_override(A&& val) {
493 this->override<First, Second>();
494 return this->set<First, Second>(FLECS_FWD(val));
495 }
496
502 template <typename T, typename ... Args>
503 Self& emplace_override(Args&&... args) {
504 this->override<T>();
505
506 flecs::emplace<T>(this->m_world, this->m_id,
507 _::cpp_type<T>::id(this->m_world), FLECS_FWD(args)...);
508
509 return to_base();
510 }
511
518 template <typename First, typename Second, typename P = pair<First, Second>,
519 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value> = 0,
520 typename ... Args>
521 Self& emplace_override(Args&&... args) {
522 this->override<First, Second>();
523
524 flecs::emplace<A>(this->m_world, this->m_id,
525 ecs_pair(_::cpp_type<First>::id(this->m_world),
526 _::cpp_type<Second>::id(this->m_world)),
527 FLECS_FWD(args)...);
528
529 return to_base();
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(this->m_world));
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
888 template <typename Func>
889 Self& with(const Func& func) {
890 ecs_id_t prev = ecs_set_with(this->m_world, this->m_id);
891 func();
892 ecs_set_with(this->m_world, prev);
893 return to_base();
894 }
895
902 template <typename First, typename Func>
903 Self& with(const Func& func) {
904 with(_::cpp_type<First>::id(this->m_world), func);
905 return to_base();
906 }
907
914 template <typename Func>
915 Self& with(entity_t first, const Func& func) {
916 ecs_id_t prev = ecs_set_with(this->m_world,
917 ecs_pair(first, this->m_id));
918 func();
919 ecs_set_with(this->m_world, prev);
920 return to_base();
921 }
922
924 template <typename Func>
925 Self& scope(const Func& func) {
926 ecs_entity_t prev = ecs_set_scope(this->m_world, this->m_id);
927 func();
928 ecs_set_scope(this->m_world, prev);
929 return to_base();
930 }
931
934 return scoped_world(m_world, m_id);
935 }
936
937 /* Set the entity name.
938 */
939 Self& set_name(const char *name) {
940 ecs_set_name(this->m_world, this->m_id, name);
941 return to_base();
942 }
943
944 /* Set entity alias.
945 */
946 Self& set_alias(const char *name) {
947 ecs_set_alias(this->m_world, this->m_id, name);
948 return to_base();
949 }
950
951# ifdef FLECS_DOC
952# include "../doc/entity_builder.inl"
953# endif
954
955# ifdef FLECS_META
956# include "../meta/entity_builder.inl"
957# endif
958
959protected:
960 Self& to_base() {
961 return *static_cast<Self*>(this);
962 }
963};
964
965}
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:397
ecs_id_t ecs_entity_t
An entity identifier.
Definition: flecs.h:286
uint64_t ecs_id_t
Ids are the things that can be added to an entity.
Definition: flecs.h:279
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.
Component information.
Definition: flecs.h:1261
ecs_size_t size
Component size.
Definition: flecs.h:1262
Component class.
Definition: component.hpp:348
Entity builder.
Definition: builder.hpp:15
Self & add(Second constant)
Add a pair.
Definition: builder.hpp:102
Self & child_of(entity_t second)
Shortcut for add(ChildOf, entity).
Definition: builder.hpp:228
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:263
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:915
Self & add_if(bool cond)
Conditional add.
Definition: builder.hpp:141
Self & depends_on()
Shortcut for add(DependsOn, entity).
Definition: builder.hpp:272
Self & add_second(flecs::entity_t first)
Add a pair.
Definition: builder.hpp:116
Self & with(const Func &func)
Entities created in function will have the current entity.
Definition: builder.hpp:889
Self & set_override(T &&val)
Set component, mark component for auto-overriding.
Definition: builder.hpp:442
Self & scope(const Func &func)
The function will be ran with the scope set to the current entity.
Definition: builder.hpp:925
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:179
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:236
Self & add()
Add a pair.
Definition: builder.hpp:77
Self & enable()
Enable a component.
Definition: builder.hpp:568
scoped_world scope() const
Return world scoped to entity.
Definition: builder.hpp:933
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:65
Self & enable()
Enable an entity.
Definition: builder.hpp:536
Self & is_a(entity_t second)
Shortcut for add(IsA, entity).
Definition: builder.hpp:211
Self & add(Second second)
Add a pair.
Definition: builder.hpp:88
Self & add(id_t component)
Add an entity to an entity.
Definition: builder.hpp:54
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:466
Self & remove(Second constant)
Remove a pair.
Definition: builder.hpp:366
Self & with(const Func &func)
Entities created in function will have (First, this).
Definition: builder.hpp:903
Self & add_if(bool cond, flecs::id_t component)
Conditional add.
Definition: builder.hpp:126
Self & remove(Second second)
Remove a pair.
Definition: builder.hpp:344
Self & enable(flecs::id_t second)
Enable a pair.
Definition: builder.hpp:589
Self & remove()
Remove a component from an entity.
Definition: builder.hpp:290
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:431
Self & emplace_override(Args &&... args)
Emplace component, mark component for auto-overriding.
Definition: builder.hpp:503
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:191
Self & remove(entity_t first, entity_t second)
Remove a pair.
Definition: builder.hpp:321
Self & disable()
Disable a component.
Definition: builder.hpp:620
Self & slot_of(entity_t second)
Shortcut for add(SlotOf, entity).
Definition: builder.hpp:244
Self & set_override(flecs::entity_t second, const First &val)
Set pair, mark component for auto-overriding.
Definition: builder.hpp:454
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:156
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:521
Self & set_override(const A &val)
Set component, mark component for auto-overriding.
Definition: builder.hpp:479
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:355
Self & slot()
Shortcut for add(SlotOf, target(ChildOf)).
Definition: builder.hpp:250
Self & is_a()
Shortcut for add(IsA, entity).
Definition: builder.hpp:220
Self & slot_of()
Shortcut for add(SlotOf, entity).
Definition: builder.hpp:281
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:492
Self & add_if(bool cond, E constant)
Conditional add.
Definition: builder.hpp:202
Self & remove(entity_t entity)
Remove an entity from an entity.
Definition: builder.hpp:310
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
Scoped world.
Definition: world.hpp:1096