Factory(World world, BitVector additions, BitVector removals) { this.cm = world.getComponentManager(); this.additions = additions; this.removals = removals; this.bs = new BitVector(); }
/** * Returns a BitVector instance containing bits of the components the entity * possesses. * @return a BitVector containing the entities component bits */ protected BitVector getComponentBits() { return world.getComponentManager().componentBits(id); }
/** * @return unique identifier for entities with this specific component configuration. */ public int getCompositionId() { return world.getComponentManager().getIdentity(id); }
/** * Retrieves component from this entity. * <p> * Minimize usage of this. Use {@link ComponentMapper} instead. * </p> * @param type * in order to retrieve the component fast you must provide a * ComponentType instance for the expected component * @return component that matches, or {@code null} if none is found */ public Component getComponent(ComponentType type) { return world.getComponentManager().getComponent(id, type); }
/** * Returns a bag of all components this entity has. * <p> * You need to reset the bag yourself if you intend to fill it more than * once. * </p> * @param fillBag * the bag to put the components into * @return the fillBag containing the components */ public Bag<Component> getComponents(Bag<Component> fillBag) { return world.getComponentManager().getComponentsFor(id, fillBag); }
/** Prepare new builder. */ public EntityTransmuterFactory(World world) { this.world = world; types = world.getComponentManager().typeFactory; additions = new BitVector(); removals = new BitVector(); }
private EntitySubscription createSubscription(Aspect.Builder builder) { EntitySubscription entitySubscription = new EntitySubscription(world, builder); subscriptionMap.put(builder, entitySubscription); subscriptions.add(entitySubscription); world.getComponentManager().synchronize(entitySubscription); return entitySubscription; }
EntityTransmuter(World world, BitVector additions, BitVector removals) { em = world.getEntityManager(); entityToIdentity = world.getComponentManager().entityToIdentity; batchProcessor = world.batchProcessor; operations = new Bag<TransmuteOperation>(TransmuteOperation.class); factory = new Factory(world, additions, removals); }
@Override protected void initialize() { LinkCreateListener listener = new LinkCreateListener(this); world.getComponentManager().getTypeFactory().register(listener); }
@Override protected void initialize() { LinkCreateListener listener = new LinkCreateListener(this); world.getComponentManager().getTypeFactory().register(listener); }
EntityTransmuter(World world, BitVector additions, BitVector removals) { em = world.getEntityManager(); entityToIdentity = world.getComponentManager().entityToIdentity; batchProcessor = world.batchProcessor; operations = new Bag<TransmuteOperation>(TransmuteOperation.class); factory = new Factory(world, additions, removals); }
/** * Create an entity for the specified world. * @param world World this entity belongs to. */ public Entity(World world) { this.world = world; this.entityManager = world.getEntityManager(); this.componentManager = world.getComponentManager(); systemBits = new Bits(); componentBits = new Bits(); }
void inspectTypes(World world) { clear(); ComponentManager cm = world.getComponentManager(); for (ComponentType ct : cm.getComponentTypes()) { inspectType(ct.getType()); } }
private void toEntityIntBags(BitVector changed, BitVector deleted) { changed.toIntBagIdCid(world.getComponentManager(), this.changed); deleted.toIntBag(this.deleted); changed.clear(); deleted.clear(); }
/** Converts java classes to component types. */ private ComponentType[] resolveTypes(World world) { ComponentTypeFactory tf = world.getComponentManager().typeFactory; ComponentType[] types = new ComponentType[classes.size()]; for (int i = 0, s = classes.size(); s > i; i++) types[i] = tf.getTypeFor(classes.get(i)); return types; } }
protected void inspectComponentTypes(SaveFileFormat save) { ComponentManager cm = world.getComponentManager(); int[] ids = save.entities.getData(); for (int i = 0, s = save.entities.size(); s > i; i++) componentIds.or(cm.componentBits(ids[i])); } }
private void toEntityIntBags(BitVector changed, BitVector deleted) { changed.toIntBagIdCid(world.getComponentManager(), this.changed); deleted.toIntBag(this.deleted); changed.clear(); deleted.clear(); }
/** Converts java classes to component types. */ private ComponentType[] resolveTypes(World world) { ComponentTypeFactory tf = world.getComponentManager().typeFactory; ComponentType[] types = new ComponentType[classes.size()]; for (int i = 0, s = classes.size(); s > i; i++) types[i] = tf.getTypeFor(classes.get(i)); return types; } }
private void growEntityStores() { int newSize = 2 * entities.getCapacity(); entities.ensureCapacity(newSize); ComponentManager cm = world.getComponentManager(); cm.ensureCapacity(newSize); for (int i = 0, s = entityBitVectors.size(); s > i; i++) { entityBitVectors.get(i).ensureCapacity(newSize); } }
private void growEntityStores() { int newSize = 2 * entities.getCapacity(); entities.ensureCapacity(newSize); ComponentManager cm = world.getComponentManager(); cm.ensureCapacity(newSize); for (int i = 0, s = entityBitVectors.size(); s > i; i++) { entityBitVectors.get(i).ensureCapacity(newSize); } }