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

Unable to use distributive_run_if with common conditions #8058

Closed
st0rmbtw opened this issue Mar 12, 2023 · 3 comments · Fixed by #8060
Closed

Unable to use distributive_run_if with common conditions #8058

st0rmbtw opened this issue Mar 12, 2023 · 3 comments · Fixed by #8060
Labels
A-ECS Entities, components, systems, and events C-Bug An unexpected or incorrect behavior
Milestone

Comments

@st0rmbtw
Copy link
Contributor

st0rmbtw commented Mar 12, 2023

Bevy version

0.10.0

What you did

I wanted to add a chain of systems with run condition using distributive_run_if

app.add_systems(
    (
        update_cursor_position,
        update_info,
    )
    .chain()
    .distributive_run_if(resource_equals(UiVisibility(true)))
);

What went wrong

That code doesn't compile because distributive_run_if requires a condition to implement Clone, but all common conditions don't return Clone-able functions.

Additional information

error: the trait bound `impl for<'a> FnMut(bevy::prelude::Res<'a, ui::resources::UiVisibility>) -> bool: Clone` is not satisfied

@st0rmbtw st0rmbtw added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Mar 12, 2023
@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events D-Trivial Nice and easy! A great choice to get started with Bevy and removed S-Needs-Triage This issue needs to be labelled labels Mar 12, 2023
@alice-i-cecile alice-i-cecile added this to the 0.11 milestone Mar 12, 2023
@alice-i-cecile
Copy link
Member

When fixing this, remember to change the ones in bevy_time and bevy_input too!

@B-Reif
Copy link
Contributor

B-Reif commented Mar 12, 2023

We can't necessarily expect all of these conditions to implement Clone, right? Or would we constrain conditions like resource_equals to resources which implement Clone?

@B-Reif
Copy link
Contributor

B-Reif commented Mar 12, 2023

This currently poses a problem for

  • resource_equals<T>
  • resource_exists_and_equals<T>
  • not

The resource conditions would have to expect the Resource type T to be Clone. The not condition returns a CombinatorSystem which isn't Clone.

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.

3 participants