20template <
typename Self>
21template <
typename Func>
24 this->world_, this->id_, func);
28template <typename T, if_t< is_enum<T>::value > >
35 using U =
typename std::underlying_type<T>::type;
36 const T* v =
static_cast<const T*
>(
38 ecs_assert(v != NULL, ECS_INTERNAL_ERROR,
"missing enum constant value");
42 return static_cast<const T*
>(
ecs_get_id(world_, id_, r));
46 return static_cast<const T*
>(
ecs_get_id(world_, id_, r));
50template<
typename First>
58 flecs::entity_t relationship,
66 flecs::entity_t relationship,
78template <
typename First,
typename Second>
80 return target_for(relationship, _::type<First, Second>::id(world_));
84 return target(flecs::ChildOf);
89 "cannot use readonly world/stage to create mutable handle");
95 "cannot use iterator created for readonly world/stage to create mutable handle");
101 "cannot use entity created for readonly world/stage to create mutable handle");
121 ECS_RECORD_TO_ROW(r->
row), 1);
126template <
typename Func>
136 for (
int i = 0; i < count; i ++) {
143template <
typename Func>
145 flecs::world_t *real_world =
const_cast<flecs::world_t*
>(
158 flecs::id_t pattern = pred;
160 pattern = ecs_pair(pred, obj);
174template <
typename Func>
182template <typename Func, if_t< is_callable<Func>::value > >
188 ecs_assert(id_ != 0, ECS_INVALID_PARAMETER,
"invalid lookup from null handle");
193inline flecs::entity entity_view::clone(
bool copy_value, flecs::entity_t dst_id)
const {
199 ecs_clone(world_, dst_id, id_, copy_value);
204template <
typename... Args>
209template <typename E, if_t< is_enum<E>::value >>
210inline flecs::id world::id(E value)
const {
211 flecs::entity_t constant = enum_type<E>(world_).entity(value);
215template <typename E, if_t< is_enum<E>::value >>
217 flecs::entity_t constant = enum_type<E>(world_).entity(value);
223 return flecs::entity(world_, _::type<T>::register_id(world_, name,
true, 0,
false) );
226template <
typename... Args>
229 result.
add(flecs::Prefab);
236 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.
void each(const flecs::entity_view &rel, const Func &func) const
Iterate targets for a given relationship.
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.
flecs::entity entity() const
Return entity associated with reference.
flecs::id component() const
Return component associated with reference.
world_t * c_ptr() const
Obtain pointer to C world object.
bool is_readonly() const
Test whether the current world object is readonly.