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 ChildBuilder::spawn_batch #15869

Open
papow65 opened this issue Oct 12, 2024 · 1 comment
Open

Add ChildBuilder::spawn_batch #15869

papow65 opened this issue Oct 12, 2024 · 1 comment
Labels
A-ECS Entities, components, systems, and events A-Hierarchy Parent-child entity hierarchies C-Feature A new feature, making something new possible D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it!

Comments

@papow65
Copy link
Contributor

papow65 commented Oct 12, 2024

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

There lacks a handy and efficient way to spawn many similar entities when using ChildBuilder.

What solution would you like?

Commands::spawn_batch is a handy and efficient way to spawn multiple entities. A similar method should be provided on ChildBuilder.

When migrating to 0.15-dev, where TextSpans are separate entities, I've noticed I would use ChildBuilder::spawn_batch often if it existed.

What alternative(s) have you considered?

Waiting for bsn!, or using on i-cant-believe-its-not-bsn.

@papow65 papow65 added C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Oct 12, 2024
@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events A-Hierarchy Parent-child entity hierarchies S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it! D-Straightforward Simple bug fixes and API improvements, docs, test and examples and removed S-Needs-Triage This issue needs to be labelled labels Oct 12, 2024
@pablo-lua
Copy link
Contributor

This problem Is much trickier than it seems. There is the problem that spawn_batch (command wise) doesn't return the entities for use with Child Builder. So, we would need to change this to spawn the entities via commands first and then send the entities. The problem is that commands can't do it as fast as spawn_batch do, the entities would already be spawned. And finally, changing the SpawnBatch impl doesn't really help us here, as bevy_hierarchy and bevy_ecs are separate crates, so we can't create something that inserts the Parent for us while giving us back the spawned entities so we can add in AddChildren
I saw just one solution when I investigate this: We can use insert_batch so we actually have the spawned entities (see #15702) or we can use something like #15635, so we just need to pass the Parent Component. (This just if we keep the ChildBuilder after linked PR)

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 A-Hierarchy Parent-child entity hierarchies C-Feature A new feature, making something new possible D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it!
Projects
None yet
Development

No branches or pull requests

3 participants