14template <
typename Self>
17 using entity_view::entity_view;
27 "cannot default construct type: add T::T() or use emplace<T>()");
49 ecs_add_pair(this->m_world, this->m_id,
first,
second);
59 template<
typename First,
typename Second>
70 template<typename First, typename Second, if_not_t< is_enum<Second>::value > = 0>
73 "cannot default construct type: add T::T() or use emplace<T>()");
84 template<typename First, typename Second, if_t< is_enum<Second>::value > = 0>
85 Self&
add(Second constant) {
87 "cannot default construct type: add T::T() or use emplace<T>()");
88 const auto& et = enum_type<Second>(this->m_world);
89 return this->add<First>(et.entity(constant));
98 template<
typename Second>
111 return this->
add(component);
113 return this->
remove(component);
123 template <
typename T>
126 return this->add<T>();
128 return this->remove<T>();
161 template <
typename First>
173 template <
typename First,
typename Second>
184 template <typename E, if_t< is_enum<E>::value > = 0>
186 const auto& et = enum_type<E>(this->m_world);
187 return this->add_if<E>(cond, et.entity(constant));
202 template <
typename T>
212 return this->
add(flecs::ChildOf,
second);
220 return this->
add(flecs::DependsOn,
second);
235 ECS_INVALID_PARAMETER,
"add ChildOf pair before using slot()");
245 template <
typename T>
254 template <
typename T>
263 template <
typename T>
272 template <typename T, if_not_t< is_enum<T>::value > = 0>
294 ecs_remove_pair(this->m_world, this->m_id,
first,
second);
304 template<
typename First,
typename Second>
315 template<typename First, typename Second, if_not_t< is_enum<Second>::value > = 0>
326 template<
typename Second>
337 template<typename First, typename Second, if_t< is_enum<Second>::value > = 0>
339 const auto& et = enum_type<Second>(this->m_world);
340 flecs::entity_t
second = et.entity(constant);
341 return this->remove<First>(
second);
351 Self&
override(flecs::id_t
id) {
370 template <
typename T>
381 template <
typename First>
392 template <
typename First,
typename Second>
402 template <
typename T>
405 return this->set<T>(val);
413 template <
typename T>
416 return this->set<T>(FLECS_FWD(val));
425 template <
typename First>
427 this->override<First>(
second);
428 return this->set<First>(
second, val);
437 template <
typename First>
439 this->override<First>(
second);
440 return this->set<First>(
second, FLECS_FWD(val));
449 template <
typename First,
typename Second,
typename P = pair<First, Second>,
450 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value> = 0>
452 this->override<First, Second>();
453 return this->set<First, Second>(val);
462 template <
typename First,
typename Second,
typename P = pair<First, Second>,
463 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value> = 0>
465 this->override<First, Second>();
466 return this->set<First, Second>(FLECS_FWD(val));
474 template <
typename T,
typename ... Args>
478 flecs::emplace<T>(this->m_world, this->m_id,
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,
494 this->override<First, Second>();
496 flecs::emplace<A>(this->m_world, this->m_id,
513 template <typename E, if_t< is_enum<E>::value > = 0>
516 const auto& et = enum_type<E>(this->m_world);
517 flecs::entity_t
second = et.entity(value);
526 template <typename E, if_t< is_enum<E>::value > = 0>
529 return this->
remove(first, flecs::Wildcard);
557 Self&
enable(flecs::id_t
id,
bool toggle =
true) {
588 template<
typename First>
599 template<
typename First,
typename Second>
611 return this->
enable(
id,
false);
640 template<
typename First>
651 template<
typename First,
typename Second>
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);
661 Self& set_ptr(entity_t comp,
const void *ptr) {
666 ecs_assert(cptr != NULL, ECS_INVALID_PARAMETER, NULL);
668 return set_ptr(comp, cptr->
size, ptr);
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));
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);
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));
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);
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>
710 flecs::set<P>(this->m_world, this->m_id, FLECS_FWD(value));
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);
737 template <typename First, typename Second, if_not_t< is_enum<Second>::value > = 0>
740 flecs::set(this->m_world, this->m_id, value,
753 template <typename First, typename Second, if_not_t< is_enum<Second>::value > = 0>
756 flecs::set(this->m_world, this->m_id, FLECS_FWD(value),
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);
784 template <
typename Second>
787 flecs::set(this->m_world, this->m_id, value,
800 template <
typename Second>
803 flecs::set(this->m_world, this->m_id, FLECS_FWD(value),
808 template <
typename First,
typename Second>
810 flecs::set<pair_object<First, Second>>(this->m_world, this->m_id, value);
829 template <typename Func, if_t< is_callable<Func>::value > = 0>
830 Self& set(
const Func& func);
850 template<
typename T,
typename ... Args,
typename A = actual_type_t<T>>
852 flecs::emplace<A>(this->m_world, this->m_id,
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,
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),
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)),
887 template <
typename Func>
901 template <
typename First,
typename Func>
912 template <
typename Func>
915 ecs_pair(
first, this->m_id));
922 template <
typename Func>
932 Self& set_name(
const char *
name) {
938# include "../doc/entity_builder.inl"
942# include "../meta/entity_builder.inl"
947 return *
static_cast<Self*
>(
this);
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.
#define ecs_check(condition, error_code,...)
Check.
ecs_id_t ecs_entity_t
An entity identifier.
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 entity.
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.
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.
ecs_size_t size
Component size.
Self & add(Second constant)
Add a pair.
Self & child_of(entity_t second)
Shortcut for add(ChildOf, entity).
Self & set(Second constant, const First &value)
Set a pair for an entity.
Self & child_of()
Shortcut for add(ChildOf, entity).
Self & enable(flecs::id_t first, flecs::id_t second)
Enable a pair.
Self & disable(flecs::id_t id)
Disable an id.
Self & with(entity_t first, const Func &func)
Entities created in function will have (first, this).
Self & add_if(bool cond)
Conditional add.
Self & depends_on()
Shortcut for add(DependsOn, entity).
Self & add_second(flecs::entity_t first)
Add a pair.
Self & with(const Func &func)
Entities created in function will have the current entity.
Self & set_override(T &&val)
Set component, mark component for auto-overriding.
Self & scope(const Func &func)
The function will be ran with the scope set to the current entity.
Self & add()
Add a component to an entity.
Self & add_if(bool cond, flecs::entity_t second)
Conditional add.
Self & set_second(entity_t first, Second &&value)
Set a pair for an entity.
Self & depends_on(entity_t second)
Shortcut for add(DependsOn, entity).
Self & enable()
Enable a component.
Self & set(A &&value)
Set a pair for an entity.
Self & set(Second second, const First &value)
Set a pair for an entity.
Self & disable(flecs::id_t first, flecs::id_t second)
Disable a pair.
Self & add(entity_t first, entity_t second)
Add a pair.
Self & enable()
Enable an entity.
Self & is_a(entity_t second)
Shortcut for add(IsA, entity).
Self & add(Second second)
Add a pair.
Self & add(id_t component)
Add an entity to an entity.
Self & disable()
Disable an entity.
Self & disable()
Disable a pair.
Self & set_override(flecs::entity_t second, First &&val)
Set pair, mark component for auto-overriding.
Self & remove(Second constant)
Remove a pair.
Self & with(const Func &func)
Entities created in function will have (First, this).
Self & add_if(bool cond, flecs::id_t component)
Conditional add.
Self & remove(Second second)
Remove a pair.
Self & enable(flecs::id_t second)
Enable a pair.
Self & remove()
Remove a component from an entity.
Self & disable(flecs::id_t second)
Disable a pair.
Self & set_override(const T &val)
Set component, mark component for auto-overriding.
Self & emplace_override(Args &&... args)
Emplace component, mark component for auto-overriding.
Self & set(Second second, First &&value)
Set a pair for an entity.
Self & add_if(bool cond)
Conditional add.
Self & remove(entity_t first, entity_t second)
Remove a pair.
Self & disable()
Disable a component.
Self & slot_of(entity_t second)
Shortcut for add(SlotOf, entity).
Self & set_override(flecs::entity_t second, const First &val)
Set pair, mark component for auto-overriding.
Self & enable()
Enable a pair.
Self & add_if(bool cond, flecs::entity_t first, flecs::entity_t second)
Conditional add.
Self & set_second(entity_t first, const Second &value)
Set a pair for an entity.
Self & enable(flecs::id_t id, bool toggle=true)
Enable an id.
Self & emplace_override(Args &&... args)
Emplace pair, mark pair for auto-overriding.
Self & set_override(const A &val)
Set component, mark component for auto-overriding.
Self & set(const A &value)
Set a pair for an entity.
Self & remove_second(flecs::entity_t first)
Removes a pair.
Self & slot()
Shortcut for add(SlotOf, target(ChildOf)).
Self & is_a()
Shortcut for add(IsA, entity).
Self & slot_of()
Shortcut for add(SlotOf, entity).
Self & add(E value)
Add pair for enum constant.
Self & set_override(A &&val)
Set component, mark component for auto-overriding.
Self & add_if(bool cond, E constant)
Conditional add.
Self & remove(entity_t entity)
Remove an entity from an entity.
Self & emplace(Args &&... args)
Emplace component.
flecs::string_view name() const
Return the entity name.
entity_t id() const
Get entity id.
flecs::entity target(int32_t index=0) const
Get target for a given pair.
flecs::entity second() const
Get second element from a pair.
flecs::entity first() const
Get first element from a pair.
Type that represents a pair.