Skip to content

Problem with all_children_iter #12

@eldyer

Description

@eldyer

The following test fails:

#[test]
fn test() {
        let mut world = World::new();
        world.register::<Parent>();
        let mut system = HierarchySystem::<Parent>::new();
        System::setup(&mut system, &mut world.res);

        let e3 = world.create_entity().build();
        let e1 = world.create_entity().build();
        let e2 = world.create_entity().build();
        let e0 = world.create_entity().build();

        world.write_storage::<Parent>().insert(e2, Parent {entity: e1 });
        world.write_storage::<Parent>().insert(e1, Parent {entity: e0 });
        world.write_storage::<Parent>().insert(e3, Parent {entity: e2 });

        system.run_now(&mut world.res);
        world.maintain();

        let hierarchy = world.read_resource::<Hierarchy<Parent>>();
        assert!(hierarchy.all_children_iter(e0).eq([e1, e2, e3].iter().cloned()));
    }

However, it works if I change the order of the entity creation into e.g.:

        let e0 = world.create_entity().build();
        let e1 = world.create_entity().build();
        let e2 = world.create_entity().build();
        let e3 = world.create_entity().build();

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions