/** * Create iterator for IntBag * * @return true if the iteration has more elements */ public IntBagIterator(final IntBag intBag) { this.intBag = intBag; index = -1; indexEnd = intBag != null ? intBag.size() : 0; assert indexEnd >= 0; state = State.INIT; }
/** * Returns true if the iteration has more elements. (In other words, returns true if next() would return an element rather than throwing an exception.) * * @return true if the iteration has more elements */ public boolean hasNext() { return index + 1 < indexEnd && indexEnd <= intBag.size(); }
public static BitSet toBitSet(IntBag bag, BitSet out) { int[] data = bag.getData(); for (int i = 0, s = bag.size(); s > i; i++) { out.set(data[i]); } return out; } }
/** * Removes all components from deleted entities. * * @param pendingPurge * the entities to remove components from */ void clean(IntBag pendingPurge) { int[] ids = pendingPurge.getData(); for (int i = 0, s = pendingPurge.size(); s > i; i++) { removeComponents(ids[i]); } }
@Override public void inserted(IntBag entities) { int[] ids = entities.getData(); for (int i = 0, s = entities.size(); s > i; i++) { insert(ids[i]); } }
public static BitVector toBitVector(IntBag bag, BitVector out) { int[] data = bag.getData(); for (int i = 0, s = bag.size(); s > i; i++) { out.set(data[i]); } return out; }
private boolean updateReferenced(IntBag ids, BitVector referencedIds) { boolean updated = false; for (int i = 0; i < ids.size(); i++) updated |= updateReferenced(ids.get(i), referencedIds); return updated; }
@Override public void inserted(IntBag entities) { int[] ids = entities.getData(); for (int i = 0, s = entities.size(); s > i; i++) { inserted(ids[i]); } }
/** * Removes all components from deleted entities. * * @param pendingPurge * the entities to remove components from */ void clean(IntBag pendingPurge) { int[] ids = pendingPurge.getData(); for (int i = 0, s = pendingPurge.size(); s > i; i++) { removeComponents(ids[i]); } }
void deleted(IntBag entities) { int[] ids = entities.getData(); for (int i = 0, s = entities.size(); s > i; i++) { int id = ids[i]; if (registered.get(id)) { String removedTag = tagsByEntity.remove(world.getEntity(id)); entitiesByTag.remove(removedTag); registered.clear(id); } } }
void deleted(IntBag entities) { int[] ids = entities.getData(); for (int i = 0, s = entities.size(); s > i; i++) { removeFromAllGroups(world.getEntity(ids[i])); } } }
private void deleted(IntBag entities) { int[] ids = entities.getData(); for (int i = 0, s = entities.size(); s > i; i++) { int id = ids[i]; if (activeEntityIds.unsafeGet(id)) remove(id); } }
/** @inheritDoc */ @Override protected final void processSystem() { IntBag actives = subscription.getEntities(); int[] ids = actives.getData(); for (int i = 0, s = actives.size(); s > i; i++) { process(ids[i]); } } }
private void deleted(IntBag entities) { // performance hack, skip if manager lacks implementation of removed. if ((methodFlags & FLAG_REMOVED) == 0) return; int[] ids = entities.getData(); for (int i = 0, s = entities.size(); s > i; i++) { deleted(world.getEntity(ids[i])); } }
private void deletedAll(IntBag entities) { int[] ids = entities.getData(); for (int i = 0, s = entities.size(); s > i; i++) { int id = ids[i]; activeEntityIds.unsafeClear(id); removedIds.unsafeSet(id); } }
private void added(IntBag entities) { // performance hack, skip if manager lacks implementation of inserted. if ((methodFlags & FLAG_INSERTED) == 0) return; int[] ids = entities.getData(); for (int i = 0, s = entities.size(); s > i; i++) { added(world.getEntity(ids[i])); } }
void configureWith(int count) { poolIndex = 0; pool.setSize(0); pool.ensureCapacity(count); for (int i = 0; i < count; i++) { pool.add(world.create(archetype)); } Arrays.sort(pool.getData(), 0, pool.size()); }
void translate(Component c, Field field, Bag<Entity> translatedIds) { try { IntBag bag = (IntBag) field.get(c); for (int i = 0, s = bag.size(); s > i; i++) { int oldId = bag.get(i); bag.set(i, translatedIds.get(oldId).getId()); } } catch (ReflectionException e) { throw new RuntimeException(e); } } },
@Override public void validate(int sourceId, IntBag ids, LinkListener listener) { for (int i = 0; ids.size() > i; i++) { int id = ids.get(i); if (!all.getActiveEntityIds().unsafeGet(id)) { ids.remove(i--); if (listener != null) listener.onTargetDead(sourceId, id); } } }