14template <
typename Self>
19 template <
typename... T,
typename... Args>
20 const Self& add(Args... args)
const {
22 _::make_id<T...>(this->
world_, args...));
26 template <
typename Second>
52 const Self&
add_if(
bool cond)
const {
54 return this->add<T>();
56 return this->remove<T>();
89 template <
typename First>
101 template <
typename First,
typename Second>
112 template <typename E, if_t< is_enum<E>::value > = 0>
123 return this->add(flecs::IsA,
second);
130 template <
typename T>
140 return this->add(flecs::ChildOf,
second);
148 return this->add(flecs::DependsOn,
second);
155 template <typename E, if_t<is_enum<E>::value> = 0>
166 template <
typename T>
175 template <
typename T>
180 template <
typename... T,
typename... Args>
181 const Self& remove(Args... args)
const {
183 _::make_id<T...>(this->
world_, args...).
id);
187 template <
typename Second>
189 return remove(
first, _::type<Second>::id(this->
world_));
192 template <
typename... T,
typename... Args>
193 const Self& auto_override(Args... args)
const {
197 template <
typename Second>
199 return auto_override(
first, _::type<Second>::id(this->
world_));
202 template <
typename... T,
typename A = _::value_type_t<T...>>
203 const Self& set_auto_override(A&& value)
const {
204 auto id = _::value_id<T...>(this->
world_, value);
205 this->auto_override(
id.
id);
206 flecs::set(this->
world_, this->
id_, FLECS_FWD(value),
id.
id);
210 template <
typename... T,
typename A = _::value_type_t<T...>>
211 const Self& set_auto_override(
const A& value)
const {
212 auto id = _::value_id<T...>(this->
world_, value);
213 this->auto_override(
id.
id);
214 flecs::set(this->
world_, this->
id_, value,
id.
id);
218 template <
typename First>
221 this->auto_override(
id.
id);
222 flecs::set(this->
world_, this->
id_, FLECS_FWD(value),
id.
id);
226 template <
typename First>
229 this->auto_override(
id.
id);
230 flecs::set(this->
world_, this->
id_, value,
id.
id);
234 template <
typename... T,
typename... Args>
235 const Self& emplace_auto_override(Args&&... args)
const {
236 auto id = _::make_id<T...>(this->
world_);
237 this->auto_override(
id.
id);
238 flecs::emplace<typename decltype(id)::type>(this->
world_, this->
id_,
239 id.
id, FLECS_FWD(args)...);
301 template<
typename First>
312 template<
typename First,
typename Second>
327 return this->
enable(
id,
false);
356 template<
typename First>
367 template<
typename First,
typename Second>
372 const Self& set_ptr(
entity_t comp,
size_t size,
const void *ptr)
const {
377 const Self& set_ptr(
entity_t comp,
const void *ptr)
const {
384 return set_ptr(comp, type_info->
size, ptr);
387 template <
typename... T,
typename A = _::value_type_t<T...>>
388 const Self& set(A&& value)
const {
389 auto id = _::value_id<T...>(this->
world_, value);
390 flecs::set(this->
world_, this->
id_, FLECS_FWD(value),
id.
id);
394 template <
typename... T,
typename A = _::value_type_t<T...>>
395 const Self& set(
const A& value)
const {
396 auto id = _::value_id<T...>(this->
world_, value);
397 flecs::set(this->
world_, this->
id_, value,
id.
id);
401 template <
typename First,
typename Second>
402 const Self& set(Second
second, First&& value)
const {
404 flecs::set(this->
world_, this->
id_, FLECS_FWD(value),
id.
id);
408 template <
typename First,
typename Second>
409 const Self& set(Second
second,
const First& value)
const {
411 flecs::set(this->
world_, this->
id_, value,
id.
id);
415 template <
typename Second>
416 const Self& set_second(
entity_t first, Second&& value)
const {
417 auto id = _::second_id<Second>(this->
world_,
first);
418 flecs::set(this->
world_, this->
id_, FLECS_FWD(value),
id.
id);
422 template <
typename Second>
423 const Self& set_second(
entity_t first,
const Second& value)
const {
424 auto id = _::second_id<Second>(this->
world_,
first);
425 flecs::set(this->
world_, this->
id_, value,
id.
id);
429 template <
typename First,
typename Second>
430 const Self& set_second(
const Second& value)
const {
431 flecs::set<pair_object<First, Second>>(this->
world_, this->
id_, value);
435 template <
typename... T,
typename A = _::value_type_t<T...>>
436 const Self& assign(A&& value)
const {
437 auto id = _::value_id<T...>(this->
world_, value);
438 flecs::assign(this->
world_, this->
id_, FLECS_FWD(value),
id.
id);
442 template <
typename... T,
typename A = _::value_type_t<T...>>
443 const Self& assign(
const A& value)
const {
444 auto id = _::value_id<T...>(this->
world_, value);
445 flecs::assign(this->
world_, this->
id_, value,
id.
id);
449 template <
typename First,
typename Second>
450 const Self& assign(Second
second, First&& value)
const {
452 flecs::assign(this->
world_, this->
id_, FLECS_FWD(value),
id.
id);
456 template <
typename First,
typename Second>
457 const Self& assign(Second
second,
const First& value)
const {
459 flecs::assign(this->
world_, this->
id_, value,
id.
id);
463 template <
typename Second>
464 const Self& assign_second(
entity_t first, Second&& value)
const {
465 auto id = _::second_id<Second>(this->
world_,
first);
466 flecs::assign(this->
world_, this->
id_, FLECS_FWD(value),
id.
id);
470 template <
typename Second>
471 const Self& assign_second(
entity_t first,
const Second& value)
const {
472 auto id = _::second_id<Second>(this->
world_,
first);
473 flecs::assign(this->
world_, this->
id_, value,
id.
id);
477 template <
typename First,
typename Second>
478 const Self& assign_second(
const Second& value)
const {
479 flecs::assign<pair_object<First, Second>>(this->
world_, this->
id_, value);
498 template <
typename Func>
499 const Self&
insert(
const Func& func)
const;
501 template <
typename... T,
typename... Args>
502 const Self& emplace(Args&&... args)
const {
503 auto id = _::make_id<T...>(this->
world_);
504 flecs::emplace<typename decltype(id)::type>(this->
world_, this->
id_,
505 id.
id, FLECS_FWD(args)...);
509 template <
typename First,
typename ... Args>
512 flecs::emplace<First>(this->
world_, this->
id_,
518 template <
typename Second,
typename ... Args>
525 flecs::emplace<Second>(this->
world_, this->
id_,
532 template <
typename Func>
533 const Self&
scope(
const Func& func)
const {
567 const Self& to_base()
const {
568 return *
static_cast<const Self*
>(
this);
Doc entity builder mixin.
enum_data< E > enum_type(flecs::world_t *world)
Convenience function for getting enum reflection data.
void ecs_remove_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Remove a component from 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.
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 & disable() const
Disable an entity.
const Self & enable(flecs::id_t second) const
Enable a pair.
const Self & add_if(bool cond, E constant) const
Conditional add.
const Self & disable(flecs::id_t first, flecs::id_t second) const
Disable a pair.
const Self & is_a() const
Shortcut for add(IsA, entity).
const Self & enable() const
Enable an entity.
const Self & enable() const
Enable a component.
const Self & child_of() const
Shortcut for add(ChildOf, 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 & disable(flecs::id_t id) const
Disable an ID.
const Self & add_if(bool cond) const
Conditional add.
const Self & is_a(entity_t second) const
Shortcut for add(IsA, entity).
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 & add_if(bool cond) const
Conditional add.
const Self & disable() const
Disable a component.
entity_view()
Default constructor.
const Self & set_name(const char *name) const
Set the entity name.
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 & 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 & 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 & depends_on(entity_t second) const
Shortcut for add(DependsOn, entity).
const Self & depends_on() const
Shortcut for add(DependsOn, entity).
const Self & disable() const
Disable a pair.
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.