com.artemis.systems.EntityProcessingSystem 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.Entity;
import com.artemis.EntitySystem;
import com.artemis.World;
import com.artemis.utils.IntBag;
/**
* A typical entity system.
*
* Use this when you need to process entities possessing the provided component
* types.
*
*
* @author Arni Arent
*/
public abstract class EntityProcessingSystem extends EntitySystem {
private Entity flyweight;
/**
* Creates a new EntityProcessingSystem.
*
* @param aspect
* the aspect to match entities
*/
public EntityProcessingSystem(Aspect.Builder aspect) {
super(aspect);
}
@Override
protected void setWorld(World world) {
super.setWorld(world);
flyweight = createFlyweightEntity();
}
/**
* Process a entity this system is interested in.
*
* @param e
* the entity to process
*/
protected abstract void process(Entity e);
@Override
protected final void processSystem() {
IntBag actives = subscription.getEntities();
int[] array = actives.getData();
Entity e = flyweight;
for (int i = 0, s = actives.size(); s > i; i++) {
e.id = array[i];
process(e);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy