/** * Gets the <code>composition id</code> uniquely identifying the * component composition of an entity. Each composition identity maps * to one unique <code>BitVector</code>. * * @param entityId Entity for which to get the composition id * @return composition identity of entity */ public int compositionId(int entityId) { return cm.getIdentity(entityId); }
/** * Gets the <code>composition id</code> uniquely identifying the * component composition of an entity. Each composition identity maps * to one unique <code>BitVector</code>. * * @param entityId Entity for which to get the composition id * @return composition identity of entity */ public int compositionId(int entityId) { return cm.getIdentity(entityId); }
/** * @return unique identifier for entities with this specific component configuration. */ public int getCompositionId() { return world.getComponentManager().getIdentity(id); }
/** * @return unique identifier for entities with this specific component configuration. */ public int getCompositionId() { return world.getComponentManager().getIdentity(id); }
/** * 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) { 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; }
/** * Synchronizes new subscriptions with {@link World} state. * * @param es entity subscription to update. */ void synchronize(EntitySubscription es) { Bag<BitVector> compositionBits = identityResolver.compositionBits; for (int i = 1, s = compositionBits.size(); s > i; i++) { BitVector componentBits = compositionBits.get(i); es.processComponentIdentity(i, componentBits); } for (Entity e : world.getEntityManager().entities) { if (e != null) es.check(e.id, getIdentity(e.id)); } es.informEntityChanges(); es.rebuildCompressedActives(); }
/** * Synchronizes new subscriptions with {@link World} state. * * @param es entity subscription to update. */ void synchronize(EntitySubscription es) { Bag<BitVector> compositionBits = identityResolver.compositionBits; for (int i = 1, s = compositionBits.size(); s > i; i++) { BitVector componentBits = compositionBits.get(i); es.processComponentIdentity(i, componentBits); } for (Entity e : world.getEntityManager().entities) { if (e != null) es.check(e.id, getIdentity(e.id)); } es.informEntityChanges(); es.rebuildCompressedActives(); }
/** * Synchronizes new subscriptions with {@link World} state. * * @param es entity subscription to update. */ void synchronize(EntitySubscription es) { Bag<BitVector> compositionBits = identityResolver.compositionBits; for (int i = 1, s = compositionBits.size(); s > i; i++) { BitVector componentBits = compositionBits.get(i); es.processComponentIdentity(i, componentBits); } for (Entity e : world.getEntityManager().entities) { if (e != null) es.check(e.id, getIdentity(e.id)); } es.informEntityChanges(); es.rebuildCompressedActives(); }