add entity filter method to find all entities created with a given preset

This commit is contained in:
Gered 2013-10-27 11:33:08 -04:00
parent 4f3b8ff2b7
commit cf49f66e85

View file

@ -151,6 +151,17 @@ public class EntityManager implements Disposable {
return componentEntities.keys(); return componentEntities.keys();
} }
public <T extends EntityPreset> void getAllCreatedWithPreset(Class<T> presetType, Array<Entity> outMatchingEntities) {
if (outMatchingEntities == null)
throw new IllegalArgumentException("Must supply an Array object to store the matching entities in.");
for (Entity i : getAllWith(EntityPresetComponent.class)) {
EntityPresetComponent entityPreset = i.get(EntityPresetComponent.class);
if (presetType.isAssignableFrom(entityPreset.presetType))
outMatchingEntities.add(i);
}
}
public void remove(Entity entity) { public void remove(Entity entity) {
if (entity == null) if (entity == null)
throw new IllegalArgumentException("entity can not be null."); throw new IllegalArgumentException("entity can not be null.");