/** * Get the index of the component type of given component class. * * @param c * the component class to get the type index for * * @return the component type's index */ public int getIndexFor(Class<? extends Component> c) { return getTypeFor(c).getIndex(); }
/** * Get all components from all entities for a given type. * * @param type * the type of components to get * @return a bag containing all components of the given type */ protected Bag<Component> getComponentsByType(ComponentType type) { return mappers.get(type.getIndex()).components; }
/** * Get all components from all entities for a given type. * * @param type * the type of components to get * @return a bag containing all components of the given type */ protected Bag<Component> getComponentsByType(ComponentType type) { return mappers.get(type.getIndex()).components; }
/** * Get the index of the component type of given component class. * * @param c * the component class to get the type index for * * @return the component type's index */ public int getIndexFor(Class<? extends Component> c) { return getTypeFor(c).getIndex(); }
/** * Get all components from all entities for a given type. * * @param type * the type of components to get * @return a bag containing all components of the given type */ protected Bag<Component> getComponentsByType(ComponentType type) { return mappers.get(type.getIndex()).components; }
/** generate bitset mask of types. */ private static BitVector bitset(ComponentType[] types) { BitVector bs = new BitVector(); for (int i = 0; types.length > i; i++) bs.set(types[i].getIndex()); return bs; }
/** generate bitset mask of types. */ private static BitVector bitset(ComponentType[] types) { BitVector bs = new BitVector(); for (int i = 0; types.length > i; i++) bs.set(types[i].getIndex()); return bs; }
/** * Get a component of an entity. * * @param entityId * the entity associated with the component * @param type * the type of component to get * @return the component of given type */ protected Component getComponent(int entityId, ComponentType type) { ComponentMapper mapper = mappers.get(type.getIndex()); return mapper.get(entityId); }
/** * Get a component of an entity. * * @param entityId * the entity associated with the component * @param type * the type of component to get * @return the component of given type */ protected Component getComponent(int entityId, ComponentType type) { ComponentMapper mapper = mappers.get(type.getIndex()); return mapper.get(entityId); }
protected <T extends Component> ComponentMapper<T> getMapper(Class<T> mapper) { ComponentType type = typeFactory.getTypeFor(mapper); return mappers.get(type.getIndex()); }
protected <T extends Component> ComponentMapper<T> getMapper(Class<T> mapper) { ComponentType type = typeFactory.getTypeFor(mapper); return mappers.get(type.getIndex()); }
protected <T extends Component> ComponentMapper<T> getMapper(Class<T> mapper) { ComponentType type = typeFactory.getTypeFor(mapper); return mappers.get(type.getIndex()); }
/** * Get a component of an entity. * * @param entityId * the entity associated with the component * @param type * the type of component to get * @return the component of given type */ protected Component getComponent(int entityId, ComponentType type) { ComponentMapper mapper = mappers.get(type.getIndex()); return mapper.get(entityId); }
void registerComponentType(ComponentType ct, int capacity) { int index = ct.getIndex(); ComponentMapper mapper = new ComponentMapper(ct.getType(), world); mapper.components.ensureCapacity(capacity); mappers.set(index, mapper); }
void registerComponentType(ComponentType ct, int capacity) { int index = ct.getIndex(); ComponentMapper mapper = new ComponentMapper(ct.getType(), world); mapper.components.ensureCapacity(capacity); mappers.set(index, mapper); }
/** Fetch mapper, or create if missing. */ @SuppressWarnings("unchecked") private <T extends Component> M<T> getCreateMapper(ComponentType type) { final int index = type.getIndex(); mappers.ensureCapacity(index); M m = mappers.get(index); if (m == null) { m = setMapper(index, type.getType()); } return m; }
void registerComponentType(ComponentType ct, int capacity) { int index = ct.getIndex(); ComponentMapper mapper = new ComponentMapper(ct.getType(), world); mapper.components.ensureCapacity(capacity); mappers.set(index, mapper); }
/** Fetch mapper, or create if missing. */ @SuppressWarnings("unchecked") private <T extends Component> M<T> getCreateMapper(ComponentType type) { final int index = type.getIndex(); mappers.ensureCapacity(index); M m = mappers.get(index); if (m == null) { m = setMapper(index, type.getType()); } return m; }