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
6#pragma once
7
8namespace flecs
9{
10
14template <typename Self>
16
17 using entity_view::entity_view;
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 {
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
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_);
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>
303 const Self& remove() const {
304 ecs_remove_id(this->world_, this->id_, _::type<T>::id(this->world_));
305 return to_base();
306 }
307
312 const Self& remove(entity_t entity) const {
313 ecs_remove_id(this->world_, this->id_, entity);
314 return to_base();
315 }
316
323 const Self& remove(entity_t first, entity_t second) const {
324 ecs_remove_pair(this->world_, this->id_, first, second);
325 return to_base();
326 }
327
334 template<typename First, typename Second>
335 const Self& remove() const {
336 return this->remove<First>(_::type<Second>::id(this->world_));
337 }
338
345 template<typename First, typename Second, if_not_t< is_enum<Second>::value > = 0>
346 const Self& remove(Second second) const {
347 return this->remove(_::type<First>::id(this->world_), second);
348 }
349
356 template<typename Second>
357 const Self& remove_second(flecs::entity_t first) const {
358 return this->remove(first, _::type<Second>::id(this->world_));
359 }
360
367 template<typename First, typename Second, if_t< is_enum<Second>::value > = 0>
368 const Self& remove(Second constant) const {
369 const auto& et = enum_type<Second>(this->world_);
370 flecs::entity_t second = et.entity(constant);
371 return this->remove<First>(second);
372 }
373
381 const Self& auto_override(flecs::id_t id) const {
382 return this->add(ECS_AUTO_OVERRIDE | id);
383 }
384
391 const Self& auto_override(flecs::entity_t first, flecs::entity_t second) const {
392 return this->auto_override(ecs_pair(first, second));
393 }
394
400 template <typename T>
401 const Self& auto_override() const {
402 return this->auto_override(_::type<T>::id(this->world_));
403 }
404
411 template <typename First>
412 const Self& auto_override(flecs::entity_t second) const {
413 return this->auto_override(_::type<First>::id(this->world_), second);
414 }
415
422 template <typename First, typename Second>
423 const Self& auto_override() const {
424 return this->auto_override<First>(_::type<Second>::id(this->world_));
425 }
426
433 template <typename T>
434 const Self& set_auto_override(const T& val) const {
435 this->auto_override<T>();
436 return this->set<T>(val);
437 }
438
445 template <typename T>
446 const Self& set_auto_override(T&& val) const {
447 this->auto_override<T>();
448 return this->set<T>(FLECS_FWD(val));
449 }
450
458 template <typename First>
459 const Self& set_auto_override(flecs::entity_t second, const First& val) const {
460 this->auto_override<First>(second);
461 return this->set<First>(second, val);
462 }
463
471 template <typename First>
472 const Self& set_auto_override(flecs::entity_t second, First&& val) const {
473 this->auto_override<First>(second);
474 return this->set<First>(second, FLECS_FWD(val));
475 }
476
484 template <typename First, typename Second, typename P = pair<First, Second>,
485 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value> = 0>
486 const Self& set_auto_override(const A& val) const {
487 this->auto_override<First, Second>();
488 return this->set<First, Second>(val);
489 }
490
498 template <typename First, typename Second, typename P = pair<First, Second>,
499 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value> = 0>
500 const Self& set_auto_override(A&& val) const {
501 this->auto_override<First, Second>();
502 return this->set<First, Second>(FLECS_FWD(val));
503 }
504
511 template <typename T, typename ... Args>
512 const Self& emplace_auto_override(Args&&... args) const {
513 this->auto_override<T>();
514
515 flecs::emplace<T>(this->world_, this->id_,
516 _::type<T>::id(this->world_), FLECS_FWD(args)...);
517
518 return to_base();
519 }
520
528 template <typename First, typename Second, typename P = pair<First, Second>,
529 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value> = 0,
530 typename ... Args>
531 const Self& emplace_auto_override(Args&&... args) const {
532 this->auto_override<First, Second>();
533
534 flecs::emplace<A>(this->world_, this->id_,
535 ecs_pair(_::type<First>::id(this->world_),
536 _::type<Second>::id(this->world_)),
537 FLECS_FWD(args)...);
538
539 return to_base();
540 }
541
546 const Self& enable() const {
547 ecs_enable(this->world_, this->id_, true);
548 return to_base();
549 }
550
555 const Self& disable() const {
556 ecs_enable(this->world_, this->id_, false);
557 return to_base();
558 }
559
569 const Self& enable(flecs::id_t id, bool toggle = true) const {
570 ecs_enable_id(this->world_, this->id_, id, toggle);
571 return to_base();
572 }
573
579 template<typename T>
580 const Self& enable() const {
581 return this->enable(_::type<T>::id(this->world_));
582 }
583
590 const Self& enable(flecs::id_t first, flecs::id_t second) const {
591 return this->enable(ecs_pair(first, second));
592 }
593
600 template<typename First>
601 const Self& enable(flecs::id_t second) const {
602 return this->enable(_::type<First>::id(world_), second);
603 }
604
611 template<typename First, typename Second>
612 const Self& enable() const {
613 return this->enable<First>(_::type<Second>::id(world_));
614 }
615
625 const Self& disable(flecs::id_t id) const {
626 return this->enable(id, false);
627 }
628
634 template<typename T>
635 const Self& disable() const {
636 return this->disable(_::type<T>::id(world_));
637 }
638
645 const Self& disable(flecs::id_t first, flecs::id_t second) const {
646 return this->disable(ecs_pair(first, second));
647 }
648
655 template<typename First>
656 const Self& disable(flecs::id_t second) const {
657 return this->disable(_::type<First>::id(world_), second);
658 }
659
666 template<typename First, typename Second>
667 const Self& disable() const {
668 return this->disable<First>(_::type<Second>::id(world_));
669 }
670
671 const Self& set_ptr(entity_t comp, size_t size, const void *ptr) const {
672 ecs_set_id(this->world_, this->id_, comp, size, ptr);
673 return to_base();
674 }
675
676 const Self& set_ptr(entity_t comp, const void *ptr) const {
677 const flecs::Component *cptr = ecs_get(
678 this->world_, comp, EcsComponent);
679
680 /* Can't set if it's not a component */
681 ecs_assert(cptr != NULL, ECS_INVALID_PARAMETER, NULL);
682
683 return set_ptr(comp, cptr->size, ptr);
684 }
685
686 template<typename T, if_t<is_actual<T>::value> = 0 >
687 const Self& set(T&& value) const {
688 flecs::set<T>(this->world_, this->id_, FLECS_FWD(value));
689 return to_base();
690 }
691
692 template<typename T, if_t<is_actual<T>::value > = 0>
693 const Self& set(const T& value) const {
694 flecs::set<T>(this->world_, this->id_, value);
695 return to_base();
696 }
697
698 template<typename T, typename A = actual_type_t<T>, if_not_t<
699 is_actual<T>::value > = 0>
700 const Self& set(A&& value) const {
701 flecs::set<T>(this->world_, this->id_, FLECS_FWD(value));
702 return to_base();
703 }
704
705 template<typename T, typename A = actual_type_t<T>, if_not_t<
706 is_actual<T>::value > = 0>
707 const Self& set(const A& value) const {
708 flecs::set<T>(this->world_, this->id_, value);
709 return to_base();
710 }
711
720 template <typename First, typename Second, typename P = pair<First, Second>,
721 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value> = 0>
722 const Self& set(A&& value) const {
723 flecs::set<P>(this->world_, this->id_, FLECS_FWD(value));
724 return to_base();
725 }
726
735 template <typename First, typename Second, typename P = pair<First, Second>,
736 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value> = 0>
737 const Self& set(const A& value) const {
738 flecs::set<P>(this->world_, this->id_, value);
739 return to_base();
740 }
741
750 template <typename First, typename Second, if_not_t< is_enum<Second>::value > = 0>
751 const Self& set(Second second, const First& value) const {
752 auto first = _::type<First>::id(this->world_);
753 flecs::set(this->world_, this->id_, value,
754 ecs_pair(first, second));
755 return to_base();
756 }
757
766 template <typename First, typename Second, if_not_t< is_enum<Second>::value > = 0>
767 const Self& set(Second second, First&& value) const {
768 auto first = _::type<First>::id(this->world_);
769 flecs::set(this->world_, this->id_, FLECS_FWD(value),
770 ecs_pair(first, second));
771 return to_base();
772 }
773
782 template <typename First, typename Second, if_t< is_enum<Second>::value > = 0>
783 const Self& set(Second constant, const First& value) const {
784 const auto& et = enum_type<Second>(this->world_);
785 flecs::entity_t second = et.entity(constant);
786 return set<First>(second, value);
787 }
788
797 template <typename Second>
798 const Self& set_second(entity_t first, const Second& value) const {
799 auto second = _::type<Second>::id(this->world_);
800 ecs_assert( ecs_get_type_info(world_, ecs_pair(first, second)) != NULL,
801 ECS_INVALID_PARAMETER, "pair is not a component");
802 ecs_assert( ecs_get_type_info(world_, ecs_pair(first, second))->component == second,
803 ECS_INVALID_PARAMETER, "type of pair is not Second");
804 flecs::set(this->world_, this->id_, value,
805 ecs_pair(first, second));
806 return to_base();
807 }
808
817 template <typename Second>
818 const Self& set_second(entity_t first, Second&& value) const {
819 auto second = _::type<Second>::id(this->world_);
820 ecs_assert( ecs_get_type_info(world_, ecs_pair(first, second)) != NULL,
821 ECS_INVALID_PARAMETER, "pair is not a component");
822 ecs_assert( ecs_get_type_info(world_, ecs_pair(first, second))->component == second,
823 ECS_INVALID_PARAMETER, "type of pair is not Second");
824 flecs::set(this->world_, this->id_, FLECS_FWD(value),
825 ecs_pair(first, second));
826 return to_base();
827 }
828
829 template <typename First, typename Second>
830 const Self& set_second(const Second& value) const {
831 flecs::set<pair_object<First, Second>>(this->world_, this->id_, value);
832 return to_base();
833 }
834
850 template <typename Func>
851 const Self& insert(const Func& func) const;
852
860 template<typename T, typename ... Args, typename A = actual_type_t<T>>
861 const Self& emplace(Args&&... args) const {
862 flecs::emplace<A>(this->world_, this->id_,
863 _::type<T>::id(this->world_), FLECS_FWD(args)...);
864 return to_base();
865 }
866
867 template <typename First, typename Second, typename ... Args, typename P = pair<First, Second>,
868 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value> = 0>
869 const Self& emplace(Args&&... args) const {
870 flecs::emplace<A>(this->world_, this->id_,
871 ecs_pair(_::type<First>::id(this->world_),
872 _::type<Second>::id(this->world_)),
873 FLECS_FWD(args)...);
874 return to_base();
875 }
876
877 template <typename First, typename ... Args>
878 const Self& emplace_first(flecs::entity_t second, Args&&... args) const {
879 auto first = _::type<First>::id(this->world_);
880 flecs::emplace<First>(this->world_, this->id_,
881 ecs_pair(first, second),
882 FLECS_FWD(args)...);
883 return to_base();
884 }
885
886 template <typename Second, typename ... Args>
887 const Self& emplace_second(flecs::entity_t first, Args&&... args) const {
888 auto second = _::type<Second>::id(this->world_);
889 ecs_assert( ecs_get_type_info(world_, ecs_pair(first, second)) != NULL,
890 ECS_INVALID_PARAMETER, "pair is not a component");
891 ecs_assert( ecs_get_type_info(world_, ecs_pair(first, second))->component == second,
892 ECS_INVALID_PARAMETER, "type of pair is not Second");
893 flecs::emplace<Second>(this->world_, this->id_,
894 ecs_pair(first, second),
895 FLECS_FWD(args)...);
896 return to_base();
897 }
898
904 template <typename Func>
905 const Self& with(const Func& func) const {
906 ecs_id_t prev = ecs_set_with(this->world_, this->id_);
907 func();
908 ecs_set_with(this->world_, prev);
909 return to_base();
910 }
911
918 template <typename First, typename Func>
919 const Self& with(const Func& func) const {
920 with(_::type<First>::id(this->world_), func);
921 return to_base();
922 }
923
930 template <typename Func>
931 const Self& with(entity_t first, const Func& func) const {
932 ecs_id_t prev = ecs_set_with(this->world_,
933 ecs_pair(first, this->id_));
934 func();
935 ecs_set_with(this->world_, prev);
936 return to_base();
937 }
938
940 template <typename Func>
941 const Self& scope(const Func& func) const {
942 ecs_entity_t prev = ecs_set_scope(this->world_, this->id_);
943 func();
944 ecs_set_scope(this->world_, prev);
945 return to_base();
946 }
947
950 return scoped_world(world_, id_);
951 }
952
953 /* Set the entity name.
954 */
955 const Self& set_name(const char *name) const {
956 ecs_set_name(this->world_, this->id_, name);
957 return to_base();
958 }
959
960 /* Set entity alias.
961 */
962 const Self& set_alias(const char *name) const {
963 ecs_set_alias(this->world_, this->id_, name);
964 return to_base();
965 }
966
967# ifdef FLECS_DOC
969# endif
970
971# ifdef FLECS_META
973# endif
974
975# ifdef FLECS_JSON
977# endif
978
980
981protected:
982 const Self& to_base() const {
983 return *static_cast<const Self*>(this);
984 }
985};
986
987}
component< T > & constant(const char *name, T value)
Add constant.
Definition component.inl:31
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:368
#define ecs_check(condition, error_code,...)
Check.
Definition log.h:415
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_id_t ecs_entity_t
An entity identifier.
Definition flecs.h:381
uint64_t ecs_id_t
Ids are the things that can be added to an entity.
Definition flecs.h:374
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.
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.
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 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:1523
ecs_size_t size
Component size.
Definition flecs.h:1524
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:531
const Self & disable() const
Disable an entity.
Definition builder.hpp:555
const Self & add(E value) const
Add pair for enum constant.
Definition builder.hpp:42
const Self & set(Second constant, const First &value) const
Set a pair for an entity.
Definition builder.hpp:783
const Self & auto_override(flecs::entity_t second) const
Mark pair for auto-overriding.
Definition builder.hpp:412
const Self & enable(flecs::id_t second) const
Enable a pair.
Definition builder.hpp:601
const Self & remove(Second constant) const
Remove a pair.
Definition builder.hpp:368
const Self & remove(entity_t first, entity_t second) const
Remove a pair.
Definition builder.hpp:323
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:346
const Self & emplace(Args &&... args) const
Emplace component.
Definition builder.hpp:861
const Self & set_auto_override(flecs::entity_t second, const First &val) const
Set pair, mark component for auto-overriding.
Definition builder.hpp:459
const Self & disable(flecs::id_t first, flecs::id_t second) const
Disable a pair.
Definition builder.hpp:645
const Self & emplace_auto_override(Args &&... args) const
Emplace component, mark component for auto-overriding.
Definition builder.hpp:512
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:546
const Self & remove_second(flecs::entity_t first) const
Removes a pair.
Definition builder.hpp:357
const Self & slot_of(entity_t second) const
Shortcut for add(SlotOf, entity).
Definition builder.hpp:257
const Self & auto_override() const
Mark component for auto-overriding.
Definition builder.hpp:401
const Self & enable() const
Enable a component.
Definition builder.hpp:580
scoped_world scope() const
Return world scoped to entity.
Definition builder.hpp:949
const Self & child_of() const
Shortcut for add(ChildOf, entity).
Definition builder.hpp:276
const Self & set(A &&value) const
Set a pair for an entity.
Definition builder.hpp:722
const Self & set_auto_override(A &&val) const
Set component, mark component for auto-overriding.
Definition builder.hpp:500
const Self & enable() const
Enable a pair.
Definition builder.hpp:612
const Self & enable(flecs::id_t first, flecs::id_t second) const
Enable a pair.
Definition builder.hpp:590
const Self & remove() const
Remove a component from an entity.
Definition builder.hpp:303
const Self & disable(flecs::id_t id) const
Disable an id.
Definition builder.hpp:625
const Self & slot() const
Shortcut for add(SlotOf, target(ChildOf)).
Definition builder.hpp:263
const Self & set(Second second, const First &value) const
Set a pair for an entity.
Definition builder.hpp:751
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:818
const Self & set_auto_override(T &&val) const
Set component, mark component for auto-overriding.
Definition builder.hpp:446
const Self & add_if(bool cond) const
Conditional add.
Definition builder.hpp:143
const Self & remove() const
Removes a pair.
Definition builder.hpp:335
const Self & disable() const
Disable a component.
Definition builder.hpp:635
const Self & add(id_t component) const
Add an entity to an entity.
Definition builder.hpp:56
const Self & add(entity_t first, entity_t second) const
Add a pair.
Definition builder.hpp:67
const Self & with(entity_t first, const Func &func) const
Entities created in function will have (first, this).
Definition builder.hpp:931
const Self & set(Second second, First &&value) const
Set a pair for an entity.
Definition builder.hpp:767
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 ran with the scope set to the current entity.
Definition builder.hpp:941
const Self & add_if(bool cond, flecs::entity_t second) const
Conditional add.
Definition builder.hpp:181
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 & with(const Func &func) const
Entities created in function will have (First, this).
Definition builder.hpp:919
const Self & disable(flecs::id_t second) const
Disable a pair.
Definition builder.hpp:656
const Self & set_auto_override(const T &val) const
Set component, mark component for auto-overriding.
Definition builder.hpp:434
const Self & remove(entity_t entity) const
Remove an entity from an entity.
Definition builder.hpp:312
const Self & set_auto_override(flecs::entity_t second, First &&val) const
Set pair, mark component for auto-overriding.
Definition builder.hpp:472
const Self & enable(flecs::id_t id, bool toggle=true) const
Enable an id.
Definition builder.hpp:569
const Self & child_of(entity_t second) const
Shortcut for add(ChildOf, entity).
Definition builder.hpp:230
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:285
const Self & auto_override(flecs::id_t id) const
Mark id for auto-overriding.
Definition builder.hpp:381
const Self & set(const A &value) const
Set a pair for an entity.
Definition builder.hpp:737
const Self & disable() const
Disable a pair.
Definition builder.hpp:667
const Self & auto_override(flecs::entity_t first, flecs::entity_t second) const
Mark pair for auto-overriding.
Definition builder.hpp:391
const Self & auto_override() const
Mark pair for auto-overriding.
Definition builder.hpp:423
const Self & slot_of() const
Shortcut for add(SlotOf, entity).
Definition builder.hpp:294
const Self & add() const
Add a component to an entity.
Definition builder.hpp:25
const Self & add(Second second) const
Add a pair.
Definition builder.hpp:90
const Self & set_auto_override(const A &val) const
Set component, mark component for auto-overriding.
Definition builder.hpp:486
const Self & with(const Func &func) const
Entities created in function will have the current entity.
Definition builder.hpp:905
const Self & set_second(entity_t first, const Second &value) const
Set a pair for an entity.
Definition builder.hpp:798
flecs::string_view name() const
Return the entity name.
flecs::entity target(int32_t index=0) const
Get target for a given pair.
Definition impl.hpp:52
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:1242