-
Notifications
You must be signed in to change notification settings - Fork 116
AspectSubscriptionManager
Adrian Papari edited this page Jul 19, 2015
·
11 revisions
AspectSubscriptionManager asm = world.getManager(AspectSubscriptionManager.class);
EntitySubscription subscription = asm.get(Aspect.all(ComponentY.class));
// don't hold onto the IntBag
IntBag entityIds = subscription.getEntities();
EntitySubscriptions can be instantiated at any time.
EntitySubscriptions synchronize the active entity id:s on demand; this synchronization check happens during #getEntities()
- make sure to call it when processing enters a new system or manager - as all entity state changes are applied in-between processing each system.
- Implement
EntitySubscription.SubscriptionListener
. - Fetch the subscription and add the listener:
AspectSubscriptionManager asm = world.getManager(AspectSubscriptionManager.class);
EntitySubscription subscription = asm.get(Aspect.all(ComponentY.class));
subscription.addSubscriptionListener(new EntitySubscription.SubscriptionListener() {
@Override
public void inserted(ImmutableBag<Entity> entities) {
// code
}
@Override
public void removed(ImmutableBag<Entity> entities) {
// code
}
});
- Overview
- Concepts
- Getting Started
- Using
- More guides
- Plugins
- Game Gallery
- Tools and Frameworks
- API reference