-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Closed
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-FeatureA new feature, making something new possibleA new feature, making something new possibleC-UsabilityA targeted quality-of-life change that makes Bevy easier to useA targeted quality-of-life change that makes Bevy easier to useS-Needs-DesignThis issue requires design work to think about how it would best be accomplishedThis issue requires design work to think about how it would best be accomplished
Description
I ran into an issue using Commands::spawn_batch
to spawn in a bunch of entities that have some custom components and also needed a SpriteComponents
bundle for rendering, and the only way I could find to do this was to use commands.spawn(...).with_bundle(...)
or inline the fields of SpriteComponents
. Both of these are sub-optimal solutions in my eyes.
One way to solve this would be to add a combinator for Bundle
like
trait Bundle {
// ...
fn and<B: Bundle>(self, other: B) -> And<Self, B> where Self: Sized {
And { first: self, second: other }
}
}
struct And<A, B> {
first: A,
second: B,
}
impl<A: Bundle, B: Bundle> Bundle for And<A, B> {
// ...
}
such that
fn some_startup(mut commands: Commands) {
commands.spawn(bundle_a).with_bundle(bundle_b);
}
// has the same effect as
fn some_startup(mut commands: Commands) {
commands.spawn(bundle_a.and(bundle_b));
}
This would allow you to combine bundles in places where you can only pass in a single bundle, for example Commands::spawn_batch
.
alice-i-cecile, mcobzarenco, ytaras, RustyStriker, mwillsey and 1 moremcobzarenco
Metadata
Metadata
Assignees
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-FeatureA new feature, making something new possibleA new feature, making something new possibleC-UsabilityA targeted quality-of-life change that makes Bevy easier to useA targeted quality-of-life change that makes Bevy easier to useS-Needs-DesignThis issue requires design work to think about how it would best be accomplishedThis issue requires design work to think about how it would best be accomplished