15template <
typename Self>
16template <
typename Func>
19 this->world_, this->id_, func);
23template <typename T, if_t< is_enum<T>::value > >
30 using U =
typename std::underlying_type<T>::type;
31 const T* v =
static_cast<const T*
>(
33 ecs_assert(v != NULL, ECS_INTERNAL_ERROR,
"missing enum constant value");
37 return static_cast<const T*
>(
ecs_get_id(world_, id_, r));
41 return static_cast<const T*
>(
ecs_get_id(world_, id_, r));
45template<
typename First>
53 flecs::entity_t relationship,
61 flecs::entity_t relationship,
73template <
typename First,
typename Second>
75 return target_for(relationship, _::type<First, Second>::id(world_));
79 return target(flecs::ChildOf);
84 "cannot use readonly world/stage to create mutable handle");
90 "cannot use iterator created for readonly world/stage to create mutable handle");
96 "cannot use entity created for readonly world/stage to create mutable handle");
116 ECS_RECORD_TO_ROW(r->
row), 1);
121template <
typename Func>
131 for (
int i = 0; i < count; i ++) {
138template <
typename Func>
140 flecs::world_t *real_world =
const_cast<flecs::world_t*
>(
153 flecs::id_t pattern = pred;
155 pattern = ecs_pair(pred, obj);
169template <
typename Func>
177template <typename Func, if_t< is_callable<Func>::value > >
183 ecs_assert(id_ != 0, ECS_INVALID_PARAMETER,
"invalid lookup from null handle");
188inline flecs::entity entity_view::clone(
bool copy_value, flecs::entity_t dst_id)
const {
194 ecs_clone(world_, dst_id, id_, copy_value);
199template <
typename... Args>
204template <typename E, if_t< is_enum<E>::value >>
205inline flecs::id world::id(E value)
const {
206 flecs::entity_t constant = enum_type<E>(world_).entity(value);
210template <typename E, if_t< is_enum<E>::value >>
212 flecs::entity_t constant = enum_type<E>(world_).entity(value);
218 return flecs::entity(world_, _::type<T>::register_id(world_, name,
true) );
221template <
typename... Args>
224 result.
add(flecs::Prefab);
231 result.
add(flecs::Prefab);
#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_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_record_t * ecs_record_find(const ecs_world_t *world, ecs_entity_t entity)
Find record for entity.
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.
ecs_table_t * table
Identifies a type (and table) in world.
uint32_t row
Table row of the entity.
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.