10inline untyped_ref::untyped_ref(
flecs::entity entity, flecs::id_t
id)
11 : untyped_ref(entity.world(), entity.id(), id) { }
21template <
typename Self>
22template <
typename Func>
25 this->world_, this->id_, func);
29template <typename T, if_t< is_enum<T>::value > >
36 using U =
typename std::underlying_type<T>::type;
37 const T* v =
static_cast<const T*
>(
39 ecs_assert(v != NULL, ECS_INTERNAL_ERROR,
"missing enum constant value");
43 return static_cast<const T*
>(
ecs_get_id(world_, id_, r));
47 return static_cast<const T*
>(
ecs_get_id(world_, id_, r));
51template<
typename First>
59 flecs::entity_t relationship,
67 flecs::entity_t relationship,
79template <
typename First,
typename Second>
81 return target_for(relationship, _::type<First, Second>::id(world_));
85 return target(flecs::ChildOf);
90 "cannot use readonly world/stage to create mutable handle");
96 "cannot use iterator created for readonly world/stage to create mutable handle");
102 "cannot use entity created for readonly world/stage to create mutable handle");
122 ECS_RECORD_TO_ROW(r->row), 1);
127template <
typename Func>
137 for (
int i = 0; i < count; i ++) {
144template <
typename Func>
146 flecs::world_t *real_world =
const_cast<flecs::world_t*
>(
159 flecs::id_t pattern = pred;
161 pattern = ecs_pair(pred, obj);
175template <
typename Func>
183template <typename Func, if_t< is_callable<Func>::value > >
189 ecs_assert(id_ != 0, ECS_INVALID_PARAMETER,
"invalid lookup from null handle");
194inline flecs::entity entity_view::clone(
bool copy_value, flecs::entity_t dst_id)
const {
200 ecs_clone(world_, dst_id, id_, copy_value);
205template <
typename... Args>
210template <typename E, if_t< is_enum<E>::value >>
211inline flecs::id world::id(E value)
const {
212 flecs::entity_t
constant = enum_type<E>(world_).entity(value);
216template <typename E, if_t< is_enum<E>::value >>
218 flecs::entity_t
constant = enum_type<E>(world_).entity(value);
224 return flecs::entity(world_, _::type<T>::register_id(world_, name,
true,
false) );
227template <
typename... Args>
230 result.
add(flecs::Prefab);
237 result.
add(flecs::Prefab);
component< T > & constant(const char *name, T value)
Add constant.
#define ecs_assert(condition, error_code,...)
Assert.
uint64_t ecs_id_t
Ids are the things that can be added to an entity.
struct ecs_record_t ecs_record_t
Information about an entity, like its table and row.
struct ecs_table_t ecs_table_t
A table stores entities and components for a specific type.
flecs::entity prefab(Args &&... args) const
Create a prefab.
flecs::entity entity(Args &&... args) const
Create an entity.
flecs::id_t * array() const
Return pointer to array.
int32_t count() const
Return number of ids in type.
ecs_entity_t ecs_clone(ecs_world_t *world, ecs_entity_t dst, ecs_entity_t src, bool copy_value)
Clone an entity This operation clones the components of one entity into another entity.
ecs_entity_t ecs_new(ecs_world_t *world)
Create new entity id.
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.
const ecs_type_t * ecs_get_type(const ecs_world_t *world, ecs_entity_t entity)
Get the type of an entity.
ecs_entity_t ecs_get_target_for_id(const ecs_world_t *world, ecs_entity_t entity, ecs_entity_t rel, ecs_id_t id)
Get the target of a relationship for a given id.
ecs_table_t * ecs_get_table(const ecs_world_t *world, ecs_entity_t entity)
Get the table of an entity.
const void * ecs_get_id(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
Get an immutable pointer to a component.
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 ecs_type_t * ecs_table_get_type(const ecs_table_t *table)
Get type for table.
int32_t ecs_search_offset(const ecs_world_t *world, const ecs_table_t *table, int32_t offset, ecs_id_t id, ecs_id_t *id_out)
Search for component id in table type starting from an offset.
const ecs_world_t * ecs_get_world(const ecs_poly_t *poly)
Get world from poly.
A type is a list of (component) ids.
const Self & insert(const Func &func) const
Set 1..N components.
const Self & add() const
Add a component to an entity.
flecs::type type() const
Get the entity's type.
const T * get() const
Get component value.
flecs::string path(const char *sep="::", const char *init_sep="::") const
Return the entity path.
flecs::table_range range() const
Get table range for the entity.
flecs::entity target_for(flecs::entity_t relationship, flecs::id_t id) const
Get the target of a pair for a given relationship id.
flecs::entity lookup(const char *path, bool search_path=false) const
Lookup an entity by name.
flecs::table table() const
Get the entity's table.
flecs::entity parent() const
Get parent of entity.
void each(const Func &func) const
Iterate (component) ids of an entity.
flecs::entity target(int32_t index=0) const
Get target for a given pair.
flecs::entity mut(const flecs::world &stage) const
Return mutable entity handle for current stage When an entity handle created from the world is used w...
Class that wraps around a flecs::id_t.
flecs::entity second() const
Get second element from a pair.
Class for iterating over query results.
world_t * c_ptr() const
Obtain pointer to C world object.
bool is_readonly() const
Test whether the current world object is readonly.