Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bevy's bundle types should implement Clone where possible #12985

Closed
alice-i-cecile opened this issue Apr 15, 2024 · 0 comments · Fixed by #12993
Closed

Bevy's bundle types should implement Clone where possible #12985

alice-i-cecile opened this issue Apr 15, 2024 · 0 comments · Fixed by #12993
Labels
A-Cross-Cutting Impacts the entire engine A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use

Comments

@alice-i-cecile
Copy link
Member

What problem does this solve or what need does it fill?

When working with a collection of prefab entities (aka a zoo or manifest), it can be very useful to store a canonical bundle for each kind of object, and then clone it to initialize a new entity of that kind.

Unfortunately, not all of Bevy's bundle types implement Clone. I ran into this with TextBundle, but I'm sure there's more.

What solution would you like?

Derive Clone on all of Bevy's bundle types where possible. Add trivial Clone impls to all contained components.

What alternative(s) have you considered?

This can be worked around by implementing a custom bundle type which either mirrors or embeds Bevy's bundle types, and implementing Clone on that.

Additional context

#1515 covers a feature request to clone arbitrary entities, once they exist. This feature request is distinct but related: rather than cloning entities dynamically, we simply want to clone the set of data used to generate them.

@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use A-Cross-Cutting Impacts the entire engine labels Apr 15, 2024
github-merge-queue bot pushed a commit that referenced this issue Apr 16, 2024
# Objective

Closes #12985.

## Solution

- Derive clone for most types with bundle in their name.
- Bundle types missing clone:
-
[`TextBundle`](https://docs.rs/bevy/latest/bevy/prelude/struct.TextBundle.html)
(Contains
[`ContentSize`](https://docs.rs/bevy/latest/bevy/ui/struct.ContentSize.html)
which can't be cloned because it itself contains a `Option<MeasureFunc>`
where
[`MeasureFunc`](https://docs.rs/taffy/0.3.18/taffy/node/enum.MeasureFunc.html)
isn't clone)
-
[`ImageBundle`](https://docs.rs/bevy/latest/bevy/prelude/struct.ImageBundle.html)
(Same as `TextBundle`)
-
[`AtlasImageBundle`](https://docs.rs/bevy/latest/bevy/prelude/struct.AtlasImageBundle.html)
(Will be deprecated in 0.14 there's no point)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Cross-Cutting Impacts the entire engine A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant