@@ -15291,45 +15291,42 @@ void flecs_emit(
1529115291
1529215292 /* Check if this id is a pair of an traversable relationship. If so, we
1529315293 * may have to forward ids from the pair's target. */
15294- bool is_pair = ECS_IS_PAIR(id);
15295- if (can_forward && is_pair) {
15296- if (is_pair && (cr_flags & EcsIdTraversable)) {
15297- const ecs_event_record_t *er_fwd = NULL;
15298- if (ECS_PAIR_FIRST(id) == EcsIsA) {
15299- if (event == EcsOnAdd) {
15300- if (!world->stages[0]->base) {
15301- /* Adding an IsA relationship can trigger prefab
15302- * instantiation, which can instantiate prefab
15303- * hierarchies for the entity to which the
15304- * relationship was added. */
15305- ecs_entity_t tgt = ECS_PAIR_SECOND(id);
15306-
15307- /* Setting this value prevents flecs_instantiate
15308- * from being called recursively, in case prefab
15309- * children also have IsA relationships. */
15310- world->stages[0]->base = tgt;
15311- const ecs_entity_t *instances =
15312- ecs_table_entities(table);
15313- int32_t e;
15314-
15315- for (e = 0; e < count; e ++) {
15316- flecs_instantiate(
15317- world, tgt, instances[offset + e], NULL);
15318- }
15319-
15320- world->stages[0]->base = 0;
15294+ if (can_forward && (cr_flags & EcsIdTraversable)) {
15295+ const ecs_event_record_t *er_fwd = NULL;
15296+ if (ECS_PAIR_FIRST(id) == EcsIsA) {
15297+ if (event == EcsOnAdd) {
15298+ if (!world->stages[0]->base) {
15299+ /* Adding an IsA relationship can trigger prefab
15300+ * instantiation, which can instantiate prefab
15301+ * hierarchies for the entity to which the
15302+ * relationship was added. */
15303+ ecs_entity_t tgt = ECS_PAIR_SECOND(id);
15304+
15305+ /* Setting this value prevents flecs_instantiate
15306+ * from being called recursively, in case prefab
15307+ * children also have IsA relationships. */
15308+ world->stages[0]->base = tgt;
15309+ const ecs_entity_t *instances =
15310+ ecs_table_entities(table);
15311+ int32_t e;
15312+
15313+ for (e = 0; e < count; e ++) {
15314+ flecs_instantiate(
15315+ world, tgt, instances[offset + e], NULL);
1532115316 }
1532215317
15323- /* Adding an IsA relationship will emit OnSet events for
15324- * any new reachable components. */
15325- er_fwd = er_onset;
15318+ world->stages[0]->base = 0;
1532615319 }
15327- }
1532815320
15329- /* Forward events for components from pair target */
15330- flecs_emit_forward(world, er, er_fwd, ids, &it, table, cr);
15331- ecs_assert(it.event_cur == evtx, ECS_INTERNAL_ERROR, NULL);
15321+ /* Adding an IsA relationship will emit OnSet events for
15322+ * any new reachable components. */
15323+ er_fwd = er_onset;
15324+ }
1533215325 }
15326+
15327+ /* Forward events for components from pair target */
15328+ flecs_emit_forward(world, er, er_fwd, ids, &it, table, cr);
15329+ ecs_assert(it.event_cur == evtx, ECS_INTERNAL_ERROR, NULL);
1533315330 }
1533415331
1533515332 if (er) {
0 commit comments