Skip to content
DaanVanYperen edited this page Sep 10, 2014 · 1 revision

Subsystems in Artemis

Deferred entity systems are a drop in replacement for EntityProcessingSystem, where you need to delegate order of entity processing to an overarching system.

One example would be an animation, font and map rendering subsystem of a render pipeline principal, sorting render calls by z-layer and batching them by textures, shaders, etc.

Implementing

Implement each of your specialized subsystems by extending abstract class DeferredEntityProcessingSystem. Then implement EntityProcessPrincipal into a system that will call the subsystems in the order you desire (See RenderBatchingSystem for an example).

Register your principal as an active system, and all your subsystems as passive systems.

final RenderBatchingSystem renderBatchingSystem = new RenderBatchingSystem();
world.setSystem(renderBatchingSystem);
world.setSystem(new AnimRenderSystem(renderBatchingSystem), true);
world.setSystem(new LabelRenderSystem(renderBatchingSystem), true);
world.setSystem(new BarRenderSystem(renderBatchingSystem), true);

How it works

The deferred systems will cascade insert/removed entities to the principal, also providing a callback agent to the principal with begin, end and process methods. The principal then typically stores, batches and execute these jobs upon world.process() call.