-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Implement Spawn
trait
#14247
Implement Spawn
trait
#14247
Conversation
After going through all the code for this, I think |
I'll fix docs after we agree on the code, it's a pain to maintain at all time |
Not a full review yet but one note: Since fn foo<C: Spawn>(commands: C) -> C::SpawnOutput {
commands.spawn_empty()
.insert(...) // Error
.with_children(...) // Error
} This would require another trait, so if the plan is to do that in a separate PR that makes sense. |
I'm getting the easy traits out first, hopefully we can get a few in 0.14.1 The trait for |
Deferred vs immediate is already the case for |
type SpawnOutput<'a> = EntityWorldMut<'a> where Self: 'a; | ||
|
||
fn spawn(&mut self, bundle: impl Bundle) -> EntityWorldMut { | ||
let entity = self.world.spawn((bundle, Parent(self.parent))).id(); | ||
/// Spawns an entity with the given bundle and inserts it into the parent entity's [`Children`]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docs got swapped between spawn_empty
and spawn
.
Naming proposition:
Or something along these lines. Issue is, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to see a more cohesive overview of which traits would be used, and what they would be implemented for. I don't think this is wise to merge piecemeal, although I am in favor of the broad idea.
If we can't do it piecewise then this will turn into a large scale PR that will need to be for 0.15, in that case I'm closing the issue in favor of future discussion in #14231 with this as an example |
Objective
Solution
Spawn
trait that providesspawn_empty
andspawn
APIWorld
,Commands
,WorldChildBuilder
andChildBuilder
Migration Guide
Spawn
was added tobevy::prelude
, but will have to be included manually if prelude is not used.