/** * Returns whether this Aspect would accept the given Entity. */ public boolean isInterested(Entity e){ return isInterested(e.getComponentBits()); }
/** * Returns whether this Aspect would accept the given Entity. */ public boolean isInterested(Entity e){ return isInterested(e.getComponentBits()); }
/** * Returns whether this Aspect would accept the given Entity. */ public boolean isInterested(Entity e){ return isInterested(e.getComponentBits()); }
/** * Clean up Components belonging to the Entity * @param e Entity to clear components for. */ public void removeComponentsOfEntity(Entity e) { Bits componentBits = e.getComponentBits(); for (int i = componentBits.nextSetBit(0); i >= 0; i = componentBits.nextSetBit(i+1)) { removeComponent(e.id, i); } componentBits.clear(); }
/** * Remove Component of specified class for a given Entity. * * @param e Entity to remove the component for. * @param type Component class to remove. */ public void removeComponent(Entity e, Class<? extends Component> type) { int classIndex = getComponentClassIndex(type); if(e.getComponentBits().get(classIndex)) { e.getComponentBits().clear(classIndex); if (!componentsToDelete.containsKey(e)) { componentsToDelete.put(e, Pools.obtain(IntArray.class)); } componentsToDelete.get(e).add(classIndex); } }
/** * Fills an array with Components belonging to the specified Entity. * * @param e Entity to get Components with. * @param array Array of Components to fill. */ public void getComponents(Entity e, Array<Component> array) { Bits componentBits = e.getComponentBits(); for (int i = componentBits.nextSetBit(0); i >= 0; i = componentBits.nextSetBit(i+1)) { array.add(componentsByType.get(i).get(e.id)); } }
/** * Adds a Component bellonging to the specified Entity to the manager. * * @param <T> Type of component * @param e Entity the component belongs to * @param component Component to add */ public <T extends Component> void addComponent(Entity e, T component) { int classIndex = getComponentClassIndex(component.getClass()); @SuppressWarnings("unchecked") Array<T> components = (Array<T>) componentsByType.get(classIndex); if(components == null) { components = new SafeArray<T>(); componentsByType.set(classIndex, components); } // clean up existing component belonging to the entity Component current = components.get(e.id); if (current != null && current != component) { Pools.free(current); } components.set(e.id, component); e.getComponentBits().set(classIndex); }
boolean interested = true; // possibly interested, let's try to prove it wrong. Bits componentBits = e.getComponentBits();