Flecs: include/flecs/addons/cpp/mixins/entity/builder.hpp Source File
Description: A fast entity component system (ECS) for C & C++

| Flecs v4.0 A fast entity component system (ECS) for C & C++

Loading...
Searching...
No Matches
builder.hpp
Go to the documentation of this file.
1
5
6#pragma once
7
8namespace flecs
9{
10
12 * @ingroup cpp_entities
13 */
14template <typename Self>
15 struct entity_builder : entity_view {
16
17 using entity_view::entity_view;
18
21
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
32 /** Add pair for enum constant.
33 * This operation will add a pair to the entity where the first element is
34 * the enumeration type, and the second element the enumeration constant.
35 *
36 * The operation may be used with regular (C style) enumerations as well as
37 * enum classes.
38 *
39 * @param value The enumeration value.
40 */
41 template <typename E, if_t< is_enum<E>::value > = 0>
42 const Self& add(E value) const {
43 flecs::entity_t first = _::type<E>::id(this->world_);
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, "Component was not found in reflection data.");
48 return this->add(first, second);
49 }
50
51
51 /** Add an entity to an entity.
52 * Add an entity to the entity. This is typically used for tagging.
53 *
54 * @param component The component to add.
55 */
56 const Self& add(id_t component) const {
57 ecs_add_id(this->world_, this->id_, component);
58 return to_base();
59 }
60
62 * This operation adds a pair to the entity.
63 *
64 * @param first The first element of the pair.
65 * @param second The second element of the pair.
66 */
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
73
73 * This operation adds a pair to the entity.
74 *
75 * @tparam First The first element of the pair
76 * @tparam Second The second element of the pair
77 */
78 template<typename First, typename Second>
79 const Self& add() const {
80 return this->add<First>(_::type<Second>::id(this->world_));
81 }
82
83
85 *
86 * @tparam First The first element of the pair
87 * @param second The second element of the pair.
88 */
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
96
96 /** Add a pair.
97 * This operation adds a pair to the entity that consists out of a tag
98 * combined with an enum constant.
99 *
100 * @tparam First The first element of the pair
101 * @param constant the enum constant.
102 */
103 template<typename First, typename Second, if_t< is_enum<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_);
249 flecs::entity_t target = et.entity(second);
250 return depends_on(target);
251 }
252
257 const Self& slot_of(entity_t second) const {
258 return this->add(flecs::SlotOf, second);
259 }
260
263 const Self& slot() const {
264 ecs_check(ecs_get_target(world_, id_, flecs::ChildOf, 0),
265 ECS_INVALID_PARAMETER, "add ChildOf pair before using slot()");
266 return this->slot_of(this->target(flecs::ChildOf));
267 error:
268 return to_base();
269 }
270
275 template <typename T>
276 const Self& child_of() const {
277 return this->child_of(_::type<T>::id(this->world_));
278 }
279
284 template <typename T>
285 const Self& depends_on() const {
286 return this->depends_on(_::type<T>::id(this->world_));
287 }
288
293 template <typename T>
294 const Self& slot_of() const {
295 return this->slot_of(_::type<T>::id(this->world_));
296 }
297
302 template <typename T, if_not_t< is_enum<T>::value > = 0>
303 const Self& remove() const {
304 ecs_remove_id(this->world_, this->id_, _::type<T>::id(this->world_));
305 return to_base();
306 }
307
313 template <typename E, if_t< is_enum<E>::value > = 0>
314 const Self& remove() const {
315 flecs::entity_t first = _::type<E>::id(this->world_);
316 return this->remove(first, flecs::Wildcard);
317 }
318
323 const Self& remove(entity_t entity) const {
324 ecs_remove_id(this->world_, this->id_, entity);
325 return to_base();
326 }
327
334 const Self& remove(entity_t first, entity_t second) const {
335 ecs_remove_pair(this->world_, this->id_, first, second);
336 return to_base();
337 }
338
345 template<typename First, typename Second>
346 const Self& remove() const {
347 return this->remove<First>(_::type<Second>::id(this->world_));
348 }
349
356 template<typename First, typename Second, if_not_t< is_enum<Second>::value > = 0>
357 const Self& remove(Second second) const {
358 return this->remove(_::type<First>::id(this->world_), second);
359 }
360
367 template<typename Second>
368 const Self& remove_second(flecs::entity_t first) const {
369 return this->remove(first, _::type<Second>::id(this->world_));
370 }
371
378 template<typename First, typename Second, if_t< is_enum<Second>::value > = 0>
379 const Self& remove(Second constant) const {
380 const auto& et = enum_type<Second>(this->world_);
381 flecs::entity_t second = et.entity(constant);
382 return this->remove<First>(second);
383 }
384
392 const Self& auto_override(flecs::id_t id) const {
393 return this->add(ECS_AUTO_OVERRIDE | id);
394 }
395
402 const Self& auto_override(flecs::entity_t first, flecs::entity_t second) const {
403 return this->auto_override(ecs_pair(first, second));
404 }
405
411 template <typename T>
412 const Self& auto_override() const {
413 return this->auto_override(_::type<T>::id(this->world_));
414 }
415
422 template <typename First>
423 const Self& auto_override(flecs::entity_t second) const {
424 return this->auto_override(_::type<First>::id(this->world_), second);
425 }
426
433 template <typename First, typename Second>
434 const Self& auto_override() const {
435 return this->auto_override<First>(_::type<Second>::id(this->world_));
436 }
437
444 template <typename T>
445 const Self& set_auto_override(const T& val) const {
446 this->auto_override<T>();
447 return this->set<T>(val);
448 }
449
456 template <typename T>
457 const Self& set_auto_override(T&& val) const {
458 this->auto_override<T>();
459 return this->set<T>(FLECS_FWD(val));
460 }
461
469 template <typename First>
470 const Self& set_auto_override(flecs::entity_t second, const First& val) const {
471 this->auto_override<First>(second);
472 return this->set<First>(second, val);
473 }
474
482 template <typename First>
483 const Self& set_auto_override(flecs::entity_t second, First&& val) const {
484 this->auto_override<First>(second);
485 return this->set<First>(second, FLECS_FWD(val));
486 }
487
495 template <typename First, typename Second, typename P = pair<First, Second>,
496 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value> = 0>
497 const Self& set_auto_override(const A& val) const {
498 this->auto_override<First, Second>();
499 return this->set<First, Second>(val);
500 }
501
509 template <typename First, typename Second, typename P = pair<First, Second>,
510 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value> = 0>
511 const Self& set_auto_override(A&& val) const {
512 this->auto_override<First, Second>();
513 return this->set<First, Second>(FLECS_FWD(val));
514 }
515
522 template <typename T, typename ... Args>
523 const Self& emplace_auto_override(Args&&... args) const {
524 this->auto_override<T>();
525
526 flecs::emplace<T>(this->world_, this->id_,
527 _::type<T>::id(this->world_), FLECS_FWD(args)...);
528
529 return to_base();
530 }
531
539 template <typename First, typename Second, typename P = pair<First, Second>,
540 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value> = 0,
541 typename ... Args>
542 const Self& emplace_auto_override(Args&&... args) const {
543 this->auto_override<First, Second>();
544
545 flecs::emplace<A>(this->world_, this->id_,
546 ecs_pair(_::type<First>::id(this->world_),
547 _::type<Second>::id(this->world_)),
548 FLECS_FWD(args)...);
549
550 return to_base();
551 }
552
557 const Self& enable() const {
558 ecs_enable(this->world_, this->id_, true);
559 return to_base();
560 }
561
566 const Self& disable() const {
567 ecs_enable(this->world_, this->id_, false);
568 return to_base();
569 }
570
580 const Self& enable(flecs::id_t id, bool toggle = true) const {
581 ecs_enable_id(this->world_, this->id_, id, toggle);
582 return to_base();
583 }
584
590 template<typename T>
591 const Self& enable() const {
592 return this->enable(_::type<T>::id(this->world_));
593 }
594
601 const Self& enable(flecs::id_t first, flecs::id_t second) const {
602 return this->enable(ecs_pair(first, second));
603 }
604
611 template<typename First>
612 const Self& enable(flecs::id_t second) const {
613 return this->enable(_::type<First>::id(world_), second);
614 }
615
622 template<typename First, typename Second>
623 const Self& enable() const {
624 return this->enable<First>(_::type<Second>::id(world_));
625 }
626
636 const Self& disable(flecs::id_t id) const {
637 return this->enable(id, false);
638 }
639
645 template<typename T>
646 const Self& disable() const {
647 return this->disable(_::type<T>::id(world_));
648 }
649
656 const Self& disable(flecs::id_t first, flecs::id_t second) const {
657 return this->disable(ecs_pair(first, second));
658 }
659
666 template<typename First>
667 const Self& disable(flecs::id_t second) const {
668 return this->disable(_::type<First>::id(world_), second);
669 }
670
677 template<typename First, typename Second>
678 const Self& disable() const {
679 return this->disable<First>(_::type<Second>::id(world_));
680 }
681
682 const Self& set_ptr(entity_t comp, size_t size, const void *ptr) const {
683 ecs_set_id(this->world_, this->id_, comp, size, ptr);
684 return to_base();
685 }
686
687 const Self& set_ptr(entity_t comp, const void *ptr) const {
688 const flecs::Component *cptr = ecs_get(
689 this->world_, comp, EcsComponent);
690
691 /* Can't set if it's not a component */
692 ecs_assert(cptr != NULL, ECS_INVALID_PARAMETER, NULL);
693
694 return set_ptr(comp, cptr->size, ptr);
695 }
696
697 template<typename T, if_t<is_actual<T>::value> = 0 >
698 const Self& set(T&& value) const {
699 flecs::set<T>(this->world_, this->id_, FLECS_FWD(value));
700 return to_base();
701 }
702
703 template<typename T, if_t<is_actual<T>::value > = 0>
704 const Self& set(const T& value) const {
705 flecs::set<T>(this->world_, this->id_, value);
706 return to_base();
707 }
708
709 template<typename T, typename A = actual_type_t<T>, if_not_t<
710 is_actual<T>::value > = 0>
711 const Self& set(A&& value) const {
712 flecs::set<T>(this->world_, this->id_, FLECS_FWD(value));
713 return to_base();
714 }
715
716 template<typename T, typename A = actual_type_t<T>, if_not_t<
717 is_actual<T>::value > = 0>
718 const Self& set(const A& value) const {
719 flecs::set<T>(this->world_, this->id_, value);
720 return to_base();
721 }
722
731 template <typename First, typename Second, typename P = pair<First, Second>,
732 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value> = 0>
733 const Self& set(A&& value) const {
734 flecs::set<P>(this->world_, this->id_, FLECS_FWD(value));
735 return to_base();
736 }
737
746 template <typename First, typename Second, typename P = pair<First, Second>,
747 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value> = 0>
748 const Self& set(const A& value) const {
749 flecs::set<P>(this->world_, this->id_, value);
750 return to_base();
751 }
752
761 template <typename First, typename Second, if_not_t< is_enum<Second>::value > = 0>
762 const Self& set(Second second, const First& value) const {
763 auto first = _::type<First>::id(this->world_);
764 flecs::set(this->world_, this->id_, value,
765 ecs_pair(first, second));
766 return to_base();
767 }
768
777 template <typename First, typename Second, if_not_t< is_enum<Second>::value > = 0>
778 const Self& set(Second second, First&& value) const {
779 auto first = _::type<First>::id(this->world_);
780 flecs::set(this->world_, this->id_, FLECS_FWD(value),
781 ecs_pair(first, second));
782 return to_base();
783 }
784
793 template <typename First, typename Second, if_t< is_enum<Second>::value > = 0>
794 const Self& set(Second constant, const First& value) const {
795 const auto& et = enum_type<Second>(this->world_);
796 flecs::entity_t second = et.entity(constant);
797 return set<First>(second, value);
798 }
799
808 template <typename Second>
809 const Self& set_second(entity_t first, const Second& value) const {
810 auto second = _::type<Second>::id(this->world_);
811 ecs_assert( ecs_get_type_info(world_, ecs_pair(first, second)) != NULL,
812 ECS_INVALID_PARAMETER, "pair is not a component");
813 ecs_assert( ecs_get_type_info(world_, ecs_pair(first, second))->component == second,
814 ECS_INVALID_PARAMETER, "type of pair is not Second");
815 flecs::set(this->world_, this->id_, value,
816 ecs_pair(first, second));
817 return to_base();
818 }
819
828 template <typename Second>
829 const Self& set_second(entity_t first, Second&& value) const {
830 auto second = _::type<Second>::id(this->world_);
831 ecs_assert( ecs_get_type_info(world_, ecs_pair(first, second)) != NULL,
832 ECS_INVALID_PARAMETER, "pair is not a component");
833 ecs_assert( ecs_get_type_info(world_, ecs_pair(first, second))->component == second,
834 ECS_INVALID_PARAMETER, "type of pair is not Second");
835 flecs::set(this->world_, this->id_, FLECS_FWD(value),
836 ecs_pair(first, second));
837 return to_base();
838 }
839
840 template <typename First, typename Second>
841 const Self& set_second(const Second& value) const {
842 flecs::set<pair_object<First, Second>>(this->world_, this->id_, value);
843 return to_base();
844 }
845
861 template <typename Func>
862 const Self& insert(const Func& func) const;
863
885 template<typename T, typename ... Args, typename A = actual_type_t<T>>
886 const Self& emplace(Args&&... args) const {
887 flecs::emplace<A>(this->world_, this->id_,
888 _::type<T>::id(this->world_), FLECS_FWD(args)...);
889 return to_base();
890 }
891
892 template <typename First, typename Second, typename ... Args, typename P = pair<First, Second>,
893 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value> = 0>
894 const Self& emplace(Args&&... args) const {
895 flecs::emplace<A>(this->world_, this->id_,
896 ecs_pair(_::type<First>::id(this->world_),
897 _::type<Second>::id(this->world_)),
898 FLECS_FWD(args)...);
899 return to_base();
900 }
901
902 template <typename First, typename ... Args>
903 const Self& emplace_first(flecs::entity_t second, Args&&... args) const {
904 auto first = _::type<First>::id(this->world_);
905 flecs::emplace<First>(this->world_, this->id_,
906 ecs_pair(first, second),
907 FLECS_FWD(args)...);
908 return to_base();
909 }
910
911 template <typename Second, typename ... Args>
912 const Self& emplace_second(flecs::entity_t first, Args&&... args) const {
913 auto second = _::type<Second>::id(this->world_);
914 ecs_assert( ecs_get_type_info(world_, ecs_pair(first, second)) != NULL,
915 ECS_INVALID_PARAMETER, "pair is not a component");
916 ecs_assert( ecs_get_type_info(world_, ecs_pair(first, second))->component == second,
917 ECS_INVALID_PARAMETER, "type of pair is not Second");
918 flecs::emplace<Second>(this->world_, this->id_,
919 ecs_pair(first, second),
920 FLECS_FWD(args)...);
921 return to_base();
922 }
923
929 template <typename Func>
930 const Self& with(const Func& func) const {
931 ecs_id_t prev = ecs_set_with(this->world_, this->id_);
932 func();
933 ecs_set_with(this->world_, prev);
934 return to_base();
935 }
936
943 template <typename First, typename Func>
944 const Self& with(const Func& func) const {
945 with(_::type<First>::id(this->world_), func);
946 return to_base();
947 }
948
955 template <typename Func>
956 const Self& with(entity_t first, const Func& func) const {
957 ecs_id_t prev = ecs_set_with(this->world_,
958 ecs_pair(first, this->id_));
959 func();
960 ecs_set_with(this->world_, prev);
961 return to_base();
962 }
963
965 template <typename Func>
966 const Self& scope(const Func& func) const {
967 ecs_entity_t prev = ecs_set_scope(this->world_, this->id_);
968 func();
969 ecs_set_scope(this->world_, prev);
970 return to_base();
971 }
972
974 scoped_world scope() const {
975 return scoped_world(world_, id_);
976 }
977
978 /* Set the entity name.
979 */
980 const Self& set_name(const char *name) const {
981 ecs_set_name(this->world_, this->id_, name);
982 return to_base();
983 }
984
985 /* Set entity alias.
986 */
987 const Self& set_alias(const char *name) const {
988 ecs_set_alias(this->world_, this->id_, name);
989 return to_base();
990 }
991
992# ifdef FLECS_DOC
993# include "../doc/entity_builder.inl"
994# endif
995
996# ifdef FLECS_META
997# include "../meta/entity_builder.inl"
998# endif
999
1000# ifdef FLECS_JSON
1001# include "../json/entity_builder.inl"
1002# endif
1003
1004# include "../event/entity_builder.inl"
1005
1006protected:
1007 const Self& to_base() const {
1008 return *static_cast<const Self*>(this);
1009 }
1010};
1011
1012}
entity_builder.inl
Doc entity builder mixin.
entity_builder.inl
Event entity mixin.
ecs_set_with
ecs_entity_t ecs_set_with(ecs_world_t *world, ecs_id_t id)
Set current with id.
ecs_add_id
void ecs_add_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
Add a (component) id to an entity.
ecs_remove_id
void ecs_remove_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
Remove a (component) id from an entity.
ecs_assert
#define ecs_assert(condition, error_code,...)
Assert.
Definition log.h:368
ecs_check
#define ecs_check(condition, error_code,...)
Check.
Definition log.h:415
ecs_get_type_info
const ecs_type_info_t * ecs_get_type_info(const ecs_world_t *world, ecs_id_t id)
Get the type for an id.
ecs_entity_t
ecs_id_t ecs_entity_t
An entity identifier.
Definition flecs.h:346
ecs_id_t
uint64_t ecs_id_t
Ids are the things that can be added to an entity.
Definition flecs.h:339
flecs::component::constant
untyped_component & constant(const char *name, int32_t value)
Add constant.
Definition untyped_component.inl:191
ecs_enable_id
void ecs_enable_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t id, bool enable)
Enable or disable component.
ecs_enable
void ecs_enable(ecs_world_t *world, ecs_entity_t entity, bool enabled)
Enable or disable entity.
ecs_get_target
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.
ecs_has_id
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_set_id
void 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.
ECS_AUTO_OVERRIDE
const ecs_id_t ECS_AUTO_OVERRIDE
Automatically override component when it is inherited.
ecs_set_alias
void ecs_set_alias(ecs_world_t *world, ecs_entity_t entity, const char *alias)
Set alias for entity.
ecs_set_name
ecs_entity_t ecs_set_name(ecs_world_t *world, ecs_entity_t entity, const char *name)
Set the name of an entity.
ecs_set_scope
ecs_entity_t ecs_set_scope(ecs_world_t *world, ecs_entity_t scope)
Set the current scope.
entity_builder.inl
JSON entity mixin.
entity_builder.inl
Meta entity builder mixin.
EcsComponent
Component information.
Definition flecs.h:1486
EcsComponent::size
ecs_size_t size
Component size.
Definition flecs.h:1487
flecs::_::type
Definition flecs.hpp:38
flecs::component
Component class.
Definition flecs.hpp:30
flecs::entity_builder
Entity builder.
Definition builder.hpp:15
flecs::entity_builder::emplace_auto_override
const Self & emplace_auto_override(Args &&... args) const
Emplace pair, mark pair for auto-overriding.
Definition builder.hpp:542
flecs::entity_builder::disable
const Self & disable() const
Disable an entity.
Definition builder.hpp:566
flecs::entity_builder::add
const Self & add(E value) const
Add pair for enum constant.
Definition builder.hpp:42
flecs::entity_builder::set
const Self & set(Second constant, const First &value) const
Set a pair for an entity.
Definition builder.hpp:794
flecs::entity_builder::auto_override
const Self & auto_override(flecs::entity_t second) const
Mark pair for auto-overriding.
Definition builder.hpp:423
flecs::entity_builder::enable
const Self & enable(flecs::id_t second) const
Enable a pair.
Definition builder.hpp:612
flecs::entity_builder::remove
const Self & remove(Second constant) const
Remove a pair.
Definition builder.hpp:379
flecs::entity_builder::remove
const Self & remove(entity_t first, entity_t second) const
Remove a pair.
Definition builder.hpp:334
flecs::entity_builder::add_if
const Self & add_if(bool cond, E constant) const
Conditional add.
Definition builder.hpp:204
flecs::entity_builder::remove
const Self & remove(Second second) const
Remove a pair.
Definition builder.hpp:357
flecs::entity_builder::emplace
const Self & emplace(Args &&... args) const
Emplace component.
Definition builder.hpp:886
flecs::entity_builder::set_auto_override
const Self & set_auto_override(flecs::entity_t second, const First &val) const
Set pair, mark component for auto-overriding.
Definition builder.hpp:470
flecs::entity_builder::disable
const Self & disable(flecs::id_t first, flecs::id_t second) const
Disable a pair.
Definition builder.hpp:656
flecs::entity_builder::emplace_auto_override
const Self & emplace_auto_override(Args &&... args) const
Emplace component, mark component for auto-overriding.
Definition builder.hpp:523
flecs::entity_builder::add
const Self & add() const
Add a pair.
Definition builder.hpp:79
flecs::entity_builder::is_a
const Self & is_a() const
Shortcut for add(IsA, entity).
Definition builder.hpp:222
flecs::entity_builder::enable
const Self & enable() const
Enable an entity.
Definition builder.hpp:557
flecs::entity_builder::remove_second
const Self & remove_second(flecs::entity_t first) const
Removes a pair.
Definition builder.hpp:368
flecs::entity_builder::slot_of
const Self & slot_of(entity_t second) const
Shortcut for add(SlotOf, entity).
Definition builder.hpp:257
flecs::entity_builder::auto_override
const Self & auto_override() const
Mark component for auto-overriding.
Definition builder.hpp:412
flecs::entity_builder::enable
const Self & enable() const
Enable a component.
Definition builder.hpp:591
flecs::entity_builder::scope
scoped_world scope() const
Return world scoped to entity.
Definition builder.hpp:974
flecs::entity_builder::child_of
const Self & child_of() const
Shortcut for add(ChildOf, entity).
Definition builder.hpp:276
flecs::entity_builder::set
const Self & set(A &&value) const
Set a pair for an entity.
Definition builder.hpp:733
flecs::entity_builder::set_auto_override
const Self & set_auto_override(A &&val) const
Set component, mark component for auto-overriding.
Definition builder.hpp:511
flecs::entity_builder::enable
const Self & enable() const
Enable a pair.
Definition builder.hpp:623
flecs::entity_builder::enable
const Self & enable(flecs::id_t first, flecs::id_t second) const
Enable a pair.
Definition builder.hpp:601
flecs::entity_builder::disable
const Self & disable(flecs::id_t id) const
Disable an id.
Definition builder.hpp:636
flecs::entity_builder::slot
const Self & slot() const
Shortcut for add(SlotOf, target(ChildOf)).
Definition builder.hpp:263
flecs::entity_builder::set
const Self & set(Second second, const First &value) const
Set a pair for an entity.
Definition builder.hpp:762
flecs::entity_builder::add_if
const Self & add_if(bool cond) const
Conditional add.
Definition builder.hpp:193
flecs::entity_builder::is_a
const Self & is_a(entity_t second) const
Shortcut for add(IsA, entity).
Definition builder.hpp:213
flecs::entity_builder::add
const Self & add(Second constant) const
Add a pair.
Definition builder.hpp:104
flecs::entity_builder::depends_on
const Self & depends_on(E second) const
Shortcut for add(DependsOn, entity).
Definition builder.hpp:247
flecs::entity_builder::add_if
const Self & add_if(bool cond, flecs::entity_t first, flecs::entity_t second) const
Conditional add.
Definition builder.hpp:158
flecs::entity_builder::set_second
const Self & set_second(entity_t first, Second &&value) const
Set a pair for an entity.
Definition builder.hpp:829
flecs::entity_builder::set_auto_override
const Self & set_auto_override(T &&val) const
Set component, mark component for auto-overriding.
Definition builder.hpp:457
flecs::entity_builder::add_if
const Self & add_if(bool cond) const
Conditional add.
Definition builder.hpp:143
flecs::entity_builder::remove
const Self & remove() const
Remove a component from an entity.
Definition builder.hpp:303
flecs::entity_builder::disable
const Self & disable() const
Disable a component.
Definition builder.hpp:646
flecs::entity_builder::add
const Self & add(id_t component) const
Add an entity to an entity.
Definition builder.hpp:56
flecs::entity_builder::add
const Self & add(entity_t first, entity_t second) const
Add a pair.
Definition builder.hpp:67
flecs::entity_builder::with
const Self & with(entity_t first, const Func &func) const
Entities created in function will have (first, this).
Definition builder.hpp:956
flecs::entity_builder::set
const Self & set(Second second, First &&value) const
Set a pair for an entity.
Definition builder.hpp:778
flecs::entity_builder::insert
const Self & insert(const Func &func) const
Set 1..N components.
Definition impl.hpp:17
flecs::entity_builder::scope
const Self & scope(const Func &func) const
The function will be ran with the scope set to the current entity.
Definition builder.hpp:966
flecs::entity_builder::add_if
const Self & add_if(bool cond, flecs::entity_t second) const
Conditional add.
Definition builder.hpp:181
flecs::entity_builder::add_second
const Self & add_second(flecs::entity_t first) const
Add a pair.
Definition builder.hpp:118
flecs::entity_builder::add_if
const Self & add_if(bool cond, flecs::id_t component) const
Conditional add.
Definition builder.hpp:128
flecs::entity_builder::with
const Self & with(const Func &func) const
Entities created in function will have (First, this).
Definition builder.hpp:944
flecs::entity_builder::disable
const Self & disable(flecs::id_t second) const
Disable a pair.
Definition builder.hpp:667
flecs::entity_builder::set_auto_override
const Self & set_auto_override(const T &val) const
Set component, mark component for auto-overriding.
Definition builder.hpp:445
flecs::entity_builder::remove
const Self & remove(entity_t entity) const
Remove an entity from an entity.
Definition builder.hpp:323
flecs::entity_builder::set_auto_override
const Self & set_auto_override(flecs::entity_t second, First &&val) const
Set pair, mark component for auto-overriding.
Definition builder.hpp:483
flecs::entity_builder::enable
const Self & enable(flecs::id_t id, bool toggle=true) const
Enable an id.
Definition builder.hpp:580
flecs::entity_builder::child_of
const Self & child_of(entity_t second) const
Shortcut for add(ChildOf, entity).
Definition builder.hpp:230
flecs::entity_builder::depends_on
const Self & depends_on(entity_t second) const
Shortcut for add(DependsOn, entity).
Definition builder.hpp:238
flecs::entity_builder::depends_on
const Self & depends_on() const
Shortcut for add(DependsOn, entity).
Definition builder.hpp:285
flecs::entity_builder::auto_override
const Self & auto_override(flecs::id_t id) const
Mark id for auto-overriding.
Definition builder.hpp:392
flecs::entity_builder::set
const Self & set(const A &value) const
Set a pair for an entity.
Definition builder.hpp:748
flecs::entity_builder::disable
const Self & disable() const
Disable a pair.
Definition builder.hpp:678
flecs::entity_builder::auto_override
const Self & auto_override(flecs::entity_t first, flecs::entity_t second) const
Mark pair for auto-overriding.
Definition builder.hpp:402
flecs::entity_builder::auto_override
const Self & auto_override() const
Mark pair for auto-overriding.
Definition builder.hpp:434
flecs::entity_builder::slot_of
const Self & slot_of() const
Shortcut for add(SlotOf, entity).
Definition builder.hpp:294
flecs::entity_builder::add
const Self & add() const
Add a component to an entity.
Definition builder.hpp:25
flecs::entity_builder::add
const Self & add(Second second) const
Add a pair.
Definition builder.hpp:90
flecs::entity_builder::set_auto_override
const Self & set_auto_override(const A &val) const
Set component, mark component for auto-overriding.
Definition builder.hpp:497
flecs::entity_builder::with
const Self & with(const Func &func) const
Entities created in function will have the current entity.
Definition builder.hpp:930
flecs::entity_builder::set_second
const Self & set_second(entity_t first, const Second &value) const
Set a pair for an entity.
Definition builder.hpp:809
flecs::entity_view::name
flecs::string_view name() const
Return the entity name.
Definition entity_view.hpp:78
flecs::entity_view::target
flecs::entity target(int32_t index=0) const
Get target for a given pair.
Definition impl.hpp:46
flecs::entity
Entity.
Definition entity.hpp:30
flecs::id::second
flecs::entity second() const
Get second element from a pair.
Definition impl.hpp:31
flecs::id::first
flecs::entity first() const
Get first element from a pair.
Definition impl.hpp:20
flecs::pair
Type that represents a pair.
Definition pair.hpp:36
flecs::scoped_world
Scoped world.
Definition world.hpp:1234