@Override public void setWorld(World world) { all = world.getAspectSubscriptionManager().get(all()); } }
private A createNew() { return (A) ((pool != null) ? pool.obtain() : ComponentManager.newInstance(type.getType())); }
public WeaverLog execute() { WeaverLog log = new WeaverLog(); List<File> classes = ClassUtil.find(targetClasses); rewriteComponents(classes, log); generateLinkMutators(classes, log); rewriteProfilers(classes); if (ClassMetadata.GlobalConfiguration.optimizeEntitySystems) rewriteEntitySystems(classes, log); sort(log); return log; }
/** * Get all entities with component. * This is a relatively costly operation. For performance use withAspect instead. * @return {@code EBag} of entities matching aspect. Returns empty bag if no entities match aspect. */ public static EBag withComponent(Class<? extends Component> component) { if(_processingMapper==null) throw new RuntimeException("SuperMapper system must be registered before any systems using E().");; return new EBag(_processingMapper.getWorld().getAspectSubscriptionManager().get(Aspect.all(component)).getEntities()); }
@Override protected void initialize() { world.getAspectSubscriptionManager().get(all()) .addSubscriptionListener(new EntitySubscription.SubscriptionListener() { @Override public void inserted(IntBag entities) { } @Override public void removed(IntBag entities) { deleted(entities); } }); }
/** Begin building new entity.*/ public EntityBuilder(World world) { this.world = world; edit = world.createEntity().edit(); }
/** * Create a component of given type by class. * @param owner entity id * @param componentClass class of component to instance. * @return Newly created packed, pooled or basic component. */ protected <T extends Component> T create(int owner, Class<T> componentClass) { return getMapper(componentClass).create(owner); }
/** * Create or remove a component from an entity. * * Does nothing if already removed or created respectively. * * @param entity Entity to change. * @param value {@code true} to create component (if missing), {@code false} to remove (if exists). * @return the instance of the component, or {@code null} if removed. */ public A set(Entity entity, boolean value) { return set(entity.getId(), value); }
/** * Fast and safe retrieval of a component for this entity. * If the entity does not have this component then fallback is returned. * * @param entity Entity that should possess the component * @param fallback fallback component to return, or {@code null} to return null. * @return the instance of the component */ public A getSafe(Entity entity, A fallback) { return getSafe(entity.getId(), fallback); }
/** * Removal of components from a entity. * <p/> * Faster than {@link #remove(Class)}. * * @param type the type of component to remove from this entity * @return this EntityEdit for chaining */ public EntityEdit remove(ComponentType type) { cm.getMapper(type.getType()).remove(entityId); return this; }
/** * @return entity subscription backing this system. */ public EntitySubscription getSubscription() { final AspectSubscriptionManager sm = world.getAspectSubscriptionManager(); return sm.get(aspectConfiguration); }
/** * Returns whether this Aspect would accept the given Entity. */ public boolean isInterested(Entity e){ return isInterested(e.getComponentBits()); }
@Override public void setWorld(World world) { all = world.getAspectSubscriptionManager().get(all()); } }
/** * Get all entities matching aspect. * For performance reasons do not create the aspect every call. * @return {@code EBag} of entities matching aspect. Returns empty bag if no entities match aspect. */ public static EBag withAspect(Aspect.Builder aspect) { if(_processingMapper==null) throw new RuntimeException("SuperMapper system must be registered before any systems using E().");; return new EBag(_processingMapper.getWorld().getAspectSubscriptionManager().get(aspect).getEntities()); }
@Override protected void initialize() { world.getAspectSubscriptionManager() .get(all()) .addSubscriptionListener(new EntitySubscription.SubscriptionListener() { @Override public void inserted(IntBag entities) {} @Override public void removed(IntBag entities) { deleted(entities); } }); }
/** * Removal of components from a entity. * <p/> * Faster than {@link #remove(Class)}. * * @param type the type of component to remove from this entity * @return this EntityEdit for chaining */ public EntityEdit remove(ComponentType type) { cm.getMapper(type.getType()).remove(entityId); return this; }
@Override public void setWorld(World world) { all = world.getAspectSubscriptionManager().get(all()); } }
@Override public void setWorld(World world) { all = world.getAspectSubscriptionManager().get(all()); } }
@Override public void setWorld(World world) { all = world.getAspectSubscriptionManager().get(all()); }