11inline void world::init_builtin_components() {
19# if !defined(FLECS_META) && !defined(FLECS_CPP_NO_ENUM_REFLECTION)
31 _::system_init(*
this);
50 const char *name = alias;
61 ecs_assert(e != 0, ECS_INVALID_PARAMETER, NULL);
68 entity_t eid = e.
id();
69 const char *name = alias;
90inline entity world::lookup(
const char *name,
const char *sep,
const char *root_sep,
bool recursive)
const {
109template <
typename First,
typename Second>
110inline void world::set(Second second,
const First& value)
const {
112 e.
set<First>(second, value);
115template <
typename First,
typename Second>
118 e.
set<First>(second, value);
143template <
typename First,
typename Second,
typename P,
typename A>
146 return e.
try_get<First, Second>();
149template <
typename First,
typename Second>
152 return e.
try_get<First>(second);
160inline const void*
world::get(flecs::entity_t r, flecs::entity_t t)
const {
171template <
typename First,
typename Second,
typename P,
typename A>
174 return e.
get<First, Second>();
177template <
typename First,
typename Second>
180 return e.
get<First>(second);
196 return e.try_get_mut<T>();
199template <
typename First,
typename Second,
typename P,
typename A>
205template <
typename First,
typename Second>
224 return e.get_mut<T>();
227template <
typename First,
typename Second,
typename P,
typename A>
230 return e.
get_mut<First, Second>();
233template <
typename First,
typename Second>
236 return e.
get_mut<First>(second);
245template <
typename First,
typename Second>
248 return e.
has<First, Second>();
251template <
typename First>
254 return e.
has<First>(second);
257inline bool world::has(flecs::id_t first, flecs::id_t second)
const {
259 return e.
has(first, second);
268template <
typename First,
typename Second>
271 e.
add<First, Second>();
274template <
typename First>
277 e.
add<First>(second);
280inline void world::add(flecs::entity_t first, flecs::entity_t second)
const {
282 e.
add(first, second);
291template <
typename First,
typename Second>
294 e.
remove<First, Second>();
297template <
typename First>
303inline void world::remove(flecs::entity_t first, flecs::entity_t second)
const {
308template <
typename Func>
318template <
typename First>
327 flecs::entity_t relationship,
335 flecs::entity_t relationship,
342template <typename Func, if_t< is_callable<Func>::value > >
344 static_assert(arity<Func>::value == 1,
"singleton component must be the only argument");
346 this->world_, this->
singleton<first_arg_t<Func>>(), func);
349template <typename Func, if_t< is_callable<Func>::value > >
351 static_assert(arity<Func>::value == 1,
"singleton component must be the only argument");
353 this->world_, this->
singleton<first_arg_t<Func>>(), func);
372inline flecs::entity enum_data<E>::entity(underlying_type_t<E> value)
const {
373 int index = index_by_value(value);
375 int32_t constant_i = impl_.constants[index].index;
376 flecs::entity_t entity = flecs_component_ids_get(world_, constant_i);
381 flecs::world
world = flecs::world(world_);
383 .with(flecs::ChildOf,
world.
id<E>())
384 .with(flecs::Constant,
world.
id<int32_t>())
386 .find([value](flecs::entity
constant) {
387 const int32_t& constant_value =
constant.get_second<int32_t>(flecs::Constant);
388 return value ==
static_cast<underlying_type_t<E>
>(constant_value);
397 return entity(
static_cast<underlying_type_t<E>
>(value));
#define ecs_assert(condition, error_code,...)
Assert.
flecs::component< T > component(Args &&... args) const
Find or register component.
flecs::query_builder< Comps... > query_builder(Args &&... args) const
Create a query builder.
flecs::entity entity(Args &&... args) const
Create an 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.
void ecs_make_alive(ecs_world_t *world, ecs_entity_t entity)
Ensure id is alive.
ecs_entity_t ecs_get_alive(const ecs_world_t *world, ecs_entity_t e)
Get alive identifier.
void ecs_set_alias(ecs_world_t *world, ecs_entity_t entity, const char *alias)
Set alias for 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)
Lookup 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.
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 entity.
ref< T > get_ref() const
Get reference to component.
void modified() const
Signal that component was modified.
T & ensure() const
Get mutable component value.
static flecs::entity null(const flecs::world_t *world)
Entity id 0.
flecs::entity get_scope() const
Get current scope.
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
flecs::id id() const
Get id from a type.
flecs::entity target(int32_t index=0) const
Get target for a given pair from a singleton entity.
const A & get() const
Get singleton pair.
const T * try_get() const
Get singleton component.
flecs::entity set_scope() const
Same as set_scope but with type.
A * try_get_mut() const
Get mutable singleton pair.
void children(Func &&f) const
Iterate entities in root of world Accepts a callback with the following signature:
void scope(id_t parent, const Func &func) const
All entities created in function are created in scope.
void modified() const
Mark singleton component as modified.
flecs::entity use(const char *alias=nullptr) const
Create alias for component.
void add() const
Add singleton component.
T & ensure() const
Ensure singleton component.
A & get_mut() const
Get mutable singleton pair.
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.
flecs::entity entity(Args &&... args) const
Create an entity.