artemis-odb
artemis-odb copied to clipboard
[SubscriptionListener] Entity#deleteFromWorld() and #remove
While implementing #508 i'm running into an inconsistency.
Observed
Given an non-delayed-removal component When an entity goes out of scope for a system:
- After
ComponentMapper#remove
, anySubscriptionListener#remove
cannot access the component (as expected). - After
Entity#deleteFromWorld
, everySubscriptionListener#remove
listener can still access the component.
Expected
@DelayedComponentRemoval
dictates behaviour.
Notes
Going for the expected is probably undesirable as it'll turn existing user games into NPE land. Perhaps for 3.0.0 we should go the other way and make alwaysDelayComponentRemoval(true)
the default? Ideally we'd re-benchmark and if insignificant hardcode it like that.
- After
Entity#deleteFromWorld
, everySubscriptionListener#remove
listener can still access the component.
Yeah, I think this is even documented in a javadoc snippet somewhere. I agree it's not good.
Moving to only updating entity/component composition to once per process tick - as mentioned in https://github.com/junkdog/artemis-odb/issues/531#issuecomment-452101931 - would make alwaysDelayComponentRemoval(true)
the default - and only behavior.