8#define ECS_EVENT_DESC_ID_COUNT_MAX (8)
18template <
typename Base,
typename E>
19struct event_builder_base {
20 event_builder_base(flecs::world_t *
world, flecs::entity_t
event)
32 ids_.array = ids_array_;
33 ids_.array[ids_.count] =
_::type<T>().id(world_);
43 template <
typename First,
typename Second>
55 template <
typename First>
56 Base&
id(entity_t second) {
65 Base&
id(entity_t first, entity_t second) {
66 return id(ecs_pair(first, second));
69 template <typename Enum, if_t<is_enum<Enum>::value> = 0>
70 Base&
id(Enum value) {
71 const auto& et = enum_type<Enum>(this->world_);
72 flecs::entity_t target = et.entity(value);
73 return id(et.entity(), target);
77 Base&
id(flecs::id_t
id) {
78 ids_.array = ids_array_;
79 ids_.array[ids_.count] =
id;
91 Base&
table(flecs::table_t *t, int32_t offset = 0, int32_t count = 0) {
99 Base& ctx(
const E* ptr) {
111 ids_.array = ids_array_;
113 desc_.observable =
const_cast<flecs::world_t*
>(
ecs_get_world(world_));
118 ids_.array = ids_array_;
120 desc_.observable =
const_cast<flecs::world_t*
>(
ecs_get_world(world_));
125 flecs::world_t *world_;
128 flecs::id_t ids_array_[ECS_EVENT_DESC_ID_COUNT_MAX];
132 return *
static_cast<Base*
>(
this);
137 using event_builder_base::event_builder_base;
146 using event_builder_base<Class, E>::event_builder_base;
149 Class& ctx(
const E& ptr) {
150 this->desc_.const_param = &ptr;
155 Class& ctx(E&& ptr) {
156 this->desc_.param = &ptr;
void ecs_emit(ecs_world_t *world, ecs_event_desc_t *desc)
Send event.
void ecs_enqueue(ecs_world_t *world, ecs_event_desc_t *desc)
Enqueue event.
struct ecs_event_desc_t ecs_event_desc_t
Used with ecs_emit().
const ecs_world_t * ecs_get_world(const ecs_poly_t *poly)
Get world from poly.
const void * const_param
Same as param, but with the guarantee that the value won't be modified.
ecs_table_t * table
The table for which to notify.
int32_t count
Limit number of notified entities to count.
int32_t offset
Limit notified entities to ones starting from offset (row) in table.
Base & id()
Add component to emit for.
Base & id(flecs::id_t id)
Add (component) id to emit for.
Base & entity(flecs::entity_t e)
Set entity for which to emit event.
Base & id(entity_t first, entity_t second)
Add pair to emit for.
Base & id(entity_t second)
Add pair to emit for.
Base & id()
Add pair to emit for.
flecs::event_builder event(flecs::entity_t evt) const
Create a new event.