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

Allow to combine "distributive_run_if" with "not" #8329

Closed
beetrootpaul opened this issue Apr 8, 2023 · 1 comment
Closed

Allow to combine "distributive_run_if" with "not" #8329

beetrootpaul opened this issue Apr 8, 2023 · 1 comment
Labels
A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use

Comments

@beetrootpaul
Copy link

What problem does this solve or what need does it fill?

Today I just learnt about distributive_run_if and wanted to use it on my systems. I managed to do it one place where it was like:

        app.add_systems(
            (system_1, system_2, system_3)
                .in_set(My::Set)
                .distributive_run_if(in_state(My::State)),
        );

Sadly, it was impossible to do same for another set of systems, in the place where I needed to do not condition:

        app.add_systems(
            (system_1, system_2, system_3)
                .in_set(My::Set)
                .distributive_run_if(not(in_state(My::State))),
        );

because of an error:

the trait bound `impl bevy::prelude::Condition<()>: std::clone::Clone` is not satisfied [E0277] the trait `std::clone::Clone` is not implemented for `impl bevy::prelude::Condition<()>` Note: required by a bound in `bevy::prelude::IntoSystemConfigs::distributive_run_if`

What solution would you like?

Possibility to use not(…) inside distributive_run_if(…).

What alternative(s) have you considered?

To overcome that, I created a custom condition which was not using not, like this:

        app.add_systems(
            (system_1, system_2, system_3)
                .in_set(My::Set)
                .distributive_run_if(my_custom__not_in_that_certain_state__condition),
        );

Additional context

A place in my public repo where I tried to achieve what is visible on the screenshot below:

https://github.com/beetrootpaul/hen-rescue-hero/blob/e5bc1f95e1203deef4424c53836f59b0245547d4/hrh_game/src/game.rs#L62-L72

A screenshot from my IDE:

screenshot 2023-04-08 at 18 11 41

I use Bevy in version 0.10.1.

@beetrootpaul beetrootpaul added C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Apr 8, 2023
@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use and removed C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Apr 8, 2023
@B-Reif
Copy link
Contributor

B-Reif commented Apr 8, 2023

This is fixed on main, and #8060 was added to the 10.1 milestone, but the fix didn't make it into 10.1 for some reason.

See https://github.com/bevyengine/bevy/blob/main/crates/bevy_ecs/src/schedule/condition.rs#L943 on the main branch for the fixed implementation.

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-Usability A targeted quality-of-life change that makes Bevy easier to use
Projects
None yet
Development

No branches or pull requests

3 participants