Skip to content

Systems look for certain combinations of components in entities and modify the data of said components in each frame. Systems determine the behaviour of entities.

There are a total of 4 different types of systems:

OrderTypeDescription
1Initialisation systemsInitialize entities when they are first added to the world and when they are re-activated.
2Input systemsRead user input and modify data of components in each frame.
3Update systemsModify the data of components in each frame.
4Render systemsTurn components into visuals that are rendered to the screen.

Initialisation systems are also executed when an inactive entity is re-activated. Input, update and render systems are executed in each frame in the order specified above.

Creating systems

Below is a list of 3 different ways of creating systems, orderered from most to least simple. All examples are update systems, but other types of systems can be created in the same way. The examples are systems that require a Transform component.

Option 1: Extending system base class

This option is best used for systems that need to perform certain logic once per frame, before or after processing all entities.

public class TransformInitializer extends InitSystemBase {
public TransformInitializer() {
super(Transform.class);
}
@Override
public void init() {
// ...
forEach(chunk -> {
Transform transform = chunk.getComponent(Transform.class);
// ...
});
}
}

Option 2: Extending system class

public class TransformInitializer extends UpdateSystem {
public TransformInitializer() {
super(Transform.class);
}
@Override
public void process(EntityChunk chunk) {
Transform transform = chunk.getComponent(Transform.class);
// ...
}
}

Option 3: Using system builder

InitSystemBuilder initSystemBuilder = new InitSystemBuilder(Transform.class);
initSystemBuilder.setCallback(chunk -> {
Transform transform = chunk.getComponent(Transform.class);
// ...
});
InitSystem transformInitializer = initSystemBuilder.build();

Adding systems to the world

Systems should be added to the world during scene loading, before any entities are added to the scene.

world.addSystem(transformUpdater);