3template <
typename Func>
4component& opaque(
const Func& type_support) {
6 auto ts = type_support(world);
7 ts.desc.entity = _::type<T>::id(world_);
17 return this->opaque(as_type.
id());
21 return this->opaque(as_type.
id());
25template <
typename ElemType>
31component<T>& constant(
const char *name, T value) {
32 using U =
typename std::underlying_type<T>::type;
34 ecs_add_id(world_, id_, _::type<flecs::Enum>::id(world_));
40 ecs_assert(eid != 0, ECS_INTERNAL_ERROR, NULL);
42 flecs::id_t pair = ecs_pair(flecs::Constant, _::type<U>::id(world_));
44 *ptr =
static_cast<U
>(value);
void ecs_add_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
Add a (component) id to an entity.
#define ecs_assert(condition, error_code,...)
Assert.
ecs_id_t ecs_entity_t
An entity identifier.
ecs_entity_t ecs_entity_init(ecs_world_t *world, const ecs_entity_desc_t *desc)
Find or create an entity.
void * ecs_ensure_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
Get a mutable pointer to a component.
void ecs_modified_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
Signal that a component has been modified.
Used with ecs_entity_init().
const char * name
Name of the entity.
ecs_entity_t parent
Parent entity.
entity_t id() const
Get entity id.
Type safe interface for opaque types.
opaque & as_type(flecs::id_t func)
Type that describes the type kind/structure of the opaque type.