mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
Update observer archetype flags for sparse components (#13886)
# Objective - Fixes #13885 ## Solution - Update the flags correctly on archetype creation ## Testing - Added `observer_order_insert_remove_sparse` to catch regressions.
This commit is contained in:
parent
8626ad05bc
commit
335dcf96a2
2 changed files with 21 additions and 0 deletions
|
@ -370,6 +370,7 @@ impl Archetype {
|
|||
// SAFETY: We are creating an archetype that includes this component so it must exist
|
||||
let info = unsafe { components.get_info_unchecked(component_id) };
|
||||
info.update_archetype_flags(&mut flags);
|
||||
observers.update_archetype_flags(component_id, &mut flags);
|
||||
archetype_components.insert(
|
||||
component_id,
|
||||
ArchetypeComponentInfo {
|
||||
|
|
|
@ -400,6 +400,10 @@ mod tests {
|
|||
#[derive(Component)]
|
||||
struct C;
|
||||
|
||||
#[derive(Component)]
|
||||
#[component(storage = "SparseSet")]
|
||||
struct S;
|
||||
|
||||
#[derive(Event)]
|
||||
struct EventA;
|
||||
|
||||
|
@ -444,6 +448,22 @@ mod tests {
|
|||
assert_eq!(3, world.resource::<R>().0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn observer_order_insert_remove_sparse() {
|
||||
let mut world = World::new();
|
||||
world.init_resource::<R>();
|
||||
|
||||
world.observe(|_: Trigger<OnAdd, S>, mut res: ResMut<R>| res.assert_order(0));
|
||||
world.observe(|_: Trigger<OnInsert, S>, mut res: ResMut<R>| res.assert_order(1));
|
||||
world.observe(|_: Trigger<OnRemove, S>, mut res: ResMut<R>| res.assert_order(2));
|
||||
|
||||
let mut entity = world.spawn_empty();
|
||||
entity.insert(S);
|
||||
entity.remove::<S>();
|
||||
entity.flush();
|
||||
assert_eq!(3, world.resource::<R>().0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn observer_order_recursive() {
|
||||
let mut world = World::new();
|
||||
|
|
Loading…
Reference in a new issue