/** * Create and return a new or reused entity instance. * Will NOT add the entity to the world, use World.addEntity(Entity) * for that. * * @return created entity */ public Entity createEntity() { return em.createEntityInstance(); }
/** * Get a entity having the specified id. * * @param entityId id of the entity to retrieve. * @return entity Entity or null. */ public Entity getEntity(int entityId) { return em.getEntity(entityId); }
/** * Will check if the entity is enabled in the world. * By default all entities that are added to world are enabled, * this will only return false if an entity has been explicitly disabled. * * @return if it's enabled */ public boolean isEnabled() { return entityManager.isEnabled(id); }
public World() { this(new ComponentManager(), new EntityManager()); }
@Override public void dispose() { em.dispose(); cm.dispose(); added.clear(); changed.clear(); deleted.clear(); enable.clear(); disable.clear(); for (Manager manager : managers) { manager.dispose(); } managers.clear(); systems.clear(); if (eventSystem != null) { eventSystem.dispose(); eventSystem = null; } }
/** * Process all non-passive systems. */ public void process() { check(added, addedPerformer); check(changed, changedPerformer); check(disable, disablePerformer); check(enable, enablePerformer); check(deleted, deletedPerformer); cm.clean(); em.clean(); if (eventSystem != null) { eventSystem.update(); } for(int i = 0; i < systems.size; i++) { EntitySystem system = systems.get(i); if(!system.isPassive()) { system.process(); } } }