Comments (3)
You can always subscribe your EntitySystem
to entity events with the Engine
by implementing the EntityListener
interface. However, the handler will be called every time any entity enters or leaves the engine.
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 EntitySystem
class doesn't have an associated family. We could, maybe, add listeners to the engine on a per family basis.
from ashley.
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);
}
}
from ashley.
Added in f90d129
from ashley.
Related Issues (20)
- GWT build fails HOT 4
- Kotlin coroutine support HOT 2
- Make removed flag of entity accesable HOT 4
- Iterating system updates entities after they have been removed engine HOT 2
- Ashley should not let you add multiple of the same component to an entity HOT 4
- How to avoid unimplemented poolable component? HOT 1
- Unable to access hasComponent method on Entity HOT 2
- how is the compent managed in memory? HOT 1
- Is this project still alive? Thank you. HOT 7
- Different systems with the same family filter receive different entities. HOT 6
- en
- ImGui wiki page not linked in Home HOT 1
- Html is not supported HOT 1
- [Question] Variable assignments at system update method HOT 1
- PooledEntity instances are not reset() if their pool is full
- Removing an entity before it was added leads to unexpected behaviour. HOT 3
- "Getting Started" guide uses deprecated Gradle syntax HOT 1
- Add system with lower priority during iteration HOT 1
- Add/Remove system improvement HOT 2
- Add a module-info.java
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ashley.