Open
Description
What problem does this solve or what need does it fill?
Currently if a bundle has components which are wrapped in an Option<>
, they are treated literally. However in my opinion it would be a good addition if we had the option to mark optional components, and they would be treated as such.
What solution would you like?
Unfortunately I don't understand the inner workings of bevy enough to propose an exact solution, but after having a small conversation on discord, it has come to my attention, that there had been a similar feature like this in the old ECS called DynamicBundle
. An example might look like this:
#[derive(Bundle)]
struct BundleA {
component_a: f32,
#[optional]
component_b: Option<i32>
}
// In a system
let bundle = BundleA { component_a: 0f32, component_b: None };
commands.spawn_bundle(bundle) // --> Only component_a is added to the entity;
What alternative(s) have you considered?
Manually checking every optional component and adding it manually.
Additional context
I hadn't used DynamicBundle when it was still in, so I don't know if what I'm proposing makes sense.