com.artemis.systems.IntervalIteratingSystem Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of artemis-odb Show documentation
Show all versions of artemis-odb Show documentation
Fork of Artemis Entity System Framework.
package com.artemis.systems;
import com.artemis.Aspect;
import com.artemis.utils.IntBag;
/**
* Process a subset of entities every x ticks.
*
* 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.
*
*
* @author Arni Arent
* @author Adrian Papari
*/
public abstract class IntervalIteratingSystem extends IntervalSystem {
/**
* Creates a new IntervalEntityProcessingSystem.
*
* @param aspect
* the aspect to match entities
* @param interval
* the interval at which the system is processed
*/
public IntervalIteratingSystem(Aspect.Builder aspect, float interval) {
super(aspect, interval);
}
/**
* Process a entity this system is interested in.
*
* @param entityId
* the entity to process
*/
protected abstract void process(int entityId);
@Override
protected void processSystem() {
IntBag entities = subscription.getEntities();
int[] ids = entities.getData();
for (int i = 0, s = entities.size(); s > i; i++) {
process(ids[i]);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy