From cf49f66e8518447925f8f0247e1554a23eb72d5b Mon Sep 17 00:00:00 2001 From: gered Date: Sun, 27 Oct 2013 11:33:08 -0400 Subject: [PATCH] add entity filter method to find all entities created with a given preset --- src/com/blarg/gdx/entities/EntityManager.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/com/blarg/gdx/entities/EntityManager.java b/src/com/blarg/gdx/entities/EntityManager.java index 03d20c1..8b72069 100644 --- a/src/com/blarg/gdx/entities/EntityManager.java +++ b/src/com/blarg/gdx/entities/EntityManager.java @@ -151,6 +151,17 @@ public class EntityManager implements Disposable { return componentEntities.keys(); } + public void getAllCreatedWithPreset(Class presetType, Array 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) { if (entity == null) throw new IllegalArgumentException("entity can not be null.");