bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Support `run_if` for SystemConfigs

Open lewiszlw opened this issue 2 years ago • 3 comments

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

Support code like below

.add_systems(
    (
        a_system,
        b_system,
    )
        .in_base_set(CoreSet::PostUpdate)
        .run_if(xxx)
)

lewiszlw avatar Feb 13 '23 13:02 lewiszlw

2 doesn't work well, since I can't easily implement .run_if for SystemConfigs, as it seems to require cloning Conditions.

From #7634. I want this and looked into implementing it twice, but it's not a completely trivial change.

alice-i-cecile avatar Feb 13 '23 17:02 alice-i-cecile

The issue seems not fixed yet. Below code won't compile

        .add_systems(
            (check_collision, remove_piece_component)
                .in_base_set(CoreSet::PostUpdate)
                .distributive_run_if(state_exists_and_equals(GameState::GamePlaying)),
        )

From rust doc, closures implement both Copy and Clone if all of the captured variables do. Many common conditions can't be used by distributive_run_if. Can you reopen this issue for tracking?

lewiszlw avatar Mar 07 '23 15:03 lewiszlw

This should be moved into milestone 0.11 .

lewiszlw avatar Mar 08 '23 06:03 lewiszlw