Flecs v4.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
18
24 template <typename T>
25 const Self& add() const {
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->world_, this->id_, _::type<T>::id(this->world_));
29 return to_base();
30 }
31
41 template <typename E, if_t< is_enum<E>::value > = 0>
42 const Self& add(E value) const {
44 const auto& et = enum_type<E>(this->world_);
45 flecs::entity_t second = et.entity(value);
46
47 ecs_assert(second, ECS_INVALID_PARAMETER, "Enum constant was not found in reflection data.");
48 return this->add(first, second);
49 }
50
56 const Self& add(id_t component) const {
57 ecs_add_id(this->world_, this->id_, component);
58 return to_base();
59 }
60
67 const Self& add(entity_t first, entity_t second) const {
68 ecs_add_pair(this->world_, this->id_, first, second);
69 return to_base();
70 }
71
78 template<typename First, typename Second>
79 const Self& add() const {
80 return this->add<First>(_::type<Second>::id(this->world_));
81 }
82
89 template<typename First, typename Second, if_not_t< is_enum<Second>::value > = 0>
90 const Self& add(Second second) const {
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(_::type<First>::id(this->world_), second);
94 }
95
103 template<typename First, typename Second, if_t< is_enum<Second>::value && !std::is_same<First, Second>::value > = 0>
104 const Self& add(Second constant) const {
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->world_);
108 return this->add<First>(et.entity(constant));
109 }
110
117 template<typename Second>
118 const Self& add_second(flecs::entity_t first) const {
119 return this->add(first, _::type<Second>::id(this->world_));
120 }
121
128 const Self& add_if(bool cond, flecs::id_t component) const {
129 if (cond) {
130 return this->add(component);
131 } else {
132 return this->remove(component);
133 }
134 }
135
142 template <typename T>
143 const Self& add_if(bool cond) const {
144 if (cond) {
145 return this->add<T>();
146 } else {
147 return this->remove<T>();
148 }
149 }
150
158 const Self& add_if(bool cond, flecs::entity_t first, flecs::entity_t second) const {
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->world_, first, flecs::Exclusive)) {
167 second = flecs::Wildcard;
168 }
169 return this->remove(first, second);
170 }
171 }
172
180 template <typename First>
181 const Self& add_if(bool cond, flecs::entity_t second) const {
182 return this->add_if(cond, _::type<First>::id(this->world_), second);
183 }
184
192 template <typename First, typename Second>
193 const Self& add_if(bool cond) const {
194 return this->add_if<First>(cond, _::type<Second>::id(this->world_));
195 }
196
203 template <typename E, if_t< is_enum<E>::value > = 0>
204 const Self& add_if(bool cond, E constant) const {
205 const auto& et = enum_type<E>(this->world_);
206 return this->add_if<E>(cond, et.entity(constant));
207 }
208
213 const Self& is_a(entity_t second) const {
214 return this->add(flecs::IsA, second);
215 }
216
221 template <typename T>
222 const Self& is_a() const {
223 return this->add(flecs::IsA, _::type<T>::id(this->world_));
224 }
225
230 const Self& child_of(entity_t second) const {
231 return this->add(flecs::ChildOf, second);
232 }
233
238 const Self& depends_on(entity_t second) const {
239 return this->add(flecs::DependsOn, second);
240 }
241
246 template <typename E, if_t<is_enum<E>::value> = 0>
247 const Self& depends_on(E second) const {
248 const auto& et = enum_type<E>(this->world_);
250 return depends_on(target);
251 }
252
257 template <typename T>
258 const Self& child_of() const {
259 return this->child_of(_::type<T>::id(this->world_));
260 }
261
266 template <typename T>
267 const Self& depends_on() const {
268 return this->depends_on(_::type<T>::id(this->world_));
269 }
270
275 template <typename T>
276 const Self& remove() const {
277 ecs_remove_id(this->world_, this->id_, _::type<T>::id(this->world_));
278 return to_base();
279 }
280
285 const Self& remove(entity_t entity) const {
286 ecs_remove_id(this->world_, this->id_, entity);
287 return to_base();
288 }
289
296 const Self& remove(entity_t first, entity_t second) const {
297 ecs_remove_pair(this->world_, this->id_, first, second);
298 return to_base();
299 }
300
307 template<typename First, typename Second>
308 const Self& remove() const {
309 return this->remove<First>(_::type<Second>::id(this->world_));
310 }
311
318 template<typename First, typename Second, if_not_t< is_enum<Second>::value > = 0>
319 const Self& remove(Second second) const {
320 return this->remove(_::type<First>::id(this->world_), second);
321 }
322
329 template<typename Second>
331 return this->remove(first, _::type<Second>::id(this->world_));
332 }
333
340 template<typename First, typename Second, if_t< is_enum<Second>::value > = 0>
341 const Self& remove(Second constant) const {
342 const auto& et = enum_type<Second>(this->world_);
344 return this->remove<First>(second);
345 }
346
354 const Self& auto_override(flecs::id_t id) const {
355 return this->add(ECS_AUTO_OVERRIDE | id);
356 }
357
365 return this->auto_override(ecs_pair(first, second));
366 }
367
373 template <typename T>
374 const Self& auto_override() const {
375 return this->auto_override(_::type<T>::id(this->world_));
376 }
377
384 template <typename First>
386 return this->auto_override(_::type<First>::id(this->world_), second);
387 }
388
395 template <typename First, typename Second>
396 const Self& auto_override() const {
397 return this->auto_override<First>(_::type<Second>::id(this->world_));
398 }
399
406 template <typename Second>
408 return this->auto_override(first, _::type<Second>::id(this->world_));
409 }
410
417 template <typename T>
418 const Self& set_auto_override(const T& val) const {
419 this->auto_override<T>();
420 return this->set<T>(val);
421 }
422
429 template <typename T>
430 const Self& set_auto_override(T&& val) const {
431 this->auto_override<T>();
432 return this->set<T>(FLECS_FWD(val));
433 }
434
442 template <typename First>
443 const Self& set_auto_override(flecs::entity_t second, const First& val) const {
444 this->auto_override<First>(second);
445 return this->set<First>(second, val);
446 }
447
455 template <typename First>
456 const Self& set_auto_override(flecs::entity_t second, First&& val) const {
457 this->auto_override<First>(second);
458 return this->set<First>(second, FLECS_FWD(val));
459 }
460
468 template <typename First, typename Second, typename P = pair<First, Second>,
469 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value> = 0>
470 const Self& set_auto_override(const A& val) const {
471 this->auto_override<First, Second>();
472 return this->set<First, Second>(val);
473 }
474
482 template <typename First, typename Second, typename P = pair<First, Second>,
483 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value> = 0>
484 const Self& set_auto_override(A&& val) const {
485 this->auto_override<First, Second>();
486 return this->set<First, Second>(FLECS_FWD(val));
487 }
488
495 template <typename T, typename ... Args>
496 const Self& emplace_auto_override(Args&&... args) const {
497 this->auto_override<T>();
498
499 flecs::emplace<T>(this->world_, this->id_,
500 _::type<T>::id(this->world_), FLECS_FWD(args)...);
501
502 return to_base();
503 }
504
512 template <typename First, typename Second, typename P = pair<First, Second>,
513 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value> = 0,
514 typename ... Args>
515 const Self& emplace_auto_override(Args&&... args) const {
516 this->auto_override<First, Second>();
517
518 flecs::emplace<A>(this->world_, this->id_,
519 ecs_pair(_::type<First>::id(this->world_),
521 FLECS_FWD(args)...);
522
523 return to_base();
524 }
525
530 const Self& enable() const {
531 ecs_enable(this->world_, this->id_, true);
532 return to_base();
533 }
534
539 const Self& disable() const {
540 ecs_enable(this->world_, this->id_, false);
541 return to_base();
542 }
543
553 const Self& enable(flecs::id_t id, bool toggle = true) const {
554 ecs_enable_id(this->world_, this->id_, id, toggle);
555 return to_base();
556 }
557
563 template<typename T>
564 const Self& enable() const {
565 return this->enable(_::type<T>::id(this->world_));
566 }
567
575 return this->enable(ecs_pair(first, second));
576 }
577
584 template<typename First>
585 const Self& enable(flecs::id_t second) const {
586 return this->enable(_::type<First>::id(world_), second);
587 }
588
595 template<typename First, typename Second>
596 const Self& enable() const {
597 return this->enable<First>(_::type<Second>::id(world_));
598 }
599
609 const Self& disable(flecs::id_t id) const {
610 return this->enable(id, false);
611 }
612
618 template<typename T>
619 const Self& disable() const {
620 return this->disable(_::type<T>::id(world_));
621 }
622
630 return this->disable(ecs_pair(first, second));
631 }
632
639 template<typename First>
640 const Self& disable(flecs::id_t second) const {
641 return this->disable(_::type<First>::id(world_), second);
642 }
643
650 template<typename First, typename Second>
651 const Self& disable() const {
652 return this->disable<First>(_::type<Second>::id(world_));
653 }
654
655 const Self& set_ptr(entity_t comp, size_t size, const void *ptr) const {
656 ecs_set_id(this->world_, this->id_, comp, size, ptr);
657 return to_base();
658 }
659
660 const Self& set_ptr(entity_t comp, const void *ptr) const {
661
662 const ecs_type_info_t *type_info = ecs_get_type_info(this->world_, comp);
663
664 /* Can't set if it's not a component */
665 ecs_assert(type_info != nullptr, ECS_INVALID_PARAMETER, nullptr);
666
667 return set_ptr(comp, type_info->size, ptr);
668 }
669
677 template<typename T, if_t<is_actual<T>::value> = 0 >
678 const Self& set(T&& value) const {
679 flecs::set<T>(this->world_, this->id_, FLECS_FWD(value));
680 return to_base();
681 }
682
690 template<typename T, if_t<is_actual<T>::value > = 0>
691 const Self& set(const T& value) const {
692 flecs::set<T>(this->world_, this->id_, value);
693 return to_base();
694 }
695
703 template<typename T, typename A = actual_type_t<T>, if_not_t<
704 is_actual<T>::value > = 0>
705 const Self& set(A&& value) const {
706 flecs::set<T>(this->world_, this->id_, FLECS_FWD(value));
707 return to_base();
708 }
709
717 template<typename T, typename A = actual_type_t<T>, if_not_t<
718 is_actual<T>::value > = 0>
719 const Self& set(const A& value) const {
720 flecs::set<T>(this->world_, this->id_, value);
721 return to_base();
722 }
723
732 template <typename First, typename Second, typename P = pair<First, Second>,
733 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value> = 0>
734 const Self& set(A&& value) const {
735 flecs::set<P>(this->world_, this->id_, FLECS_FWD(value));
736 return to_base();
737 }
738
747 template <typename First, typename Second, typename P = pair<First, Second>,
748 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value> = 0>
749 const Self& set(const A& value) const {
750 flecs::set<P>(this->world_, this->id_, value);
751 return to_base();
752 }
753
762 template <typename First, typename Second, if_not_t< is_enum<Second>::value > = 0>
763 const Self& set(Second second, const First& value) const {
764 auto first = _::type<First>::id(this->world_);
765 flecs::set(this->world_, this->id_, value,
766 ecs_pair(first, second));
767 return to_base();
768 }
769
778 template <typename First, typename Second, if_not_t< is_enum<Second>::value > = 0>
779 const Self& set(Second second, First&& value) const {
780 auto first = _::type<First>::id(this->world_);
781 flecs::set(this->world_, this->id_, FLECS_FWD(value),
782 ecs_pair(first, second));
783 return to_base();
784 }
785
794 template <typename First, typename Second, if_t< is_enum<Second>::value > = 0>
795 const Self& set(Second constant, const First& value) const {
796 const auto& et = enum_type<Second>(this->world_);
798 return set<First>(second, value);
799 }
800
809 template <typename Second>
810 const Self& set_second(entity_t first, const Second& value) const {
811 auto second = _::type<Second>::id(this->world_);
812 ecs_assert( ecs_get_type_info(world_, ecs_pair(first, second)) != nullptr,
813 ECS_INVALID_PARAMETER, "pair is not a component");
815 ECS_INVALID_PARAMETER, "type of pair is not Second");
816 flecs::set(this->world_, this->id_, value,
817 ecs_pair(first, second));
818 return to_base();
819 }
820
829 template <typename Second>
830 const Self& set_second(entity_t first, Second&& value) const {
831 auto second = _::type<Second>::id(this->world_);
832 ecs_assert( ecs_get_type_info(world_, ecs_pair(first, second)) != nullptr,
833 ECS_INVALID_PARAMETER, "pair is not a component");
835 ECS_INVALID_PARAMETER, "type of pair is not Second");
836 flecs::set(this->world_, this->id_, FLECS_FWD(value),
837 ecs_pair(first, second));
838 return to_base();
839 }
840
849 template <typename First, typename Second>
850 const Self& set_second(const Second& value) const {
851 flecs::set<pair_object<First, Second>>(this->world_, this->id_, value);
852 return to_base();
853 }
854
855
863 template<typename T, if_t<is_actual<T>::value> = 0 >
864 const Self& assign(T&& value) const {
865 flecs::assign<T>(this->world_, this->id_, FLECS_FWD(value));
866 return to_base();
867 }
868
876 template<typename T, if_t<is_actual<T>::value > = 0>
877 const Self& assign(const T& value) const {
878 flecs::assign<T>(this->world_, this->id_, value);
879 return to_base();
880 }
881
889 template<typename T, typename A = actual_type_t<T>, if_not_t<
890 is_actual<T>::value > = 0>
891 const Self& assign(A&& value) const {
892 flecs::assign<T>(this->world_, this->id_, FLECS_FWD(value));
893 return to_base();
894 }
895
903 template<typename T, typename A = actual_type_t<T>, if_not_t<
904 is_actual<T>::value > = 0>
905 const Self& assign(const A& value) const {
906 flecs::assign<T>(this->world_, this->id_, value);
907 return to_base();
908 }
909
918 template <typename First, typename Second, typename P = pair<First, Second>,
919 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value> = 0>
920 const Self& assign(A&& value) const {
921 flecs::assign<P>(this->world_, this->id_, FLECS_FWD(value));
922 return to_base();
923 }
924
933 template <typename First, typename Second, typename P = pair<First, Second>,
934 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value> = 0>
935 const Self& assign(const A& value) const {
936 flecs::assign<P>(this->world_, this->id_, value);
937 return to_base();
938 }
939
948 template <typename First, typename Second, if_not_t< is_enum<Second>::value > = 0>
949 const Self& assign(Second second, const First& value) const {
950 auto first = _::type<First>::id(this->world_);
951 flecs::assign(this->world_, this->id_, value,
952 ecs_pair(first, second));
953 return to_base();
954 }
955
964 template <typename First, typename Second, if_not_t< is_enum<Second>::value > = 0>
965 const Self& assign(Second second, First&& value) const {
966 auto first = _::type<First>::id(this->world_);
967 flecs::assign(this->world_, this->id_, FLECS_FWD(value),
968 ecs_pair(first, second));
969 return to_base();
970 }
971
980 template <typename First, typename Second, if_t< is_enum<Second>::value > = 0>
981 const Self& assign(Second constant, const First& value) const {
982 const auto& et = enum_type<Second>(this->world_);
984 return assign<First>(second, value);
985 }
986
995 template <typename Second>
996 const Self& assign_second(entity_t first, const Second& value) const {
997 auto second = _::type<Second>::id(this->world_);
998 ecs_assert( ecs_get_type_info(world_, ecs_pair(first, second)) != nullptr,
999 ECS_INVALID_PARAMETER, "pair is not a component");
1001 ECS_INVALID_PARAMETER, "type of pair is not Second");
1002 flecs::assign(this->world_, this->id_, value,
1003 ecs_pair(first, second));
1004 return to_base();
1005 }
1006
1015 template <typename Second>
1016 const Self& assign_second(entity_t first, Second&& value) const {
1017 auto second = _::type<Second>::id(this->world_);
1018 ecs_assert( ecs_get_type_info(world_, ecs_pair(first, second)) != nullptr,
1019 ECS_INVALID_PARAMETER, "pair is not a component");
1021 ECS_INVALID_PARAMETER, "type of pair is not Second");
1022 flecs::assign(this->world_, this->id_, FLECS_FWD(value),
1023 ecs_pair(first, second));
1024 return to_base();
1025 }
1026
1027 template <typename First, typename Second>
1028 const Self& assign_second(const Second& value) const {
1029 flecs::assign<pair_object<First, Second>>(this->world_, this->id_, value);
1030 return to_base();
1031 }
1032
1033
1049 template <typename Func>
1050 const Self& insert(const Func& func) const;
1051
1059 template<typename T, typename ... Args, typename A = actual_type_t<T>>
1060 const Self& emplace(Args&&... args) const {
1061 flecs::emplace<A>(this->world_, this->id_,
1062 _::type<T>::id(this->world_), FLECS_FWD(args)...);
1063 return to_base();
1064 }
1065
1066 template <typename First, typename Second, typename ... Args, typename P = pair<First, Second>,
1067 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value> = 0>
1068 const Self& emplace(Args&&... args) const {
1069 flecs::emplace<A>(this->world_, this->id_,
1070 ecs_pair(_::type<First>::id(this->world_),
1072 FLECS_FWD(args)...);
1073 return to_base();
1074 }
1075
1076 template <typename First, typename ... Args>
1077 const Self& emplace_first(flecs::entity_t second, Args&&... args) const {
1078 auto first = _::type<First>::id(this->world_);
1079 flecs::emplace<First>(this->world_, this->id_,
1080 ecs_pair(first, second),
1081 FLECS_FWD(args)...);
1082 return to_base();
1083 }
1084
1085 template <typename Second, typename ... Args>
1086 const Self& emplace_second(flecs::entity_t first, Args&&... args) const {
1087 auto second = _::type<Second>::id(this->world_);
1088 ecs_assert( ecs_get_type_info(world_, ecs_pair(first, second)) != nullptr,
1089 ECS_INVALID_PARAMETER, "pair is not a component");
1090 ecs_assert( ecs_get_type_info(world_, ecs_pair(first, second))->component == second,
1091 ECS_INVALID_PARAMETER, "type of pair is not Second");
1092 flecs::emplace<Second>(this->world_, this->id_,
1093 ecs_pair(first, second),
1094 FLECS_FWD(args)...);
1095 return to_base();
1096 }
1097
1099 template <typename Func>
1100 const Self& scope(const Func& func) const {
1101 ecs_entity_t prev = ecs_set_scope(this->world_, this->id_);
1102 func();
1103 ecs_set_scope(this->world_, prev);
1104 return to_base();
1105 }
1106
1108 const Self& set_name(const char *name) const {
1109 ecs_set_name(this->world_, this->id_, name);
1110 return to_base();
1111 }
1112
1114 const Self& set_alias(const char *name) const {
1115 ecs_set_alias(this->world_, this->id_, name);
1116 return to_base();
1117 }
1118
1119# ifdef FLECS_DOC
1120# include "../doc/entity_builder.inl"
1121# endif
1122
1123# ifdef FLECS_META
1125# endif
1126
1127# ifdef FLECS_JSON
1129# endif
1130
1132
1133protected:
1134 const Self& to_base() const {
1135 return *static_cast<const Self*>(this);
1136 }
1137};
1138
1139}
component< T > & constant(const char *name, T value)
Add a constant.
Definition component.inl:38
Doc entity builder mixin.
Event entity mixin.
void ecs_remove_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Remove a component from an entity.
void ecs_add_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Add a (component) ID to an entity.
#define ecs_assert(condition, error_code,...)
Assert.
Definition log.h:473
#define ECS_INVALID_PARAMETER
Invalid parameter error code.
Definition log.h:671
const ecs_type_info_t * ecs_get_type_info(const ecs_world_t *world, ecs_id_t component)
Get the type info for a component.
ecs_id_t ecs_entity_t
An entity identifier.
Definition flecs.h:393
ecs_id_t id_t
ID type.
Definition c_types.hpp:20
ecs_entity_t entity_t
Entity type.
Definition c_types.hpp:21
void ecs_enable_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t component, bool enable)
Enable or disable a component.
void ecs_enable(ecs_world_t *world, ecs_entity_t entity, bool enabled)
Enable or disable an entity.
bool ecs_has_id(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Test if an entity has a component.
#define ecs_add_pair(world, subject, first, second)
Add a pair to an entity.
Definition flecs_c.h:275
#define ecs_remove_pair(world, subject, first, second)
Remove a pair from an entity.
Definition flecs_c.h:283
void ecs_set_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t component, size_t size, const void *ptr)
Set the value of a component.
const ecs_id_t ECS_AUTO_OVERRIDE
Automatically override component when it is inherited.
void ecs_set_alias(ecs_world_t *world, ecs_entity_t entity, const char *alias)
Set an alias for an 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.
Type that contains component information (passed to ctors/dtors/...).
Definition flecs.h:1050
ecs_size_t size
Size of the type.
Definition flecs.h:1051
Component class.
Entity builder.
Definition builder.hpp:15
const Self & emplace_auto_override(Args &&... args) const
Emplace pair, mark pair for auto-overriding.
Definition builder.hpp:515
const Self & disable() const
Disable an entity.
Definition builder.hpp:539
const Self & add(E value) const
Add a pair for an enum constant.
Definition builder.hpp:42
const Self & set(Second constant, const First &value) const
Set a pair for an entity.
Definition builder.hpp:795
const Self & auto_override(flecs::entity_t second) const
Mark pair for auto-overriding.
Definition builder.hpp:385
const Self & enable(flecs::id_t second) const
Enable a pair.
Definition builder.hpp:585
const Self & remove(Second constant) const
Remove a pair.
Definition builder.hpp:341
const Self & remove(entity_t first, entity_t second) const
Remove a pair.
Definition builder.hpp:296
const Self & add_if(bool cond, E constant) const
Conditional add.
Definition builder.hpp:204
const Self & remove(Second second) const
Remove a pair.
Definition builder.hpp:319
const Self & emplace(Args &&... args) const
Emplace a component.
Definition builder.hpp:1060
const Self & set_auto_override(flecs::entity_t second, const First &val) const
Set pair, mark pair for auto-overriding.
Definition builder.hpp:443
const Self & assign(const A &value) const
Assign a component for an entity.
Definition builder.hpp:905
const Self & disable(flecs::id_t first, flecs::id_t second) const
Disable a pair.
Definition builder.hpp:629
const Self & emplace_auto_override(Args &&... args) const
Emplace component, mark component for auto-overriding.
Definition builder.hpp:496
const Self & assign(Second second, First &&value) const
Assign a pair for an entity.
Definition builder.hpp:965
const Self & add() const
Add a pair.
Definition builder.hpp:79
const Self & is_a() const
Shortcut for add(IsA, entity).
Definition builder.hpp:222
const Self & enable() const
Enable an entity.
Definition builder.hpp:530
const Self & remove_second(flecs::entity_t first) const
Remove a pair.
Definition builder.hpp:330
const Self & auto_override() const
Mark component for auto-overriding.
Definition builder.hpp:374
const Self & enable() const
Enable a component.
Definition builder.hpp:564
const Self & set(const T &value) const
Set a component for an entity.
Definition builder.hpp:691
const Self & child_of() const
Shortcut for add(ChildOf, entity).
Definition builder.hpp:258
const Self & set(A &&value) const
Set a pair for an entity.
Definition builder.hpp:734
const Self & set_auto_override(A &&val) const
Set pair, mark pair for auto-overriding.
Definition builder.hpp:484
const Self & set(const A &value) const
Set a component for an entity.
Definition builder.hpp:719
const Self & enable() const
Enable a pair.
Definition builder.hpp:596
const Self & enable(flecs::id_t first, flecs::id_t second) const
Enable a pair.
Definition builder.hpp:574
const Self & remove() const
Remove a component from an entity.
Definition builder.hpp:276
const Self & disable(flecs::id_t id) const
Disable an ID.
Definition builder.hpp:609
const Self & assign(const A &value) const
Assign a pair for an entity.
Definition builder.hpp:935
const Self & assign(A &&value) const
Assign a pair for an entity.
Definition builder.hpp:920
const Self & assign(const T &value) const
Assign a component for an entity.
Definition builder.hpp:877
const Self & set(Second second, const First &value) const
Set a pair for an entity.
Definition builder.hpp:763
const Self & assign(T &&value) const
Assign a component for an entity.
Definition builder.hpp:864
const Self & add_if(bool cond) const
Conditional add.
Definition builder.hpp:193
const Self & is_a(entity_t second) const
Shortcut for add(IsA, entity).
Definition builder.hpp:213
const Self & add(Second constant) const
Add a pair.
Definition builder.hpp:104
const Self & depends_on(E second) const
Shortcut for add(DependsOn, entity).
Definition builder.hpp:247
const Self & add_if(bool cond, flecs::entity_t first, flecs::entity_t second) const
Conditional add.
Definition builder.hpp:158
const Self & set_second(entity_t first, Second &&value) const
Set a pair for an entity.
Definition builder.hpp:830
const Self & set_auto_override(T &&val) const
Set component, mark component for auto-overriding.
Definition builder.hpp:430
const Self & add_if(bool cond) const
Conditional add.
Definition builder.hpp:143
const Self & remove() const
Remove a pair.
Definition builder.hpp:308
const Self & disable() const
Disable a component.
Definition builder.hpp:619
const Self & add(id_t component) const
Add an entity to an entity.
Definition builder.hpp:56
const Self & set_name(const char *name) const
Set the entity name.
Definition builder.hpp:1108
const Self & add(entity_t first, entity_t second) const
Add a pair.
Definition builder.hpp:67
const Self & set(Second second, First &&value) const
Set a pair for an entity.
Definition builder.hpp:779
const Self & assign(Second second, const First &value) const
Assign a pair for an entity.
Definition builder.hpp:949
const Self & insert(const Func &func) const
Set 1..N components.
Definition impl.hpp:23
const Self & scope(const Func &func) const
The function will be run with the scope set to the current entity.
Definition builder.hpp:1100
const Self & add_if(bool cond, flecs::entity_t second) const
Conditional add.
Definition builder.hpp:181
const Self & assign_second(entity_t first, Second &&value) const
Assign a pair for an entity.
Definition builder.hpp:1016
const Self & add_second(flecs::entity_t first) const
Add a pair.
Definition builder.hpp:118
const Self & add_if(bool cond, flecs::id_t component) const
Conditional add.
Definition builder.hpp:128
const Self & set_alias(const char *name) const
Set the entity alias.
Definition builder.hpp:1114
const Self & disable(flecs::id_t second) const
Disable a pair.
Definition builder.hpp:640
const Self & set_second(const Second &value) const
Set a pair for an entity.
Definition builder.hpp:850
const Self & set_auto_override(const T &val) const
Set component, mark component for auto-overriding.
Definition builder.hpp:418
const Self & assign(A &&value) const
Assign a component for an entity.
Definition builder.hpp:891
const Self & remove(entity_t entity) const
Remove an entity from an entity.
Definition builder.hpp:285
const Self & assign(Second constant, const First &value) const
Assign a pair for an entity.
Definition builder.hpp:981
const Self & set_auto_override(flecs::entity_t second, First &&val) const
Set pair, mark pair for auto-overriding.
Definition builder.hpp:456
const Self & set(A &&value) const
Set a component for an entity.
Definition builder.hpp:705
const Self & enable(flecs::id_t id, bool toggle=true) const
Enable an ID.
Definition builder.hpp:553
const Self & child_of(entity_t second) const
Shortcut for add(ChildOf, entity).
Definition builder.hpp:230
const Self & set(T &&value) const
Set a component for an entity.
Definition builder.hpp:678
const Self & depends_on(entity_t second) const
Shortcut for add(DependsOn, entity).
Definition builder.hpp:238
const Self & depends_on() const
Shortcut for add(DependsOn, entity).
Definition builder.hpp:267
const Self & auto_override(flecs::id_t id) const
Mark ID for auto-overriding.
Definition builder.hpp:354
const Self & set(const A &value) const
Set a pair for an entity.
Definition builder.hpp:749
const Self & disable() const
Disable a pair.
Definition builder.hpp:651
const Self & auto_override(flecs::entity_t first, flecs::entity_t second) const
Mark pair for auto-overriding.
Definition builder.hpp:364
const Self & auto_override() const
Mark pair for auto-overriding.
Definition builder.hpp:396
const Self & add() const
Add a component to an entity.
Definition builder.hpp:25
const Self & auto_override_second(flecs::entity_t first) const
Mark pair for auto-overriding.
Definition builder.hpp:407
const Self & assign_second(entity_t first, const Second &value) const
Assign a pair for an entity.
Definition builder.hpp:996
const Self & add(Second second) const
Add a pair.
Definition builder.hpp:90
const Self & set_auto_override(const A &val) const
Set pair, mark pair for auto-overriding.
Definition builder.hpp:470
const Self & set_second(entity_t first, const Second &value) const
Set a pair for an entity.
Definition builder.hpp:810
flecs::string_view name() const
Return the entity name.
entity_view()
Default constructor.
flecs::entity target(int32_t index=0) const
Get target for a given pair.
Definition impl.hpp:36
Entity.
Definition entity.hpp:30
entity()
Default constructor.
Definition entity.hpp:32
flecs::id_t id_
The raw ID value.
Definition decl.hpp:149
flecs::entity second() const
Get second element from a pair.
Definition impl.hpp:31
flecs::world_t * world_
World is optional, but guarantees that entity identifiers extracted from the ID are valid.
Definition decl.hpp:147
flecs::entity first() const
Get first element from a pair.
Definition impl.hpp:20
Trait to test if a type is constructible by Flecs.
Type that represents a pair.
Definition pair.hpp:36
enable_if_t< false==V, int > if_not_t
Convenience enable_if alias for negated conditions.
Definition utils.hpp:172
void assign(world_t *world, flecs::entity_t entity, T &&value, flecs::id_t id)
Assign a component value using move semantics.
Definition world.hpp:109
void set(world_t *world, flecs::entity_t entity, T &&value, flecs::id_t id)
Static helper functions to assign a component value.
Definition world.hpp:22