-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
What problem does this solve or what need does it fill?
When removing components (or despawning entities with those components), we often want to perform cleanup. Unfortunately, this work typically requires data from that removed component, rather than just the entity that was returned. See our example for the current behavior.
What solution would you like?
Store the Removed data in a special "purgatory" sparse set that we keep around until the frame-after-next, using the same double-buffer strategy as Events.
What alternative(s) have you considered?
Write custom commands to remove components that require cleanup, like despawn_recursive. This is hard to extend though and forces the user to not clean stuff up.
Always emit a "to despawn" event, and then clean things up before the data is lost by making sure that the cleanup systems run first.
Users manually archive and then access the components that they need to access once removed.
Additional context
Relevant to how we despawn entities in a parent-child hierarchy, e.g. despawn_recursive.
We will need to do the same thing with Resources as well.