Skip to content
Daan van Yperen edited this page Sep 29, 2015 · 24 revisions

Systems encapsulate game logic, typically operating on a family of entities.

Creating a System

Extend one of the following:

Class Extend when you want to
int
IteratingSystem Process a subset of entities each tick.
BaseEntitySystem Track a subset of entities, write your own sort/iterate yourself.
IntervalIteratingSystem Process a subset of entities every x ticks.
DelayedIteratingSystem Track cooldown per entity, processing entity when its timer runs out.
Entity
EntityProcessingSystem Process a subset of entities each tick.
EntitySystem Track a subset of entities, write your own sort/iterate yourself.
IntervalEntityProcessingSystem Process a subset of entities every x ticks.
DelayedEntityProcessingSystem Track cooldown per entity, processing entity when its timer runs out.
other
BaseSystem A completely customizable system or manager.

Register with WorldConfiguration#setSystem before passing it to World.

Good to know

Order of operation

Your registered systems are called in the order added to WorldConfiguration.

Inter-system communication

Systems can access other systems. Like all odb-native types Systems get injected automatically into your System.

public MySystem extends ... {
   MyOtherSystem myOtherSystem; // automatically injected.
}

See @Wire for details.

Initializing your system

Override #initialize() to initialize your system, not your constructor. Initialize is called after dependency injection.

class MySystem extends BaseSystem {
   @Override 
   public initialize() 
   {
      // custom initialization.
   }
}

Skip processing

Override checkProcessing to return false if you want to skip the system during processing.

Entity notifications

You can override inserted and removed methods in EntitySystem and derived classes. There you will be notified about entity changes.

Clone this wiki locally