/** * Fetch composition id for entity. * * A composition id is uniquely identified by a single Aspect. For performance reasons, each entity is * identified by its composition id. Adding or removing components from an entity will change its compositionId. * * @param entityId * @return composition identity. */ public int getIdentity(int entityId) { return entityToIdentity.get(entityId); }
/** * Set composition id of entity. * * @param entityId entity id * @param compositionId composition id */ void setIdentity(int entityId, int compositionId) { entityToIdentity.unsafeSet(entityId, (short) compositionId); }
/** * Removes the first occurrence of the value from this IntBag, if * it is present. * * @param value * the value to be removed * * @return true, if value was removed */ public boolean removeValue(short value) throws ArrayIndexOutOfBoundsException { int index = indexOf(value); if (index > -1) remove(index); return index > -1; }
/** * Creates a new instance of {@link ComponentManager}. */ protected ComponentManager(int entityContainerSize) { entityToIdentity = new ShortBag(entityContainerSize); typeFactory = new ComponentTypeFactory(this, entityContainerSize); }
public void ensureCapacity(int newSize) { typeFactory.initialMapperCapacity = newSize; entityToIdentity.ensureCapacity(newSize); for (ComponentMapper mapper : mappers) { mapper.components.ensureCapacity(newSize); } }
/** * Increase the capacity of the bag. * <p> * Capacity will increase by (3/2)*capacity + 1. * </p> */ private void grow() { int newCapacity = (data.length * 7) / 4 + 1; grow(newCapacity); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ShortBag intBag = (ShortBag) o; return size == intBag.size() && Arrays.equals(data, intBag.data); }
/** * Creates a new instance of {@link ComponentManager}. */ protected ComponentManager(int entityContainerSize) { entityToIdentity = new ShortBag(entityContainerSize); typeFactory = new ComponentTypeFactory(this, entityContainerSize); }
public void ensureCapacity(int newSize) { typeFactory.initialMapperCapacity = newSize; entityToIdentity.ensureCapacity(newSize); for (ComponentMapper mapper : mappers) { mapper.components.ensureCapacity(newSize); } }
/** * Increase the capacity of the bag. * <p> * Capacity will increase by (3/2)*capacity + 1. * </p> */ private void grow() { int newCapacity = (data.length * 7) / 4 + 1; grow(newCapacity); }
/** * Removes the first occurrence of the value from this IntBag, if * it is present. * * @param value * the value to be removed * * @return true, if value was removed */ public boolean removeValue(short value) throws ArrayIndexOutOfBoundsException { int index = indexOf(value); if (index > -1) remove(index); return index > -1; }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ShortBag intBag = (ShortBag) o; return size == intBag.size() && Arrays.equals(data, intBag.data); }
/** * Fetch composition id for entity. * * A composition id is uniquely identified by a single Aspect. For performance reasons, each entity is * identified by its composition id. Adding or removing components from an entity will change its compositionId. * * @param entityId * @return composition identity. */ public int getIdentity(int entityId) { return entityToIdentity.get(entityId); }
/** * Set composition id of entity. * * @param entityId entity id * @param compositionId composition id */ void setIdentity(int entityId, int compositionId) { entityToIdentity.unsafeSet(entityId, (short) compositionId); }
/** * Creates a new instance of {@link ComponentManager}. */ protected ComponentManager(int entityContainerSize) { entityToIdentity = new ShortBag(entityContainerSize); typeFactory = new ComponentTypeFactory(this, entityContainerSize); }
public void ensureCapacity(int newSize) { typeFactory.initialMapperCapacity = newSize; entityToIdentity.ensureCapacity(newSize); for (ComponentMapper mapper : mappers) { mapper.components.ensureCapacity(newSize); } }
/** * Check if an item, if added at the given item will fit into the bag. * <p> * If not, the bag capacity will be increased to hold an item at the index. * </p> * * @param index * index to check */ public void ensureCapacity(int index) { if(index >= data.length) { grow(index + 1); } }
/** * Fetch composition id for entity. * * A composition id is uniquely identified by a single Aspect. For performance reasons, each entity is * identified by its composition id. Adding or removing components from an entity will change its compositionId. * * @param entityId * @return composition identity. */ public int getIdentity(int entityId) { return entityToIdentity.get(entityId); }