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

Add the ability to append to a Bundle struct(or tuple) #1335

Closed
RustyStriker opened this issue Jan 27, 2021 · 6 comments
Closed

Add the ability to append to a Bundle struct(or tuple) #1335

RustyStriker opened this issue Jan 27, 2021 · 6 comments
Labels
A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use

Comments

@RustyStriker
Copy link

While learning the engine, i stumbled across a thing I believe is slowing down and forcing you to write more code than necessary, you cannot append to a Bundle.

I suggest adding the ability to add something to a Bundle struct, either by putting it in a tuple(which feels like the most intuitive solution) or any other way.

I managed to hack it around using a macro I found on: https://stackoverflow.com/questions/57454887/how-do-i-append-to-a-tuple
and added a function to the SpriteBundle which makes it into a tuple.

The idea is to prevent boiler code and have the ability to not repeat the same variables(like Transform) and use the Bundle types as a base so you could do something like:
commands.spawn((Player,SpriteBundle));
instead of:
commands.spawn((Player,Sprite,Mesh,...));

@cart
Copy link
Member

cart commented Jan 27, 2021

You can currently do this, which enables you to add components and bundles to spawned entities in a composable manner:

commands
    .spawn((Player, SomethingElse))
    .with_bundle(SpriteBundle {...})
    .with(SomeOtherComponent);

@RustyStriker
Copy link
Author

oh, well, I did not know that, and currently finding info is kinda difficult without proper docs and tutorials...

@alice-i-cecile
Copy link
Member

@RustyStriker, the docs are definitely lacking, but there are some good tutorials and unofficial docs listed on awesome-bevy.

@alice-i-cecile
Copy link
Member

For anyone else who runs across this, check out #792, which discusses another issue / set of proposals along these same lines.

@karroffel karroffel added the A-ECS Entities, components, systems, and events label Jan 30, 2021
@alice-i-cecile alice-i-cecile added the C-Usability A targeted quality-of-life change that makes Bevy easier to use label Feb 18, 2021
@alice-i-cecile
Copy link
Member

Is the functionality described in #1570 adequate for this, or do we need another method?

@cart
Copy link
Member

cart commented Mar 7, 2021

I think the new "nested bundles", plus "bundle merging" as described in #792 covers the desired use cases. I'm closing this, but feel free to continue the discussion here if anyone has other ideas.

@cart cart closed this as completed Mar 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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

No branches or pull requests

4 participants