Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query in a run criteria system doesn't work #2000

Closed
engiwengi opened this issue Apr 24, 2021 · 3 comments
Closed

Query in a run criteria system doesn't work #2000

engiwengi opened this issue Apr 24, 2021 · 3 comments
Labels
A-ECS Entities, components, systems, and events C-Bug An unexpected or incorrect behavior

Comments

@engiwengi
Copy link

engiwengi commented Apr 24, 2021

Bevy version

Bevy main 38feddb

Operating system & version

Windows 10

What you did

struct Foo;

fn number_of_entities_system(mut commands: Commands, query: Query<&Foo>) {
    println!("num entities from dummy: {}", query.iter().count());
    commands.spawn_bundle((Foo,));
}

fn number_of_entities_critiera(query: Query<&Foo>) -> ShouldRun {
    println!("num entities from criteria: {}", query.iter().count());
    ShouldRun::Yes
}

App::build()
    .add_plugins(MinimalPlugins)
    .add_system(
        number_of_entities_system
            .system()
            .with_run_criteria(number_of_entities_critiera.system()),
    )
    .run();

What you expected to happen

Both systems print the same number of entities

What actually happened

Run criteria reports zero entities, system reports correct number.

Additional information

Console log on my machine:

num entities from dummy: 1695
num entities from criteria: 0
num entities from dummy: 1696
num entities from criteria: 0
num entities from dummy: 1697
num entities from criteria: 0
num entities from dummy: 1698
@engiwengi engiwengi added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Apr 24, 2021
@Moxinilian Moxinilian added A-ECS Entities, components, systems, and events and removed S-Needs-Triage This issue needs to be labelled labels Apr 24, 2021
@cart
Copy link
Member

cart commented Apr 24, 2021

I'm guessing this is probably caused by SystemStage not calling System::new_archetype() on its run criteria systems when new Archetypes are added.

@cart
Copy link
Member

cart commented Apr 24, 2021

Pulling in @Ratysz.

@Ratysz
Copy link
Contributor

Ratysz commented Apr 24, 2021

Sounds plausible. I'm not sure when I'll have the time to take a proper look.

@bors bors bot closed this as completed in 5c4909d Jul 13, 2021
ostwilkens pushed a commit to ostwilkens/bevy that referenced this issue Jul 27, 2021
fixes bevyengine#2000 

archetypes were not updated for run criteria on a stage or on a system set
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Bug An unexpected or incorrect behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants