11inline void world::init_builtin_components() {
12 this->component<Component>();
13 this->component<Identifier>();
14 this->component<Poly>();
19# if !defined(FLECS_META) && !defined(FLECS_CPP_NO_ENUM_REFLECTION)
20 this->component<uint8_t>(
"flecs::meta::u8");
21 this->component<uint16_t>(
"flecs::meta::u16");
22 this->component<uint32_t>(
"flecs::meta::u32");
23 this->component<uint64_t>(
"flecs::meta::u64");
24 this->component<int8_t>(
"flecs::meta::i8");
25 this->component<int16_t>(
"flecs::meta::i16");
26 this->component<int32_t>(
"flecs::meta::i32");
27 this->component<int64_t>(
"flecs::meta::i64");
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);
155inline const void* world::get(flecs::id_t
id)
const {
160inline const void* world::get(flecs::entity_t r, flecs::entity_t t)
const {
166inline const T& world::get()
const {
171template <
typename First,
typename Second,
typename P,
typename A>
172inline const A& world::get()
const {
174 return e.
get<First, Second>();
177template <
typename First,
typename Second>
178const First& world::get(Second second)
const {
180 return e.
get<First>(second);
183inline void* world::try_get_mut(flecs::id_t
id)
const {
188inline void* world::try_get_mut(flecs::entity_t r, flecs::entity_t t)
const {
194inline T* world::try_get_mut()
const {
196 return e.try_get_mut<T>();
199template <
typename First,
typename Second,
typename P,
typename A>
200inline A* world::try_get_mut()
const {
205template <
typename First,
typename Second>
206inline First* world::try_get_mut(Second second)
const {
211inline void* world::get_mut(flecs::id_t
id)
const {
216inline void* world::get_mut(flecs::entity_t r, flecs::entity_t t)
const {
222inline T& world::get_mut()
const {
224 return e.get_mut<T>();
227template <
typename First,
typename Second,
typename P,
typename A>
228inline A& world::get_mut()
const {
230 return e.
get_mut<First, Second>();
233template <
typename First,
typename Second>
234inline First& world::get_mut(Second second)
const {
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 > >
343inline void world::get(
const Func& func)
const {
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);
383 .with(flecs::ChildOf, world.
id<E>())
384 .with(flecs::Constant, world.
id<int32_t>())
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));
414 return scope(
entity(name));
component< T > & constant(const char *name, T value)
Add constant.
#define ecs_assert(condition, error_code,...)
Assert.
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 enum constant to 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 & 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.
Convenience type with enum reflection data.
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::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.
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 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.
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.