-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Open
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-BugAn unexpected or incorrect behaviorAn unexpected or incorrect behaviorS-Needs-DesignThis issue requires design work to think about how it would best be accomplishedThis issue requires design work to think about how it would best be accomplished
Description
Bevy version
main
What you did
Adding required components manually can make a Bundle
outdated. This can cause diverging behavior depending on if you use bundles registered before or after manually requiring components in these bundles.
#[derive(Component)]
struct C1;
#[derive(Component, Default)]
struct C2;
let mut world = World::new();
world.register_bundle::<C1>();
world.register_required_components::<C1, C2>(); // succeeds, no C1 anywhere yet
assert!(world.spawn((C1,)).contains::<C2>()); // succeeds, registers new bundle after requiring C2
assert!(world.spawn(C1).contains::<C2>()); // fails, uses outdated bundle
Worth noting you can register bundles in many ways so a solution that minds only bundles registered by type is not enough.
Metadata
Metadata
Assignees
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-BugAn unexpected or incorrect behaviorAn unexpected or incorrect behaviorS-Needs-DesignThis issue requires design work to think about how it would best be accomplishedThis issue requires design work to think about how it would best be accomplished