What is the proper way of checking if the entity is already removed?
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 930
- Forks
- 147
- PR merge metrics
- No merged PRs in 30d
Description
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
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading EntityListener and the engine.removeEntity call, then trace the Mapper.transform.get(police.criminal) access shown in the example. Determine the supported entity lifecycle and safe handling for components that retain removed entities; done means the behavior and recommended approach are documented or covered by a focused regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100