All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.artemis.systems.EntityProcessingSystem Maven / Gradle / Ivy

There is a newer version: 2.3.0
Show newest version
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