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
b74b3b2123
commit
5d5e67fa35
@ -370,6 +370,7 @@ impl Archetype {
|
|||||||
// SAFETY: We are creating an archetype that includes this component so it must exist
|
// SAFETY: We are creating an archetype that includes this component so it must exist
|
||||||
let info = unsafe { components.get_info_unchecked(component_id) };
|
let info = unsafe { components.get_info_unchecked(component_id) };
|
||||||
info.update_archetype_flags(&mut flags);
|
info.update_archetype_flags(&mut flags);
|
||||||
|
observers.update_archetype_flags(component_id, &mut flags);
|
||||||
archetype_components.insert(
|
archetype_components.insert(
|
||||||
component_id,
|
component_id,
|
||||||
ArchetypeComponentInfo {
|
ArchetypeComponentInfo {
|
||||||
|
|||||||
@ -400,6 +400,10 @@ mod tests {
|
|||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
struct C;
|
struct C;
|
||||||
|
|
||||||
|
#[derive(Component)]
|
||||||
|
#[component(storage = "SparseSet")]
|
||||||
|
struct S;
|
||||||
|
|
||||||
#[derive(Event)]
|
#[derive(Event)]
|
||||||
struct EventA;
|
struct EventA;
|
||||||
|
|
||||||
@ -444,6 +448,22 @@ mod tests {
|
|||||||
assert_eq!(3, world.resource::<R>().0);
|
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]
|
#[test]
|
||||||
fn observer_order_recursive() {
|
fn observer_order_recursive() {
|
||||||
let mut world = World::new();
|
let mut world = World::new();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user