Registering a System or an Engine

To register Systems/Engines, you need to provide a register function to the tm_entity_register_engines_simulation_i interface. This function has the signature:

static void entity_register_engines_i(struct tm_entity_context_o *ctx)

For more information check the tm_entity_register_engines_simulation_i .

Whenever the Machinery creates an Entity Context, it calls this function and registers all your Systems / Engines to this context.

The Entity context is the world in which all your entities exist.

For Engines, you pass an instance of the tm_entity_system_i to the register function.

// example:
const tm_entity_system_i winning_system = {
    .ui_name = "winning_system_update",
    .hash = TM_STATIC_HASH("winning_system_update", 0x8f8676e599ca5c7aULL),
    .update = winning_system_update,
    .before_me[0] =
        TM_STATIC_HASH("maze_generation_system", 0x7f1fcbd9ee85c3cfULL),
    .exclusive = true,
tm_entity_api->register_system(ctx, &winning_system);

For Systems, you pass an instance of the tm_engine_i to the register function.

static void entity_register_engines_i(struct tm_entity_context_o *ctx) {

  tm_component_type_t keyboard_component = tm_entity_api->lookup_component_type(
  tm_component_type_t movement_component = tm_entity_api->lookup_component_type(
  tm_component_type_t transform_component =
  tm_component_type_t mover_component = tm_entity_api->lookup_component_type(
  const tm_engine_i movement_engine = {
      .ui_name = "movement_engine",
      .hash = TM_STATIC_HASH("movement_engine", 0x336880a23d06646dULL),
      .num_components = 4,
      .components = {keyboard_component, movement_component,
                     transform_component, mover_component},
      .writes = {false, false, true, true},
      .update = movement_update,
      .inst = (tm_engine_o *)ctx,
  tm_entity_api->register_engine(ctx, &movement_engine);

In the above example the scheduler will schedule this system after the maze_generation_system system! Since we did not provide any further information in .writes or in .components the scheduler has no other information to work with. In this case it is best to not write anything!

Example load function:

TM_DLL_EXPORT void tm_load_plugin(struct tm_api_registry_api *reg, bool load) {
  tm_entity_api = tm_get_api(reg, tm_entity_api);
  tm_add_or_remove_implementation(reg, load,
  tm_add_or_remove_implementation(reg, load,

Register your system or engine to the Editor

You can use the tm_entity_register_engines_simulation_i to register your engine or system to an entity context that runs only in the Editor. This might be good for components that shall only be used in the Editor.

The function signature is the same as the for the other interface!

Register systems & engines outside of the load function

You also can register your System/Engine outside of the load function wherever you have access to the correct Entity Context.