Dart DocumentationdartemisIntervalEntityProcessingSystem

IntervalEntityProcessingSystem abstract class

If you need to process entities at a certain interval then use this. A typical usage would be to regenerate ammo or health at certain intervals, no need to do that every game loop, but perhaps every 100 ms. or every second.

abstract class IntervalEntityProcessingSystem extends IntervalEntitySystem {

 /**
  * Create a new [IntervalEntityProcessingSystem]. It requires at least one component.
  */
 IntervalEntityProcessingSystem(int interval, Aspect aspect) : super(interval, aspect);

 /**
  * Process an [entity] this system is interested in.
  */
 void processEntity(Entity entity);

 void processEntities(ReadOnlyBag<Entity> entities) => entities.forEach((entity) => processEntity(entity));

}

Extends

EntitySystem > IntervalEntitySystem > IntervalEntityProcessingSystem

Constructors

new IntervalEntityProcessingSystem(int interval, Aspect aspect) #

Create a new IntervalEntityProcessingSystem. It requires at least one component.

IntervalEntityProcessingSystem(int interval, Aspect aspect) : super(interval, aspect);

Properties

final num delta #

inherited from IntervalEntitySystem

Returns the accumulated delta since the system was last invoked.

num get delta => _delta;

final passive #

inherited from EntitySystem
get passive => _passive;

World world #

inherited from EntitySystem
World world

Methods

void added(Entity e) #

inherited from EntitySystem
void added(Entity e) => _check(e);

void begin() #

inherited from EntitySystem

Called before processing of entities begins.

void begin() {}

void changed(Entity e) #

inherited from EntitySystem
void changed(Entity e) => _check(e);

bool checkProcessing() #

inherited from IntervalEntitySystem

Returns true if the system should be processed, false if not.

docs inherited from EntitySystem
bool checkProcessing() {
 _acc += world.delta;
 _delta += world.delta;
 if(_acc >= _interval) {
   _acc -= _interval;
   return true;
 }
 return false;
}

void deleted(Entity e) #

inherited from EntitySystem
void deleted(Entity e) {
 if (_contains(e)) {
   _removeFromSystem(e);
 }
}

void disabled(Entity e) #

inherited from EntitySystem
void disabled(Entity e) {
 if (_contains(e)) {
   _removeFromSystem(e);
 }
}

void enabled(Entity e) #

inherited from EntitySystem
void enabled(Entity e) => _check(e);

void end() #

inherited from IntervalEntitySystem

Resets the accumulated delta to 0.

Call super.end() if you overwrite this function.

void end() {
 _delta = 0;
}

void initialize() #

inherited from EntitySystem

Override to implement code that gets executed when systems are initialized.

void initialize() {}

void inserted(Entity entity) #

inherited from EntitySystem

Called if the system has received an entity it is interested in, e.g. created or a component was added to it.

void inserted(Entity entity) {}

void process() #

inherited from EntitySystem

This is the only method that is supposed to be called from outside the library,

void process() {
 if(checkProcessing()) {
   begin();
   processEntities(_actives.readOnly);
   end();
 }
}

void processEntities(ReadOnlyBag<Entity> entities) #

Any implementing entity system must implement this method and the logic to process the given entities of the system.

docs inherited from EntitySystem
void processEntities(ReadOnlyBag<Entity> entities) => entities.forEach((entity) => processEntity(entity));

abstract void processEntity(Entity entity) #

Process an entity this system is interested in.

void removed(Entity entity) #

inherited from EntitySystem

Called if an entity was removed from this system, e.g. deleted or had one of it's components removed.

void removed(Entity entity) {}