Despawning resource entities
What problem does this solve or what need does it fill?
Resources are now components on entities, but you're not allowed to simply despawn those entities.
What solution would you like?
You should be able to despawn resource entities like regular entities.
One benefit to this is that you get to re-use the mechanism for state-scoped entities for resources:
#[derive(Resource)]
#[require(DespawnOnExit(AppState::InGame))]
struct Score(u32);
What alternative(s) have you considered?
Specially treat resource entities by calling World::remove_resource.
Additional context
You can still have Stable Id's for Resource Entities, If we have Custom Allocators, which I would assume, could choose to not free the Index when despawning, and then when attempting to respawn, if its been spawned before then reuse the Index. Then you could have Relations/Systems that despawn Resource Entities.
Although perhaps the intention is more so, not-existing at any point is an error.
- @Diddykonga from this Discord discussion
Source: bevyengine/bevy