Description
What problem does this solve or what need does it fill?
There's some nice new spawning ergonomics for spawning a hierarchy of entities all at once. However, I can't put a SpawnRelatedBundle into a field of a struct that I'm deriving Bundle for:
#[derive(Bundle)]
pub struct EnemyDingusBundle {
pub identity: EnemyDingus,
pub script_state: SpawnRelatedBundle<ChildOf, Spawn<ScriptState>>
}
impl EnemyDingusBundle {
fn new(script: Handle<Script>) -> Self {
Self {
identity: EnemyDingus,
script_state: Children::spawn(Spawn(ScriptState::root(script))),
}
}
}
This gives an error like the trait bound SpawnRelatedBundle<ChildOf, Spawn<SomeComponent>>: BundleFromComponents is not satisfied
.
Putting the SpawnRelatedBundle beside a derived bundle struct and wrapping them in a tuple bundle works fine, though:
#[derive(Bundle)]
pub struct EnemyDingusBundle {
pub identity: EnemyDingus,
}
impl EnemyDingusBundle {
fn dingus_plus(script: ScriptState) -> impl Bundle {
(
Self { identity: EnemyDingus },
Children::spawn(Spawn(ScriptState::root(script))),
)
}
}
It looks like bundles with bundle effects work as expected in tuple bundles because those have a manual/bespoke Bundle implementation, but the derive macro doesn't know what to do with them.
What solution would you like?
Support effectful bundles as fields of structs that derive Bundle
, so that struct bundles have equal features to tuple bundles.
What alternative(s) have you considered?
- Make do with tuple bundle wrappers instead of well-defined bundle structs. (Which is what I'm going forward with for now.)