14template <
typename Self>
17 using entity_view::entity_view;
27 "cannot default construct type: add T::T() or use emplace<T>()");
41 template <typename E, if_t< is_enum<E>::value > = 0>
44 const auto& et = enum_type<E>(this->m_world);
45 flecs::entity_t
second = et.entity(value);
66 ecs_add_pair(this->m_world, this->m_id,
first,
second);
76 template<
typename First,
typename Second>
87 template<typename First, typename Second, if_not_t< is_enum<Second>::value > = 0>
90 "cannot default construct type: add T::T() or use emplace<T>()");
101 template<typename First, typename Second, if_t< is_enum<Second>::value > = 0>
102 Self&
add(Second constant) {
104 "cannot default construct type: add T::T() or use emplace<T>()");
105 const auto& et = enum_type<Second>(this->m_world);
106 return this->add<First>(et.entity(constant));
115 template<
typename Second>
128 return this->
add(component);
130 return this->
remove(component);
140 template <
typename T>
143 return this->add<T>();
145 return this->remove<T>();
178 template <
typename First>
190 template <
typename First,
typename Second>
201 template <typename E, if_t< is_enum<E>::value > = 0>
203 const auto& et = enum_type<E>(this->m_world);
204 return this->add_if<E>(cond, et.entity(constant));
219 template <
typename T>
229 return this->
add(flecs::ChildOf,
second);
237 return this->
add(flecs::DependsOn,
second);
252 ECS_INVALID_PARAMETER,
"add ChildOf pair before using slot()");
262 template <
typename T>
271 template <
typename T>
280 template <
typename T>
289 template <typename T, if_not_t< is_enum<T>::value > = 0>
300 template <typename E, if_t< is_enum<E>::value > = 0>
303 return this->
remove(first, flecs::Wildcard);
322 ecs_remove_pair(this->m_world, this->m_id,
first,
second);
332 template<
typename First,
typename Second>
343 template<typename First, typename Second, if_not_t< is_enum<Second>::value > = 0>
354 template<
typename Second>
365 template<typename First, typename Second, if_t< is_enum<Second>::value > = 0>
367 const auto& et = enum_type<Second>(this->m_world);
368 flecs::entity_t
second = et.entity(constant);
369 return this->remove<First>(
second);
379 Self&
override(flecs::id_t
id) {
398 template <
typename T>
409 template <
typename First>
420 template <
typename First,
typename Second>
430 template <
typename T>
433 return this->set<T>(val);
441 template <
typename T>
444 return this->set<T>(FLECS_FWD(val));
453 template <
typename First>
455 this->override<First>(
second);
456 return this->set<First>(
second, val);
465 template <
typename First>
467 this->override<First>(
second);
468 return this->set<First>(
second, FLECS_FWD(val));
477 template <
typename First,
typename Second,
typename P = pair<First, Second>,
478 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value> = 0>
480 this->override<First, Second>();
481 return this->set<First, Second>(val);
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>
493 this->override<First, Second>();
494 return this->set<First, Second>(FLECS_FWD(val));
502 template <
typename T,
typename ... Args>
506 flecs::emplace<T>(this->m_world, this->m_id,
518 template <
typename First,
typename Second,
typename P = pair<First, Second>,
519 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value> = 0,
522 this->override<First, Second>();
524 flecs::emplace<A>(this->m_world, this->m_id,
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)),
888 template <
typename Func>
902 template <
typename First,
typename Func>
914 template <
typename Func>
917 ecs_pair(
first, this->m_id));
924 template <
typename Func>
939 Self& set_name(
const char *
name) {
946 Self& set_alias(
const char *
name) {
952# include "../doc/entity_builder.inl"
956# include "../meta/entity_builder.inl"
961 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.
uint64_t ecs_id_t
Ids are the things that can be added to an entity.
void ecs_enable_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t id, bool enable)
Enable or disable component.
void ecs_enable(ecs_world_t *world, ecs_entity_t entity, bool enabled)
Enable or disable entity.
ecs_entity_t ecs_get_target(const ecs_world_t *world, ecs_entity_t entity, ecs_entity_t rel, int32_t index)
Get the target of a relationship.
bool ecs_has_id(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
Test if an entity has an id.
ecs_entity_t ecs_set_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t id, size_t size, const void *ptr)
Set the value of a component.
const ecs_id_t ECS_OVERRIDE
Automatically override component when it is inherited.
void ecs_set_alias(ecs_world_t *world, ecs_entity_t entity, const char *alias)
Set alias for entity.
ecs_entity_t ecs_set_name(ecs_world_t *world, ecs_entity_t entity, const char *name)
Set the name of an entity.
ecs_entity_t ecs_set_scope(ecs_world_t *world, ecs_entity_t scope)
Set the current scope.
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.
scoped_world scope() const
Return world scoped to entity.
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.