21# if !defined(FLECS_META) && !defined(FLECS_CPP_NO_ENUM_REFLECTION)
33 _::system_init(*
this);
48 script::_::init(*
this);
56 const char *name = alias;
77 const char *name = alias;
102inline entity world::lookup(
const char *name,
const char *sep,
const char *root_sep,
bool recursive)
const {
124template <
typename First,
typename Second>
125inline void world::set(Second second,
const First& value)
const {
127 e.
set<First>(second, value);
131template <
typename First,
typename Second>
134 e.
set<First>(second, value);
164template <
typename First,
typename Second,
typename P,
typename A>
167 return e.
try_get<First, Second>();
171template <
typename First,
typename Second>
174 return e.
try_get<First>(second);
197template <
typename First,
typename Second,
typename P,
typename A>
200 return e.
get<First, Second>();
204template <
typename First,
typename Second>
207 return e.
get<First>(second);
230template <
typename First,
typename Second,
typename P,
typename A>
237template <
typename First,
typename Second>
263template <
typename First,
typename Second,
typename P,
typename A>
266 return e.
get_mut<First, Second>();
270template <
typename First,
typename Second>
273 return e.
get_mut<First>(second);
284template <
typename First,
typename Second>
287 return e.
has<First, Second>();
291template <
typename First>
294 return e.
has<First>(second);
300 return e.
has(first, second);
304template <typename E, if_t< is_enum<E>::value > >
318template <
typename First,
typename Second>
321 e.
add<First, Second>();
325template <
typename First>
328 e.
add<First>(second);
334 e.
add(first, second);
338template <typename E, if_t< is_enum<E>::value > >
352template <
typename First,
typename Second>
355 e.
remove<First, Second>();
359template <
typename First>
372template <
typename Func>
384template <
typename First>
411template <typename Func, if_t< is_callable<Func>::value > >
413 static_assert(
arity<Func>::value == 1,
"singleton component must be the only argument");
419template <typename Func, if_t< is_callable<Func>::value > >
421 static_assert(
arity<Func>::value == 1,
"singleton component must be the only argument");
447 int index = index_by_value(value);
449 int32_t constant_i = impl_.constants[index].index;
457 .with(flecs::ChildOf,
world.
id<E>())
458 .with(flecs::Constant,
world.
id<int32_t>())
461 const int32_t& constant_value =
constant.get_second<int32_t>(flecs::Constant);
462 return value ==
static_cast<underlying_type_t<E>
>(constant_value);
472 return entity(
static_cast<underlying_type_t<E>
>(value));
component< T > & constant(const char *name, T value)
Add a constant.
typename first_arg< Func >::type first_arg_t
Convenience alias for the first argument type of a callable.
#define ecs_assert(condition, error_code,...)
Assert.
#define ECS_INVALID_PARAMETER
Invalid parameter error code.
flecs::query_builder< Comps... > query_builder(Args &&... args) const
Create a query builder.
flecs::entity entity(Args &&... args) const
Create an entity.
flecs::id id(E value) const
Convert an enum constant to an entity.
ecs_entity_t entity_t
Entity type.
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.
void ecs_make_alive(ecs_world_t *world, ecs_entity_t entity)
Ensure an ID is alive.
ecs_entity_t ecs_get_alive(const ecs_world_t *world, ecs_entity_t e)
Get an alive identifier.
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_get_scope(const ecs_world_t *world)
Get the current scope.
ecs_entity_t ecs_lookup_path_w_sep(const ecs_world_t *world, ecs_entity_t parent, const char *path, const char *sep, const char *prefix, bool recursive)
Look up an entity from a path.
const char * ecs_get_name(const ecs_world_t *world, ecs_entity_t entity)
Get the name of an entity.
ecs_entity_t ecs_set_scope(ecs_world_t *world, ecs_entity_t scope)
Set the current scope.
Trait to get the number of arguments of a callable.
const Self & remove() const
Remove a component from an entity.
const Self & set(T &&value) const
Set a component for an entity.
const Self & add() const
Add a component to an entity.
T & get_mut() const
Get mutable component value.
const T & get() const
Get component value.
bool has(flecs::id_t e) const
Check if entity has the provided entity.
T * try_get_mut() const
Get mutable component value.
entity_t id() const
Get entity ID.
const T * try_get() const
Get component value.
void children(flecs::entity_t rel, Func &&func) const
Iterate children for an entity.
static flecs::entity null()
Entity ID 0 without a world.
ref< T > get_ref() const
Get reference to component.
void modified() const
Signal that component was modified.
T & ensure() const
Get mutable component value.
flecs::entity entity() const
Get entity for the enum type.
const T & get() const
Get a singleton component.
world_t * world_
Pointer to the underlying C world.
flecs::entity get_scope() const
Get current scope.
T & get_mut() const
Get a mutable singleton component.
void remove() const
Remove singleton component.
flecs::entity lookup(const char *name, const char *sep="::", const char *root_sep="::", bool recursive=true) const
Lookup entity by name.
flecs::entity get_alive(flecs::entity_t e) const
Get alive entity for ID.
flecs::entity make_alive(flecs::entity_t e) const
Ensure an entity ID is alive.
flecs::entity target(int32_t index=0) const
Get target for a given pair from a singleton entity.
const T * try_get() const
Get singleton component.
void init_builtin_components()
Initialize built-in components.
flecs::entity set_scope() const
Same as set_scope(), but with type.
flecs::scoped_world scope() const
Use the provided scope (by type) for operations run on the returned world.
void children(Func &&f) const
Iterate entities in root of world.
T * try_get_mut() const
Try to get a mutable singleton component (returns nullptr if not found).
void modified() const
Mark singleton component as modified.
flecs::entity set_scope(const flecs::entity_t scope) const
Set current scope.
flecs::entity use(const char *alias=nullptr) const
Create an alias for a component.
void add() const
Add singleton component.
T & ensure() const
Ensure singleton component.
void set(const T &value) const
Set singleton component.
bool has() const
Test if world has singleton component.
flecs::entity singleton() const
Get singleton entity for type.
ref< T > get_ref() const
Get ref singleton component.