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_, _::value_cast<T...>(FLECS_FWD(value)),
id.
id);
210 template <
typename First>
213 this->auto_override(
id.
id);
214 flecs::set(this->
world_, this->
id_, FLECS_FWD(value),
id.
id);
218 template <
typename First>
221 this->auto_override(
id.
id);
222 flecs::set(this->
world_, this->
id_, value,
id.
id);
226 template <
typename... T,
typename... Args>
227 const Self& emplace_auto_override(Args&&... args)
const {
228 auto id = _::make_id<T...>(this->
world_);
229 this->auto_override(
id.
id);
230 flecs::emplace<typename decltype(id)::type>(this->
world_, this->
id_,
231 id.
id, FLECS_FWD(args)...);
293 template<
typename First>
304 template<
typename First,
typename Second>
319 return this->
enable(
id,
false);
348 template<
typename First>
359 template<
typename First,
typename Second>
364 const Self& set_ptr(
entity_t comp,
size_t size,
const void *ptr)
const {
369 const Self& set_ptr(
entity_t comp,
const void *ptr)
const {
376 return set_ptr(comp, type_info->
size, ptr);
379 template <
typename... T,
typename A = _::value_type_t<T...>>
380 const Self& set(A&& value)
const {
381 auto id = _::value_id<T...>(this->
world_, value);
382 flecs::set(this->
world_, this->
id_, _::value_cast<T...>(FLECS_FWD(value)),
id.
id);
386 template <
typename First,
typename Second>
387 const Self& set(Second
second, First&& value)
const {
389 flecs::set(this->
world_, this->
id_, FLECS_FWD(value),
id.
id);
393 template <
typename First,
typename Second>
394 const Self& set(Second
second,
const First& value)
const {
396 flecs::set(this->
world_, this->
id_, value,
id.
id);
400 template <
typename Second>
401 const Self& set_second(
entity_t first, Second&& value)
const {
402 auto id = _::second_id<Second>(this->
world_,
first);
403 flecs::set(this->
world_, this->
id_, FLECS_FWD(value),
id.
id);
407 template <
typename Second>
408 const Self& set_second(
entity_t first,
const Second& value)
const {
409 auto id = _::second_id<Second>(this->
world_,
first);
410 flecs::set(this->
world_, this->
id_, value,
id.
id);
414 template <
typename First,
typename Second>
415 const Self& set_second(
const Second& value)
const {
416 flecs::set<pair_object<First, Second>>(this->
world_, this->
id_, value);
420 template <
typename... T,
typename A = _::value_type_t<T...>>
421 const Self& assign(A&& value)
const {
422 auto id = _::value_id<T...>(this->
world_, value);
423 flecs::assign(this->
world_, this->
id_, _::value_cast<T...>(FLECS_FWD(value)),
id.
id);
427 template <
typename First,
typename Second>
428 const Self& assign(Second
second, First&& value)
const {
430 flecs::assign(this->
world_, this->
id_, FLECS_FWD(value),
id.
id);
434 template <
typename First,
typename Second>
435 const Self& assign(Second
second,
const First& value)
const {
437 flecs::assign(this->
world_, this->
id_, value,
id.
id);
441 template <
typename Second>
442 const Self& assign_second(
entity_t first, Second&& value)
const {
443 auto id = _::second_id<Second>(this->
world_,
first);
444 flecs::assign(this->
world_, this->
id_, FLECS_FWD(value),
id.
id);
448 template <
typename Second>
449 const Self& assign_second(
entity_t first,
const Second& value)
const {
450 auto id = _::second_id<Second>(this->
world_,
first);
451 flecs::assign(this->
world_, this->
id_, value,
id.
id);
455 template <
typename First,
typename Second>
456 const Self& assign_second(
const Second& value)
const {
457 flecs::assign<pair_object<First, Second>>(this->
world_, this->
id_, value);
476 template <
typename Func>
477 const Self&
insert(
const Func& func)
const;
479 template <
typename... T,
typename... Args>
480 const Self& emplace(Args&&... args)
const {
481 auto id = _::make_id<T...>(this->
world_);
482 flecs::emplace<typename decltype(id)::type>(this->
world_, this->
id_,
483 id.
id, FLECS_FWD(args)...);
487 template <
typename First,
typename ... Args>
490 flecs::emplace<First>(this->
world_, this->
id_,
496 template <
typename Second,
typename ... Args>
503 flecs::emplace<Second>(this->
world_, this->
id_,
510 template <
typename Func>
511 const Self&
scope(
const Func& func)
const {
545 const Self& to_base()
const {
546 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.