-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inform system when entity is added or removed #54
Comments
You can always subscribe your You can always check whether the added/deleted entity is of interest by doing: ImmutableArray<Entity> entities = engine.getEntitiesFor(Family.getFor(...));
entities.contains(entity); Would that be enough? The |
Hi, that wouldnt be enough. Another problem is that when the listener gets informed, i dont have access to the component anymore (when i have understood the ashley code right). For example i am doing something like this very often: BehaviourSystem ..... @Override
protected void removed(Entity e) {
super.removed(e);
Behaviour b = e.getComponent(BehaviourComponent.class).getBehaviour();
Task task = b.getCurrentTask();
if(task != null){
task.removeApplicant(e);
}
} or i a SteeringForceSystem: @Override
protected void removed(Entity e) {
super.removed(e);
if (spatialMapper.has(e)) {
Spatial spatial = spatialMapper.get(e);
spatial.vel.x = 0;
spatial.vel.y = 0;
}
if (steeringForceMapper.has(e)) {
SteeringForce sf = steeringForceMapper.get(e);
sf.steeringForce.set(0, 0);
}
} |
Added in f90d129 |
Hi, is it possible to inform a system when an entity ist removed or added to the system?
Im currently using artemis and i have systems which are building there own index of entites, for example to receive all entities in an spatial area. Those systems needs to update their index when an entity is added or removed.
Thx,
Christian
The text was updated successfully, but these errors were encountered: