11inline void world::init_builtin_components() {
13 _::system_init(*
this);
32 const char *name = alias;
43 ecs_assert(e != 0, ECS_INVALID_PARAMETER, NULL);
50 entity_t eid = e.
id();
51 const char *name = alias;
89template <
typename First,
typename Second>
90inline void world::set(Second second,
const First& value)
const {
92 e.set<First>(second, value);
95template <
typename First,
typename Second>
96inline void world::set(Second second, First&& value)
const {
98 e.set<First>(second, value);
113template <
typename First,
typename Second,
typename P,
typename A>
116 return e.
get<First, Second>();
119template <
typename First,
typename Second>
122 return e.
get<First>(second);
131template <
typename First,
typename Second>
134 return e.
has<First, Second>();
137template <
typename First>
140 return e.
has<First>(second);
143inline bool world::has(flecs::id_t first, flecs::id_t second)
const {
145 return e.
has(first, second);
154template <
typename First,
typename Second>
157 e.
add<First, Second>();
160template <
typename First>
163 e.
add<First>(second);
166inline void world::add(flecs::entity_t first, flecs::entity_t second)
const {
168 e.
add(first, second);
177template <
typename First,
typename Second>
180 e.
remove<First, Second>();
183template <
typename First>
189inline void world::remove(flecs::entity_t first, flecs::entity_t second)
const {
194template <
typename Func>
204template <
typename First>
213 flecs::entity_t relationship,
221 flecs::entity_t relationship,
228template <typename Func, if_t< is_callable<Func>::value > >
230 static_assert(
arity<Func>::value == 1,
"singleton component must be the only argument");
232 this->m_world, this->
singleton<first_arg_t<Func>>(), func);
235template <typename Func, if_t< is_callable<Func>::value > >
237 static_assert(
arity<Func>::value == 1,
"singleton component must be the only argument");
239 this->m_world, this->
singleton<first_arg_t<Func>>(), func);
267 return flecs::entity(world_, impl_.constants[
static_cast<int>(value)].id);
284 return scope(entity(name));
#define ecs_assert(condition, error_code,...)
Assert.
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_ensure(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.
Self & add()
Add a component to an entity.
Self & remove()
Remove a component from an entity.
const T * get() const
Get component value.
bool has(flecs::id_t e) const
Check if entity has the provided entity.
entity_t id() const
Get entity id.
void children(flecs::entity_t rel, Func &&func) const
Iterate children for entity.
T * get_mut() const
Get mutable component value.
ref< T > get_ref() const
Get reference to component.
void modified() const
Signal that component was modified.
Convenience type with enum reflection data.
flecs::entity get_scope() const
Get current scope.
T * get_mut() const
Get mut singleton component.
void remove() const
Remove singleton component.
flecs::entity get_alive(flecs::entity_t e) const
Get alive entity for id.
flecs::entity target(int32_t index=0) const
Get target for a given pair from a singleton entity.
const T * get() const
Get singleton component.
flecs::entity set_scope() const
Same as set_scope but with type.
void children(Func &&f) const
Iterate entities in root of world Accepts a callback with the following signature: void(*)(flecs::ent...
flecs::entity ensure(flecs::entity_t e) const
Ensures that entity with provided generation is alive.
flecs::entity lookup(const char *name, bool search_path=true) const
Lookup entity by name.
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.
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.