Search in sources :

Example 1 with AliveComponent

use of com.gemserk.commons.artemis.components.AliveComponent in project commons-gdx by gemserk.

the class AliveSystem method processEntities.

@Override
protected void processEntities() {
    RandomAccessMap<Entity, EntityComponents> allTheEntityComponents = factory.entityComponents;
    int entitiesSize = allTheEntityComponents.size();
    for (int entityIndex = 0; entityIndex < entitiesSize; entityIndex++) {
        EntityComponents entityComponents = allTheEntityComponents.get(entityIndex);
        AliveComponent aliveComponent = entityComponents.aliveComponent;
        float aliveTime = aliveComponent.getTime() - GlobalTime.getDelta();
        aliveComponent.setTime(aliveTime);
        if (aliveTime <= 0) {
            Entity e = allTheEntityComponents.getKey(entityIndex);
            StoreComponent storeComponent = StoreComponent.get(e);
            if (storeComponent != null)
                storeComponent.store.free(e);
            else
                e.delete();
        }
    }
}
Also used : Entity(com.artemis.Entity) AliveComponent(com.gemserk.commons.artemis.components.AliveComponent) StoreComponent(com.gemserk.commons.artemis.components.StoreComponent)

Aggregations

Entity (com.artemis.Entity)1 AliveComponent (com.gemserk.commons.artemis.components.AliveComponent)1 StoreComponent (com.gemserk.commons.artemis.components.StoreComponent)1