/** * Returns whether this Aspect would accept the given set. */ public boolean isInterested(BitVector componentBits){ // Check if the entity possesses ALL of the components defined in the aspect. if(!allSet.isEmpty() && !componentBits.containsAll(allSet)) return false; // If we are STILL interested, // Check if the entity possesses ANY of the exclusion components, // if it does then the system is not interested. if (!exclusionSet.isEmpty() && exclusionSet.intersects(componentBits)) return false; // If we are STILL interested, // Check if the entity possesses ANY of the components in the oneSet. // If so, the system is interested. if (!oneSet.isEmpty() && !oneSet.intersects(componentBits)) return false; return true; }
/** * Returns whether this Aspect would accept the given set. */ public boolean isInterested(BitVector componentBits){ // Check if the entity possesses ALL of the components defined in the aspect. if(!allSet.isEmpty() && !componentBits.containsAll(allSet)) return false; // If we are STILL interested, // Check if the entity possesses ANY of the exclusion components, // if it does then the system is not interested. if (!exclusionSet.isEmpty() && exclusionSet.intersects(componentBits)) return false; // If we are STILL interested, // Check if the entity possesses ANY of the components in the oneSet. // If so, the system is interested. if (!oneSet.isEmpty() && !oneSet.intersects(componentBits)) return false; return true; }
@Override void mark(int entityId) { if (idBits.isEmpty()) // see cm#clean batchProcessor.purgatories.add(this); idBits.set(entityId); }
/** * Returns a reference to the bag holding all matched entities. * * <p><b>Warning: </b> Never remove elements from the bag, as this * will lead to undefined behavior.</p> * * @return View of all active entities. */ public IntBag getEntities() { if (entities.isEmpty() && !activeEntityIds.isEmpty()) rebuildCompressedActives(); return entities; }
@Override void mark(int entityId) { if (idBits.isEmpty()) // see cm#clean batchProcessor.purgatories.add(this); idBits.set(entityId); }
/** * Returns a reference to the bag holding all matched entities. * * <p><b>Warning: </b> Never remove elements from the bag, as this * will lead to undefined behavior.</p> * * @return View of all active entities. */ public IntBag getEntities() { if (entities.isEmpty() && !activeEntityIds.isEmpty()) rebuildCompressedActives(); return entities; }
/** * Returns whether this Aspect would accept the given set. */ public boolean isInterested(BitVector componentBits){ // Check if the entity possesses ALL of the components defined in the aspect. if(!allSet.isEmpty()) { for (int i = allSet.nextSetBit(0); i >= 0; i = allSet.nextSetBit(i+1)) { if(!componentBits.get(i)) { return false; } } } // If we are STILL interested, // Check if the entity possesses ANY of the exclusion components, // if it does then the system is not interested. if (!exclusionSet.isEmpty() && exclusionSet.intersects(componentBits)) return false; // If we are STILL interested, // Check if the entity possesses ANY of the components in the oneSet. // If so, the system is interested. if (!oneSet.isEmpty() && !oneSet.intersects(componentBits)) return false; return true; }
/** * Decodes the set bits as integers. The destination * {@link IntBag} is reset before the bits are transposed. * * @param out decoded ints end up here * @return Same as out */ public IntBag toIntBag(IntBag out) { if (isEmpty()) { out.setSize(0); return out; } int count = prepareBag(out, 1); int[] data = out.getData(); for (int i = 0, index = 0; count > index; i++) { long bitset = words[i]; int wordBits = i << 6; while (bitset != 0) { long t = bitset & -bitset; data[index] = wordBits + Long.bitCount(t - 1); bitset ^= t; index++; } } return out; }
/** * Decodes the set bits as integers. The destination * {@link IntBag} is reset before the bits are transposed. * * @param out decoded ints end up here * @return Same as out */ public IntBag toIntBag(IntBag out) { if (isEmpty()) { out.setSize(0); return out; } int count = prepareBag(out, 1); int[] data = out.getData(); for (int i = 0, index = 0; count > index; i++) { long bitset = words[i]; int wordBits = i << 6; while (bitset != 0) { long t = bitset & -bitset; data[index] = wordBits + Long.bitCount(t - 1); bitset ^= t; index++; } } return out; }
/** * Decodes the set bits as pairs of <code>entity id</code> and * {@link World#compositionId(int) compositionId}. The * destination{@link IntBag} is reset before the bits are * transposed. * * @param out decoded ints end up here * @return Same as out */ public IntBag toIntBagIdCid(ComponentManager cm, IntBag out) { if (isEmpty()) { out.setSize(0); return out; } int count = prepareBag(out, 2); int[] data = out.getData(); for (int i = 0, index = 0; count > index; i++) { long bitset = words[i]; int wordBits = i << 6; while (bitset != 0) { long t = bitset & -bitset; int id = wordBits + Long.bitCount(t - 1); data[index] = id; data[index + 1] = cm.getIdentity(id); index += 2; bitset ^= t; } } return out; }
/** * Decodes the set bits as integers. The destination * {@link IntBag} is reset before the bits are transposed. * * @param out decoded ints end up here * @return Same as out */ public IntBag toIntBag(IntBag out) { out.setSize(0); if (isEmpty()) return out; for (int id = nextSetBit(0); id >= 0; id = nextSetBit(id + 1)) { out.add(id); } return out; }
/** * Decodes the set bits as pairs of <code>entity id</code> and * {@link World#compositionId(int) compositionId}. The * destination{@link IntBag} is reset before the bits are * transposed. * * @param out decoded ints end up here * @return Same as out */ public IntBag toIntBagIdCid(ComponentManager cm, IntBag out) { if (isEmpty()) { out.setSize(0); return out; } int count = prepareBag(out, 2); int[] data = out.getData(); for (int i = 0, index = 0; count > index; i++) { long bitset = words[i]; int wordBits = i << 6; while (bitset != 0) { long t = bitset & -bitset; int id = wordBits + Long.bitCount(t - 1); data[index] = id; data[index + 1] = cm.getIdentity(id); index += 2; bitset ^= t; } } return out; }
/** * Decodes the set bits as pairs of <code>entity id</code> and * {@link World#compositionId(int) compositionId}. The * destination{@link IntBag} is reset before the bits are * transposed. * * @param out decoded ints end up here * @return Same as out */ public IntBag toIntBagIdCid(ComponentManager cm, IntBag out) { out.setSize(0); if (isEmpty()) return out; for (int id = nextSetBit(0); id >= 0; id = nextSetBit(id + 1)) { out.add(id); out.add(cm.getIdentity(id)); } return out; }