Function ecs_commit

Synopsis

#include <include/flecs.h>

FLECS_API bool ecs_commit(ecs_world_t *world, ecs_entity_t entity, ecs_record_t *record, ecs_table_t *table, ecs_ids_t *added, ecs_ids_t *removed)

Description

Commit (move) entity to a table. This operation moves an entity from its current table to the specified table. This may trigger the following actions:

  • Ctor for each component in the target table
  • Move for each overlapping component
  • Dtor for each component in the source table.
  • OnAdd triggers for non-overlapping components in the target table
  • OnRemove triggers for non-overlapping components in the source table.

This operation is a faster than adding/removing components individually.

The application must explicitly provide the difference in components between tables as the added/removed parameters. This can usually be derived directly from the result of ecs_table_add_id and esc_table_remove_id. These arrays are required to properly execute OnAdd/OnRemove triggers.

Parameters

world - The world.

entity - The entity to commit.

record - The entity's record (optional, providing it saves a lookup).

table - The table to commit the entity to.

Returns
True if the entity got moved, false otherwise.

Source

Line 3480 in include/flecs.h.