-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Open
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-FeatureA new feature, making something new possibleA new feature, making something new possibleD-ComplexQuite challenging from either a design or technical perspective. Ask for help!Quite challenging from either a design or technical perspective. Ask for help!S-Needs-Design-DocThis issue or PR is particularly complex, and needs an approved design doc before it can be mergedThis issue or PR is particularly complex, and needs an approved design doc before it can be merged
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.
Nilirad, StarArawn, adsick, CGMossa, IceSentry and 22 morealice-i-cecile, CGMossa, yishn, wokste, therocode and 6 more
Metadata
Metadata
Assignees
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-FeatureA new feature, making something new possibleA new feature, making something new possibleD-ComplexQuite challenging from either a design or technical perspective. Ask for help!Quite challenging from either a design or technical perspective. Ask for help!S-Needs-Design-DocThis issue or PR is particularly complex, and needs an approved design doc before it can be mergedThis issue or PR is particularly complex, and needs an approved design doc before it can be merged