11inline void world::init_builtin_components() {
12 this->component<Component>();
13 this->component<Identifier>();
14 this->component<Poly>();
17 _::system_init(*
this);
36 const char *name = alias;
47 ecs_assert(e != 0, ECS_INVALID_PARAMETER, NULL);
54 entity_t eid = e.
id();
55 const char *name = alias;
76inline entity world::lookup(
const char *name,
const char *sep,
const char *root_sep,
bool recursive)
const {
95template <
typename First,
typename Second>
96inline void world::set(Second second,
const First& value)
const {
98 e.set<First>(second, value);
101template <
typename First,
typename Second>
104 e.set<First>(second, value);
119template <
typename First,
typename Second,
typename P,
typename A>
122 return e.
get<First, Second>();
125template <
typename First,
typename Second>
128 return e.
get<First>(second);
137template <
typename First,
typename Second,
typename P,
typename A>
140 return e.
get_mut<First, Second>();
143template <
typename First,
typename Second>
146 return e.
get_mut<First>(second);
155template <
typename First,
typename Second>
158 return e.
has<First, Second>();
161template <
typename First>
164 return e.
has<First>(second);
167inline bool world::has(flecs::id_t first, flecs::id_t second)
const {
169 return e.
has(first, second);
178template <
typename First,
typename Second>
181 e.
add<First, Second>();
184template <
typename First>
187 e.
add<First>(second);
190inline void world::add(flecs::entity_t first, flecs::entity_t second)
const {
192 e.
add(first, second);
201template <
typename First,
typename Second>
204 e.
remove<First, Second>();
207template <
typename First>
213inline void world::remove(flecs::entity_t first, flecs::entity_t second)
const {
218template <
typename Func>
228template <
typename First>
237 flecs::entity_t relationship,
245 flecs::entity_t relationship,
252template <typename Func, if_t< is_callable<Func>::value > >
254 static_assert(
arity<Func>::value == 1,
"singleton component must be the only argument");
256 this->world_, this->
singleton<first_arg_t<Func>>(), func);
259template <typename Func, if_t< is_callable<Func>::value > >
261 static_assert(
arity<Func>::value == 1,
"singleton component must be the only argument");
263 this->world_, this->
singleton<first_arg_t<Func>>(), func);
282inline flecs::entity enum_data<E>::entity(underlying_type_t<E> value)
const {
283 int index = index_by_value(value);
285 int32_t constant_i = impl_.constants[index].index;
286 flecs::entity_t entity = flecs_component_ids_get(world_, constant_i);
293 .with(flecs::ChildOf, world.
id<E>())
294 .with(flecs::Constant, world.
id<int32_t>())
297 const int32_t *constant_value = constant.get_second<int32_t>(flecs::Constant);
298 ecs_assert(constant_value, ECS_INTERNAL_ERROR, NULL);
299 return value ==
static_cast<underlying_type_t<E>
>(*constant_value);
308 return entity(
static_cast<underlying_type_t<E>
>(value));
325 return scope(
entity(name));
#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.
const T * get() const
Get component value.
T * get_mut() const
Get mutable 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.
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.
T * get_mut() const
Get 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
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 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.