Proposal: Despawn entities with the `Component` macro.
Open
A-ECS
C-Usability
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## What problem does this solve or what need does it fill?
Defining hooks can be simplified by a macro in some cases.
## What solution would you like?
Add a `#[component(despawn)]` field attribute, this field is either `Entity` or `&T: for<'t> impl IntoIterator` (including `Option`, `Vec`, etc). When the `on_remove` hook is triggered, despawn these entities.
## What alternative(s) have you considered?
Implement this manually.
## Additional context
Currently we have to pull in `bevy_hierarchy` to implement this in the macro, using `DespawnRecursive`. If we use hooks in 0.15 to maintain hierarchy this implementation can be simpler and work with `bevy_ecs` only.
Contributor guide
Assessment
This issue has not been assessed yet.