artemis-odb icon indicating copy to clipboard operation
artemis-odb copied to clipboard

[SubscriptionListener] Entity#deleteFromWorld() and #remove

Open DaanVanYperen opened this issue 5 years ago • 1 comments

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, any SubscriptionListener#remove cannot access the component (as expected).
  • After Entity#deleteFromWorld, every SubscriptionListener#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.

DaanVanYperen avatar Jan 05 '19 12:01 DaanVanYperen

  • After Entity#deleteFromWorld, every SubscriptionListener#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.

junkdog avatar Jan 08 '19 00:01 junkdog