The current implementation of DelayedProcessingEntitySystem is confusing and flawed.
The idea of delayed processing of entities is valid, however it seems unnatural for all the entities to live on the same timer seems badly designed.
It seems like a better approach would be to store the delay in a component that is unique for every entity and have the delayed processing system process entities according to their individual delay timer.
Something along the lines of:
public abstract class DelayComponent implements Component {
public float delay;
}
public abstract class <T extends DelayComponent> DelayProcessingEntitySystem<T> extends EntityProcessingSystem {
ComponentMapper<T> delayMapper;
public void processEntity(Entity e) {
if (delayMapper.get(e).delay < 0) {
processExpired(Entity e);
} else {
delayMapper.get(e).delay -= world.getDelta();
}
}
}
The current implementation of DelayedProcessingEntitySystem is confusing and flawed.
The idea of delayed processing of entities is valid, however it seems unnatural for all the entities to live on the same timer seems badly designed.
It seems like a better approach would be to store the delay in a component that is unique for every entity and have the delayed processing system process entities according to their individual delay timer.
Something along the lines of: