38 explicit entity(
const flecs::world_t *
world, flecs::entity_t
id) {
39 world_ =
const_cast<flecs::world_t*
>(
world);
51 id_ = ecs_cpp_new(
world, 0,
nullptr,
nullptr,
nullptr);
64 const char *sep =
"::",
87 const char *sep =
"::",
135 template <
typename T>
139 "operation invalid for empty type");
140 return *
static_cast<T*
>(
ecs_ensure_id(world_, id_, comp_id,
sizeof(T)));
155 "provided component is not a type or has size 0");
165 template <
typename First,
typename Second,
typename P = pair<First, Second>,
166 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value> = 0>
179 template <
typename First>
183 "operation invalid for empty type");
184 return *
static_cast<First*
>(
206 template <
typename Second>
210 ECS_INVALID_PARAMETER,
"pair is not a component");
212 ECS_INVALID_PARAMETER,
"type of pair is not Second");
214 "operation invalid for empty type");
215 return *
static_cast<Second*
>(
225 template <
typename T>
229 "operation invalid for empty type");
238 template <
typename First,
typename Second,
typename A = actual_type_t<flecs::pair<First, Second>>>
243 "operation invalid for empty type");
252 template <
typename First>
256 "operation invalid for empty type");
297 template <typename T, if_t< is_actual<T>::value > = 0>
310 template <typename T, if_t< is_actual<T>::value > = 0>
324 template <
typename T,
typename A = actual_type_t<T>, if_t< flecs::is_pair<T>::value > = 0>
326 return ref<A>(world_, id_,
332 template <
typename First,
typename Second,
typename P = flecs::pair<First, Second>,
333 typename A = actual_type_t<P>>
335 return ref<A>(world_, id_,
339 template <
typename First>
341 auto first = _::type<First>::id(world_);
342 return ref<First>(world_, id_, ecs_pair(
first,
second));
345 untyped_ref
get_ref(flecs::id_t component)
const {
346 return untyped_ref(world_, id_, component);
350 return untyped_ref(world_, id_, ecs_pair(
first,
second));
353 template <
typename Second>
354 ref<Second> get_ref_second(flecs::entity_t
first)
const {
355 auto second = _::type<Second>::id(world_);
357 ECS_INVALID_PARAMETER,
"pair is not a component");
359 ECS_INVALID_PARAMETER,
"type of pair is not Second");
360 return ref<Second>(world_, id_, ecs_pair(
first,
second));
384 template <
typename ... Args>
390 template <
typename R,
typename ... Args>
428 result.world_ =
const_cast<flecs::world_t*
>(
world);
438# include "mixins/json/entity.inl"
Entity class with only readonly operations.
void ecs_clear(ecs_world_t *world, ecs_entity_t entity)
Clear all components.
#define ecs_assert(condition, error_code,...)
Assert.
const ecs_type_info_t * ecs_get_type_info(const ecs_world_t *world, ecs_id_t component)
Get the type info for an component.
flecs::entity entity(Args &&... args) const
Create an entity.
void ecs_set_child_order(ecs_world_t *world, ecs_entity_t parent, const ecs_entity_t *children, int32_t child_count)
Set child order for parent with OrderedChildren.
ecs_entity_t ecs_entity_init(ecs_world_t *world, const ecs_entity_desc_t *desc)
Find or create an entity.
void ecs_delete(ecs_world_t *world, ecs_entity_t entity)
Delete an entity.
ecs_entity_t ecs_new_w_parent(ecs_world_t *world, ecs_entity_t parent, const char *name)
Create child with Parent component.
void ecs_modified_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Signal that a component has been modified.
void * ecs_ensure_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t component, size_t size)
Ensure entity has component, return pointer.
const ecs_world_t * ecs_get_world(const ecs_poly_t *poly)
Get world from poly.
Used with ecs_entity_init().
const char * sep
Optional custom separator for hierarchical names.
const char * root_sep
Optional, used for identifiers relative to root.
const char * name
Name of the entity.
ecs_entity_t parent
Parent entity.
Type that contains component information (passed to ctors/dtors/...)
ecs_size_t size
Size of type.
const Self & add() const
Add a component to an entity.
flecs::string_view name() const
Return the entity name.
flecs::entity parent() const
Get parent of entity.
entity_t id() const
Get entity id.
void children(flecs::entity_t rel, Func &&func) const
Iterate children for entity.
void destruct() const
Delete an entity.
ref< T > get_ref() const
Get reference to component.
void modified(entity_t second) const
Signal that the first part of a pair was modified.
void modified() const
Signal that the first element of a pair was modified.
First & ensure(entity_t second) const
Get mutable pointer for the first element of a pair.
void modified(entity_t comp) const
Signal that component was modified.
void clear() const
Clear an entity.
ref< T > get_ref_w_id(flecs::id_t component) const
Get reference to component specified by id.
void modified(entity_t first, entity_t second) const
Signal that a pair has modified (untyped).
void * ensure(entity_t first, entity_t second) const
Get mutable pointer for a pair (untyped).
entity(const flecs::world_t *world, flecs::entity_t id)
Wrap an existing entity id.
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.
entity(world_t *world, flecs::entity_t parent, const char *name, const char *sep="::", const char *root_sep="::")
Create a named entity for parent using ChildOf hierarchy storage.
Second & ensure_second(entity_t first) const
Get mutable pointer for the second element of a pair.
void * ensure(entity_t comp) const
Get mutable component value (untyped).
entity(entity_t id)
Conversion from flecs::entity_t to flecs::entity.
entity(world_t *world, const char *name, const char *sep="::", const char *root_sep="::")
Create a named entity.
entity(world_t *world)
Create a new entity.
flecs::entity_view view() const
Return entity as entity_view.
void set_child_order(flecs::entity_t *children, int32_t child_count) const
Set child order.
ref< A > get_ref() const
Get reference to component.
A & ensure() const
Get mutable pointer for a pair.
entity(world_t *world, const flecs::Parent &parent, const char *name=nullptr)
Create a named entity for parent using Parent hierarchy storage.
flecs::entity child(flecs::entity_t r=flecs::ChildOf, Args &&... args)
Create child.
Class that wraps around a flecs::id_t.
flecs::entity second() const
Get second element from a pair.
flecs::entity first() const
Get first element from a pair.