14template <
typename Self>
25 const Self&
add()
const {
27 "cannot default construct type: add T::T() or use emplace<T>()");
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_);
78 template<
typename First,
typename Second>
79 const Self&
add()
const {
89 template<typename First, typename Second, if_not_t< is_enum<Second>::value > = 0>
92 "cannot default construct type: add T::T() or use emplace<T>()");
103 template<typename First, typename Second, if_t< is_enum<Second>::value && !std::is_same<First, Second>::value > = 0>
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));
117 template<
typename Second>
130 return this->
add(component);
132 return this->
remove(component);
142 template <
typename T>
145 return this->add<T>();
147 return this->remove<T>();
180 template <
typename First>
192 template <
typename First,
typename Second>
203 template <typename E, if_t< is_enum<E>::value > = 0>
205 const auto& et = enum_type<E>(this->
world_);
206 return this->add_if<E>(cond, et.entity(
constant));
221 template <
typename T>
231 return this->
add(flecs::ChildOf,
second);
239 return this->
add(flecs::DependsOn,
second);
246 template <typename E, if_t<is_enum<E>::value> = 0>
248 const auto& et = enum_type<E>(this->
world_);
257 template <
typename T>
266 template <
typename T>
275 template <
typename T>
307 template<
typename First,
typename Second>
318 template<typename First, typename Second, if_not_t< is_enum<Second>::value > = 0>
329 template<
typename Second>
340 template<typename First, typename Second, if_t< is_enum<Second>::value > = 0>
342 const auto& et = enum_type<Second>(this->
world_);
344 return this->remove<First>(
second);
373 template <
typename T>
384 template <
typename First>
395 template <
typename First,
typename Second>
406 template <
typename Second>
417 template <
typename T>
419 this->auto_override<T>();
420 return this->set<T>(val);
429 template <
typename T>
431 this->auto_override<T>();
432 return this->set<T>(FLECS_FWD(val));
442 template <
typename First>
444 this->auto_override<First>(
second);
445 return this->set<First>(
second, val);
455 template <
typename First>
457 this->auto_override<First>(
second);
458 return this->set<First>(
second, FLECS_FWD(val));
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>
471 this->auto_override<First, Second>();
472 return this->set<First, Second>(val);
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>
485 this->auto_override<First, Second>();
486 return this->set<First, Second>(FLECS_FWD(val));
495 template <
typename T,
typename ... Args>
497 this->auto_override<T>();
499 flecs::emplace<T>(this->
world_, this->
id_,
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,
516 this->auto_override<First, Second>();
518 flecs::emplace<A>(this->
world_, this->
id_,
584 template<
typename First>
595 template<
typename First,
typename Second>
610 return this->
enable(
id,
false);
639 template<
typename First>
650 template<
typename First,
typename Second>
655 const Self& set_ptr(
entity_t comp,
size_t size,
const void *ptr)
const {
660 const Self& set_ptr(
entity_t comp,
const void *ptr)
const {
667 return set_ptr(comp, type_info->
size, ptr);
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));
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);
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));
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);
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));
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);
762 template <typename First, typename Second, if_not_t< is_enum<Second>::value > = 0>
763 const Self&
set(Second
second,
const First& value)
const {
778 template <typename First, typename Second, if_not_t< is_enum<Second>::value > = 0>
794 template <typename First, typename Second, if_t< is_enum<Second>::value > = 0>
796 const auto& et = enum_type<Second>(this->
world_);
798 return set<First>(
second, value);
809 template <
typename Second>
829 template <
typename Second>
849 template <
typename First,
typename Second>
851 flecs::set<pair_object<First, Second>>(this->
world_, this->
id_, value);
863 template<typename T, if_t<is_actual<T>::value> = 0 >
865 flecs::assign<T>(this->
world_, this->
id_, FLECS_FWD(value));
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);
889 template<
typename T,
typename A = actual_type_t<T>, if_not_t<
890 is_actual<T>::value > = 0>
892 flecs::assign<T>(this->
world_, this->
id_, FLECS_FWD(value));
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);
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>
921 flecs::assign<P>(this->
world_, this->
id_, FLECS_FWD(value));
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);
948 template <typename First, typename Second, if_not_t< is_enum<Second>::value > = 0>
964 template <typename First, typename Second, if_not_t< is_enum<Second>::value > = 0>
980 template <typename First, typename Second, if_t< is_enum<Second>::value > = 0>
982 const auto& et = enum_type<Second>(this->
world_);
984 return assign<First>(
second, value);
995 template <
typename Second>
1015 template <
typename Second>
1027 template <
typename First,
typename Second>
1029 flecs::assign<pair_object<First, Second>>(this->
world_, this->
id_, value);
1049 template <
typename Func>
1050 const Self&
insert(
const Func& func)
const;
1059 template<
typename T,
typename ... Args,
typename A = actual_type_t<T>>
1061 flecs::emplace<A>(this->
world_, this->
id_,
1066 template <
typename First,
typename Second,
typename ... Args,
typename P =
pair<First, Second>,
1068 const Self&
emplace(Args&&... args)
const {
1069 flecs::emplace<A>(this->
world_, this->
id_,
1072 FLECS_FWD(args)...);
1076 template <
typename First,
typename ... Args>
1079 flecs::emplace<First>(this->
world_, this->
id_,
1081 FLECS_FWD(args)...);
1085 template <
typename Second,
typename ... Args>
1092 flecs::emplace<Second>(this->
world_, this->
id_,
1094 FLECS_FWD(args)...);
1099 template <
typename Func>
1100 const Self&
scope(
const Func& func)
const {
1134 const Self& to_base()
const {
1135 return *
static_cast<const Self*
>(
this);
component< T > & constant(const char *name, T value)
Add a constant.
Doc entity builder 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.
#define ECS_INVALID_PARAMETER
Invalid parameter error code.
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.
ecs_entity_t entity_t
Entity type.
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.
#define ecs_remove_pair(world, subject, first, second)
Remove a pair from an entity.
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.
Type that contains component information (passed to ctors/dtors/...).
ecs_size_t size
Size of the type.
const Self & emplace_auto_override(Args &&... args) const
Emplace pair, mark pair for auto-overriding.
const Self & disable() const
Disable an entity.
const Self & add(E value) const
Add a pair for an enum constant.
const Self & set(Second constant, const First &value) const
Set a pair for an entity.
const Self & auto_override(flecs::entity_t second) const
Mark pair for auto-overriding.
const Self & enable(flecs::id_t second) const
Enable a pair.
const Self & remove(Second constant) const
Remove a pair.
const Self & remove(entity_t first, entity_t second) const
Remove a pair.
const Self & add_if(bool cond, E constant) const
Conditional add.
const Self & remove(Second second) const
Remove a pair.
const Self & emplace(Args &&... args) const
Emplace a component.
const Self & set_auto_override(flecs::entity_t second, const First &val) const
Set pair, mark pair for auto-overriding.
const Self & assign(const A &value) const
Assign a component for an entity.
const Self & disable(flecs::id_t first, flecs::id_t second) const
Disable a pair.
const Self & emplace_auto_override(Args &&... args) const
Emplace component, mark component for auto-overriding.
const Self & assign(Second second, First &&value) const
Assign a pair for an entity.
const Self & add() const
Add a pair.
const Self & is_a() const
Shortcut for add(IsA, entity).
const Self & enable() const
Enable an entity.
const Self & remove_second(flecs::entity_t first) const
Remove a pair.
const Self & auto_override() const
Mark component for auto-overriding.
const Self & enable() const
Enable a component.
const Self & set(const T &value) const
Set a component for an entity.
const Self & child_of() const
Shortcut for add(ChildOf, entity).
const Self & set(A &&value) const
Set a pair for an entity.
const Self & set_auto_override(A &&val) const
Set pair, mark pair for auto-overriding.
const Self & set(const A &value) const
Set a component for an entity.
const Self & enable() const
Enable a pair.
const Self & enable(flecs::id_t first, flecs::id_t second) const
Enable a pair.
const Self & remove() const
Remove a component from an entity.
const Self & disable(flecs::id_t id) const
Disable an ID.
const Self & assign(const A &value) const
Assign a pair for an entity.
const Self & assign(A &&value) const
Assign a pair for an entity.
const Self & assign(const T &value) const
Assign a component for an entity.
const Self & set(Second second, const First &value) const
Set a pair for an entity.
const Self & assign(T &&value) const
Assign a component for an entity.
const Self & add_if(bool cond) const
Conditional add.
const Self & is_a(entity_t second) const
Shortcut for add(IsA, entity).
const Self & add(Second constant) const
Add a pair.
const Self & depends_on(E second) const
Shortcut for add(DependsOn, entity).
const Self & add_if(bool cond, flecs::entity_t first, flecs::entity_t second) const
Conditional add.
const Self & set_second(entity_t first, Second &&value) const
Set a pair for an entity.
const Self & set_auto_override(T &&val) const
Set component, mark component for auto-overriding.
const Self & add_if(bool cond) const
Conditional add.
const Self & remove() const
Remove a pair.
const Self & disable() const
Disable a component.
const Self & add(id_t component) const
Add an entity to an entity.
const Self & set_name(const char *name) const
Set the entity name.
const Self & add(entity_t first, entity_t second) const
Add a pair.
const Self & set(Second second, First &&value) const
Set a pair for an entity.
const Self & assign(Second second, const First &value) const
Assign a pair for an entity.
const Self & insert(const Func &func) const
Set 1..N components.
const Self & scope(const Func &func) const
The function will be run with the scope set to the current entity.
const Self & add_if(bool cond, flecs::entity_t second) const
Conditional add.
const Self & assign_second(entity_t first, Second &&value) const
Assign a pair for an entity.
const Self & add_second(flecs::entity_t first) const
Add a pair.
const Self & add_if(bool cond, flecs::id_t component) const
Conditional add.
const Self & set_alias(const char *name) const
Set the entity alias.
const Self & disable(flecs::id_t second) const
Disable a pair.
const Self & set_second(const Second &value) const
Set a pair for an entity.
const Self & set_auto_override(const T &val) const
Set component, mark component for auto-overriding.
const Self & assign(A &&value) const
Assign a component for an entity.
const Self & remove(entity_t entity) const
Remove an entity from an entity.
const Self & assign(Second constant, const First &value) const
Assign a pair for an entity.
const Self & set_auto_override(flecs::entity_t second, First &&val) const
Set pair, mark pair for auto-overriding.
const Self & set(A &&value) const
Set a component for an entity.
const Self & enable(flecs::id_t id, bool toggle=true) const
Enable an ID.
const Self & child_of(entity_t second) const
Shortcut for add(ChildOf, entity).
const Self & set(T &&value) const
Set a component for an entity.
const Self & depends_on(entity_t second) const
Shortcut for add(DependsOn, entity).
const Self & depends_on() const
Shortcut for add(DependsOn, entity).
const Self & auto_override(flecs::id_t id) const
Mark ID for auto-overriding.
const Self & set(const A &value) const
Set a pair for an entity.
const Self & disable() const
Disable a pair.
const Self & auto_override(flecs::entity_t first, flecs::entity_t second) const
Mark pair for auto-overriding.
const Self & auto_override() const
Mark pair for auto-overriding.
const Self & add() const
Add a component to an entity.
const Self & auto_override_second(flecs::entity_t first) const
Mark pair for auto-overriding.
const Self & assign_second(entity_t first, const Second &value) const
Assign a pair for an entity.
const Self & add(Second second) const
Add a pair.
const Self & set_auto_override(const A &val) const
Set pair, mark pair for auto-overriding.
const Self & set_second(entity_t first, const Second &value) const
Set a pair for an entity.
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.
entity()
Default constructor.
flecs::id_t id_
The raw ID value.
flecs::entity second() const
Get second element from a pair.
flecs::world_t * world_
World is optional, but guarantees that entity identifiers extracted from the ID are valid.
flecs::entity first() const
Get first element from a pair.
Trait to test if a type is constructible by Flecs.
Type that represents a pair.
enable_if_t< false==V, int > if_not_t
Convenience enable_if alias for negated conditions.
void assign(world_t *world, flecs::entity_t entity, T &&value, flecs::id_t id)
Assign a component value using move semantics.
void set(world_t *world, flecs::entity_t entity, T &&value, flecs::id_t id)
Static helper functions to assign a component value.