@Override public Entity getEntityById(int id) { synchronized (entities) { for (Entity entity : entities) if (id == entity.getId()) return entity; return null; } }
// remove an entity from the controller // returns true if an entity was removed // returns false if there is no entity with the given id public boolean removeEntity(long id) { for (Entity e : this.entity_list) { if (e.getId() == id) { this.removeEntity(e); } } return false; }
public Entity getEntityById(long id) { for (Entity e : this.entity_list) { if (e.getId() == id) return e; } return null; }
/** * Create and return an {@link Entity} wrapping a new or reused entity instance. Entity is * automatically added to the world. * * <p>Use {@link Entity#edit()} to set up your newly created entity. * * <p>You can also create entities using: - {@link com.artemis.utils.EntityBuilder} Convenient * entity creation. Not useful when pooling. - {@link com.artemis.Archetype} Fastest, low level, * no parameterized components. - {@link com.artemis.EntityFactory} Fast, clean and convenient. * For fixed composition entities. Requires some setup. Best choice for parameterizing pooled * components. * * @see #create(int) recommended alternative. * @return entity */ public Entity createEntity(Archetype archetype) { Entity e = em.createEntityInstance(archetype); cm.addComponents(e.getId(), archetype); changed.set(e.getId()); return e; }