EntityListener handles when the entity is added or removed. My problem is when I remove the entity from the engine, while this entity is being used as Component owner, it cause a java.lang.NullPointerException. I wonder what method to use to check if entity is already removed from the engine.
For example:
public class PoliceComponent implements Component {
public Entity criminal;
}
engine.removeEntity(entity)
PoliceComponent police ...
Vector2 criminalPos = Mapper.transform.get(police.criminal).position;
// Now this line will cause an error
Question : is there a method like this to check for entity existence? or something better safer to remove entity while is in use.
if (engine.hasEntity(entity)) {
// exists
}