From 854ab46ec85dd6f3be7aaa426c03d6bbe8ed6294 Mon Sep 17 00:00:00 2001 From: Martin Indra Date: Tue, 25 Jul 2023 22:44:05 +0200 Subject: [PATCH] Join common system conditions (#647) --- crates/camera/src/camera.rs | 33 +++++++------------ crates/camera/src/distance.rs | 11 +++---- crates/combat/src/attack.rs | 16 ++++----- crates/combat/src/trail.rs | 5 +-- crates/construction/src/manufacturing.rs | 16 +++------ crates/controller/src/commands/executor.rs | 15 +++------ crates/controller/src/commands/handlers.rs | 23 +++---------- crates/controller/src/draft.rs | 21 ++++++------ crates/controller/src/hud/actionbar.rs | 8 ++--- crates/controller/src/hud/menu.rs | 8 ++--- crates/controller/src/hud/minimap/fill.rs | 12 +++---- .../controller/src/hud/minimap/interaction.rs | 13 +++----- crates/controller/src/mouse/input.rs | 10 ++---- crates/controller/src/mouse/pointer.rs | 8 ++--- .../controller/src/selection/bookkeeping.rs | 14 +++----- crates/index/src/systems.rs | 11 ++----- crates/menu/src/create.rs | 14 +++----- crates/menu/src/gamelisting.rs | 7 ++-- crates/menu/src/mapselection.rs | 3 +- crates/menu/src/signin.rs | 13 ++++---- crates/menu/src/singleplayer.rs | 5 +-- crates/movement/src/obstacles.rs | 17 ++++------ crates/movement/src/repulsion.rs | 13 +++----- crates/multiplayer/src/stats.rs | 13 +++----- crates/pathing/src/fplugin.rs | 14 ++++---- crates/pathing/src/pplugin.rs | 6 ++-- crates/signs/src/bars.rs | 21 +++++------- crates/signs/src/line.rs | 7 ++-- crates/signs/src/pole.rs | 22 ++++--------- crates/spawner/src/draft.rs | 14 ++------ crates/terrain/src/marker.rs | 12 +++---- 31 files changed, 138 insertions(+), 267 deletions(-) diff --git a/crates/camera/src/camera.rs b/crates/camera/src/camera.rs index f446c748..1eeb055e 100644 --- a/crates/camera/src/camera.rs +++ b/crates/camera/src/camera.rs @@ -54,56 +54,45 @@ impl Plugin for CameraPlugin { .add_systems( InputSchedule, ( - handle_horizontal_events - .run_if(in_state(GameState::Playing)) - .in_set(CameraSet::MoveHorizontallEvent), - handle_zoom_events - .run_if(in_state(GameState::Playing)) - .in_set(CameraSet::ZoomEvent), - handle_rotate_events - .run_if(in_state(GameState::Playing)) - .in_set(CameraSet::RotateEvent), - handle_tilt_events - .run_if(in_state(GameState::Playing)) - .in_set(CameraSet::TiltEvent), - ), + handle_horizontal_events.in_set(CameraSet::MoveHorizontallEvent), + handle_zoom_events.in_set(CameraSet::ZoomEvent), + handle_rotate_events.in_set(CameraSet::RotateEvent), + handle_tilt_events.in_set(CameraSet::TiltEvent), + ) + .run_if(in_state(GameState::Playing)), ) .add_systems( PreMovement, ( update_focus - .run_if(in_state(GameState::Playing)) .run_if(on_event::()) .in_set(InternalCameraSet::UpdateFocus), process_move_focus_events - .run_if(in_state(GameState::Playing)) .in_set(InternalCameraSet::MoveFocus) .after(InternalCameraSet::UpdateFocus), update_translation_handler - .run_if(in_state(GameState::Playing)) .run_if(on_event::()) .after(InternalCameraSet::MoveFocus), - ), + ) + .run_if(in_state(GameState::Playing)), ) .add_systems( Movement, ( - zoom.run_if(in_state(GameState::Playing)) - .in_set(InternalCameraSet::Zoom), + zoom.in_set(InternalCameraSet::Zoom), pivot - .run_if(in_state(GameState::Playing)) .run_if( resource_exists_and_changed::() .or_else(resource_exists_and_changed::()), ) .in_set(InternalCameraSet::Pivot), move_horizontaly - .run_if(in_state(GameState::Playing)) // Zooming changes camera focus point so do it // after other types of camera movement. .after(InternalCameraSet::Zoom) .after(InternalCameraSet::Pivot), - ), + ) + .run_if(in_state(GameState::Playing)), ); } } diff --git a/crates/camera/src/distance.rs b/crates/camera/src/distance.rs index 73d9ae7c..6abbb3ae 100644 --- a/crates/camera/src/distance.rs +++ b/crates/camera/src/distance.rs @@ -11,12 +11,11 @@ impl Plugin for DistancePlugin { app.add_systems( PostUpdate, ( - init::.run_if(in_state(AppState::InGame)), - init::.run_if(in_state(AppState::InGame)), - update - .run_if(in_state(AppState::InGame)) - .in_set(DistanceSet::Update), - ), + init::, + init::, + update.in_set(DistanceSet::Update), + ) + .run_if(in_state(AppState::InGame)), ); } } diff --git a/crates/combat/src/attack.rs b/crates/combat/src/attack.rs index c7ada56d..88ef617d 100644 --- a/crates/combat/src/attack.rs +++ b/crates/combat/src/attack.rs @@ -26,25 +26,21 @@ impl Plugin for AttackPlugin { PreUpdate, ( attack - .run_if(in_state(GameState::Playing)) .in_set(AttackingSet::Attack) .before(ChaseSet::ChaseTargetEvent), - update_positions - .run_if(in_state(GameState::Playing)) - .after(AttackingSet::Attack), - ), + update_positions.after(AttackingSet::Attack), + ) + .run_if(in_state(GameState::Playing)), ) .add_systems( Update, ( - charge - .run_if(in_state(GameState::Playing)) - .in_set(AttackingSet::Charge), + charge.in_set(AttackingSet::Charge), aim_and_fire - .run_if(in_state(GameState::Playing)) .after(AttackingSet::Charge) .before(AttackingSet::Fire), - ), + ) + .run_if(in_state(GameState::Playing)), ); } } diff --git a/crates/combat/src/trail.rs b/crates/combat/src/trail.rs index cce01c6b..cf311ce3 100644 --- a/crates/combat/src/trail.rs +++ b/crates/combat/src/trail.rs @@ -27,10 +27,7 @@ impl Plugin for TrailPlugin { .add_systems(OnExit(AppState::InGame), cleanup) .add_systems( PostUpdate, - ( - spawn.run_if(in_state(GameState::Playing)), - update.run_if(in_state(GameState::Playing)), - ), + (spawn, update).run_if(in_state(GameState::Playing)), ); } } diff --git a/crates/construction/src/manufacturing.rs b/crates/construction/src/manufacturing.rs index 92dd1633..dc0ecff7 100644 --- a/crates/construction/src/manufacturing.rs +++ b/crates/construction/src/manufacturing.rs @@ -34,20 +34,14 @@ impl Plugin for ManufacturingPlugin { .add_systems( PreUpdate, ( - change_locations - .run_if(in_state(GameState::Playing)) - .in_set(ManufacturingSet::ChangeLocations), - check_spawn_locations - .run_if(in_state(GameState::Playing)) - .before(ManufacturingSet::Produce), - produce - .run_if(in_state(GameState::Playing)) - .in_set(ManufacturingSet::Produce), + change_locations.in_set(ManufacturingSet::ChangeLocations), + check_spawn_locations.before(ManufacturingSet::Produce), + produce.in_set(ManufacturingSet::Produce), deliver - .run_if(in_state(GameState::Playing)) .after(ManufacturingSet::ChangeLocations) .after(ManufacturingSet::Produce), - ), + ) + .run_if(in_state(GameState::Playing)), ) .add_systems(Update, enqueue.run_if(in_state(GameState::Playing))) .add_systems(PostUpdate, configure.run_if(in_state(AppState::InGame))); diff --git a/crates/controller/src/commands/executor.rs b/crates/controller/src/commands/executor.rs index c67bc42a..0223a42c 100644 --- a/crates/controller/src/commands/executor.rs +++ b/crates/controller/src/commands/executor.rs @@ -18,16 +18,11 @@ impl Plugin for ExecutorPlugin { .add_systems( InputSchedule, ( - send_selected_system - .run_if(in_state(GameState::Playing)) - .in_set(CommandsSet::SendSelected), - delivery_location_system - .run_if(in_state(GameState::Playing)) - .in_set(CommandsSet::DeliveryLocation), - attack_system - .run_if(in_state(GameState::Playing)) - .in_set(CommandsSet::Attack), - ), + send_selected_system.in_set(CommandsSet::SendSelected), + delivery_location_system.in_set(CommandsSet::DeliveryLocation), + attack_system.in_set(CommandsSet::Attack), + ) + .run_if(in_state(GameState::Playing)), ); } } diff --git a/crates/controller/src/commands/handlers.rs b/crates/controller/src/commands/handlers.rs index 9dcbac58..7ad2a313 100644 --- a/crates/controller/src/commands/handlers.rs +++ b/crates/controller/src/commands/handlers.rs @@ -74,7 +74,6 @@ impl Plugin for HandlersPlugin { InputSchedule, ( right_click_handler - .run_if(in_state(GameState::Playing)) .run_if(on_click(MouseButton::Right)) .after(PointerSet::Update) .after(MouseSet::Buttons) @@ -82,7 +81,6 @@ impl Plugin for HandlersPlugin { .before(CommandsSet::DeliveryLocation) .before(CommandsSet::Attack), left_click_handler - .run_if(in_state(GameState::Playing)) .run_if(on_click(MouseButton::Left)) .in_set(HandlersSet::LeftClick) .before(SelectionSet::Update) @@ -90,37 +88,26 @@ impl Plugin for HandlersPlugin { .after(PointerSet::Update) .after(MouseSet::Buttons), double_click_handler - .run_if(in_state(GameState::Playing)) .run_if(on_double_click(MouseButton::Left)) .before(SelectionSet::Update) .before(DraftSet::Spawn) .after(PointerSet::Update) .after(MouseSet::Buttons) .after(HandlersSet::LeftClick), - move_camera_arrows_system - .run_if(in_state(GameState::Playing)) - .before(CameraSet::MoveHorizontallEvent), - move_camera_mouse_system - .run_if(in_state(GameState::Playing)) - .before(CameraSet::MoveHorizontallEvent), - zoom_camera - .run_if(in_state(GameState::Playing)) - .before(CameraSet::ZoomEvent), + move_camera_arrows_system.before(CameraSet::MoveHorizontallEvent), + move_camera_mouse_system.before(CameraSet::MoveHorizontallEvent), + zoom_camera.before(CameraSet::ZoomEvent), pivot_camera - .run_if(in_state(GameState::Playing)) .before(CameraSet::RotateEvent) .before(CameraSet::TiltEvent), handle_escape - .run_if(in_state(GameState::Playing)) .run_if(KeyCondition::single(KeyCode::Escape).build()) .before(GameMenuSet::Toggle) .before(DraftSet::Discard), select_all - .run_if(in_state(GameState::Playing)) .run_if(KeyCondition::single(KeyCode::A).with_ctrl().build()) .before(SelectionSet::Update), select_all_visible - .run_if(in_state(GameState::Playing)) .run_if( KeyCondition::single(KeyCode::A) .with_ctrl() @@ -129,10 +116,10 @@ impl Plugin for HandlersPlugin { ) .before(AreaSelectSet::SelectInArea), update_drags - .run_if(in_state(GameState::Playing)) .before(AreaSelectSet::SelectInArea) .after(MouseSet::Buttons), - ), + ) + .run_if(in_state(GameState::Playing)), ); Self::add_place_draft_systems(app); diff --git a/crates/controller/src/draft.rs b/crates/controller/src/draft.rs index 920cc6a1..a866a83c 100644 --- a/crates/controller/src/draft.rs +++ b/crates/controller/src/draft.rs @@ -21,17 +21,16 @@ impl Plugin for DraftPlugin { .add_systems( InputSchedule, ( - spawn - .run_if(in_state(AppState::InGame)) - .run_if(on_event::()) - .in_set(DraftSet::Spawn), - new_drafts - .run_if(in_state(AppState::InGame)) - .in_set(DraftSet::New), - discard_drafts - .run_if(in_state(AppState::InGame)) - .run_if(on_event::()) - .in_set(DraftSet::Discard), + ( + spawn + .run_if(on_event::()) + .in_set(DraftSet::Spawn), + new_drafts.in_set(DraftSet::New), + discard_drafts + .run_if(on_event::()) + .in_set(DraftSet::Discard), + ) + .run_if(in_state(AppState::InGame)), move_drafts .run_if(in_state(GameState::Playing)) .after(PointerSet::Update), diff --git a/crates/controller/src/hud/actionbar.rs b/crates/controller/src/hud/actionbar.rs index f734ec9a..9e751362 100644 --- a/crates/controller/src/hud/actionbar.rs +++ b/crates/controller/src/hud/actionbar.rs @@ -21,14 +21,12 @@ impl Plugin for ActionBarPlugin { .add_systems( PostUpdate, ( - detect_update - .run_if(in_state(GameState::Playing)) - .in_set(ActionBarSet::DetectUpdate), + detect_update.in_set(ActionBarSet::DetectUpdate), update - .run_if(in_state(GameState::Playing)) .run_if(resource_exists_and_changed::()) .after(ActionBarSet::DetectUpdate), - ), + ) + .run_if(in_state(GameState::Playing)), ) .add_systems( InputSchedule, diff --git a/crates/controller/src/hud/menu.rs b/crates/controller/src/hud/menu.rs index 7490f624..a901566c 100644 --- a/crates/controller/src/hud/menu.rs +++ b/crates/controller/src/hud/menu.rs @@ -15,12 +15,8 @@ impl Plugin for MenuPlugin { .add_systems(OnExit(GameState::Playing), cleanup) .add_systems( InputSchedule, - ( - toggle_system - .run_if(in_state(GameState::Playing)) - .in_set(GameMenuSet::Toggle), - button_system.run_if(in_state(GameState::Playing)), - ), + (toggle_system.in_set(GameMenuSet::Toggle), button_system) + .run_if(in_state(GameState::Playing)), ); } } diff --git a/crates/controller/src/hud/minimap/fill.rs b/crates/controller/src/hud/minimap/fill.rs index dc372ef0..543bcbaf 100644 --- a/crates/controller/src/hud/minimap/fill.rs +++ b/crates/controller/src/hud/minimap/fill.rs @@ -28,17 +28,13 @@ impl Plugin for FillPlugin { app.add_systems( PostMovement, ( - clear_system - .run_if(in_state(GameState::Playing)) - .in_set(FillSet::Clear), + clear_system.in_set(FillSet::Clear), draw_entities_system - .run_if(in_state(GameState::Playing)) .in_set(FillSet::DrawEntities) .after(FillSet::Clear), - draw_camera_system - .run_if(in_state(GameState::Playing)) - .after(FillSet::DrawEntities), - ), + draw_camera_system.after(FillSet::DrawEntities), + ) + .run_if(in_state(GameState::Playing)), ); } } diff --git a/crates/controller/src/hud/minimap/interaction.rs b/crates/controller/src/hud/minimap/interaction.rs index 86962677..e6812cd9 100644 --- a/crates/controller/src/hud/minimap/interaction.rs +++ b/crates/controller/src/hud/minimap/interaction.rs @@ -22,21 +22,16 @@ impl Plugin for InteractionPlugin { app.add_event::().add_systems( InputSchedule, ( - click_handler - .run_if(in_state(GameState::Playing)) - .in_set(InteractionSet::ClickHandler), - move_camera_system - .run_if(in_state(GameState::Playing)) - .after(InteractionSet::ClickHandler), + click_handler.in_set(InteractionSet::ClickHandler), + move_camera_system.after(InteractionSet::ClickHandler), send_units_system - .run_if(in_state(GameState::Playing)) .after(InteractionSet::ClickHandler) .before(CommandsSet::SendSelected), delivery_location_system - .run_if(in_state(GameState::Playing)) .after(InteractionSet::ClickHandler) .before(CommandsSet::DeliveryLocation), - ), + ) + .run_if(in_state(GameState::Playing)), ); } } diff --git a/crates/controller/src/mouse/input.rs b/crates/controller/src/mouse/input.rs index b5332ba9..9bdab4dc 100644 --- a/crates/controller/src/mouse/input.rs +++ b/crates/controller/src/mouse/input.rs @@ -25,23 +25,19 @@ impl Plugin for InputPlugin { .add_systems( InputSchedule, ( - update_position - .run_if(in_state(GameState::Playing)) - .in_set(MouseSet::Position), + update_position.in_set(MouseSet::Position), update_drags - .run_if(in_state(GameState::Playing)) .run_if(resource_exists_and_changed::()) .in_set(MouseSet::Drags) .after(MouseSet::Position), update_buttons - .run_if(in_state(GameState::Playing)) .in_set(MouseSet::SingeButton) .after(MouseSet::Drags), check_double_click - .run_if(in_state(GameState::Playing)) .in_set(MouseSet::Buttons) .after(MouseSet::SingeButton), - ), + ) + .run_if(in_state(GameState::Playing)), ); } } diff --git a/crates/controller/src/mouse/pointer.rs b/crates/controller/src/mouse/pointer.rs index 90083500..4672bc6d 100644 --- a/crates/controller/src/mouse/pointer.rs +++ b/crates/controller/src/mouse/pointer.rs @@ -21,13 +21,11 @@ impl Plugin for PointerPlugin { InputSchedule, ( pointer_update_system - .run_if(in_state(GameState::Playing)) .in_set(PointerSet::Update) .after(MouseSet::Position), - update_bar_visibility - .run_if(in_state(GameState::Playing)) - .after(PointerSet::Update), - ), + update_bar_visibility.after(PointerSet::Update), + ) + .run_if(in_state(GameState::Playing)), ); } } diff --git a/crates/controller/src/selection/bookkeeping.rs b/crates/controller/src/selection/bookkeeping.rs index 57dce232..d5fee8a5 100644 --- a/crates/controller/src/selection/bookkeeping.rs +++ b/crates/controller/src/selection/bookkeeping.rs @@ -16,16 +16,10 @@ impl Plugin for BookkeepingPlugin { .add_systems( InputSchedule, ( - update_selection - .run_if(in_state(GameState::Playing)) - .in_set(SelectionSet::Update), - selected_system - .run_if(in_state(GameState::Playing)) - .after(SelectionSet::Update), - deselected_system - .run_if(in_state(GameState::Playing)) - .after(SelectionSet::Update), - ), + update_selection.in_set(SelectionSet::Update), + (selected_system, deselected_system).after(SelectionSet::Update), + ) + .run_if(in_state(GameState::Playing)), ); } } diff --git a/crates/index/src/systems.rs b/crates/index/src/systems.rs index 76367342..12ecf74f 100644 --- a/crates/index/src/systems.rs +++ b/crates/index/src/systems.rs @@ -46,14 +46,9 @@ impl Plugin for IndexPlugin { .add_systems(OnExit(AppState::InGame), cleanup) .add_systems( PostUpdate, - ( - insert - .run_if(in_state(GameState::Playing)) - .in_set(IndexSet::Index), - remove - .run_if(in_state(GameState::Playing)) - .in_set(IndexSet::Index), - ), + (insert, remove) + .run_if(in_state(GameState::Playing)) + .in_set(IndexSet::Index), ) .add_systems( PostMovement, diff --git a/crates/menu/src/create.rs b/crates/menu/src/create.rs index 65576cf3..96b175bc 100644 --- a/crates/menu/src/create.rs +++ b/crates/menu/src/create.rs @@ -27,19 +27,15 @@ impl Plugin for CreateGamePlugin { .add_systems( Update, ( - button_system - .run_if(in_state(MenuState::GameCreation)) - .in_set(CreateSet::Buttons), - map_selected_system - .run_if(in_state(MenuState::GameCreation)) - .in_set(CreateSet::MapSelected), + button_system.in_set(CreateSet::Buttons), + map_selected_system.in_set(CreateSet::MapSelected), create_game_system - .run_if(in_state(MenuState::GameCreation)) .run_if(on_event::()) .after(CreateSet::Buttons) .after(CreateSet::MapSelected), - response_system.run_if(in_state(MenuState::GameCreation)), - ), + response_system, + ) + .run_if(in_state(MenuState::GameCreation)), ); } } diff --git a/crates/menu/src/gamelisting.rs b/crates/menu/src/gamelisting.rs index 31ef1489..29878ce1 100644 --- a/crates/menu/src/gamelisting.rs +++ b/crates/menu/src/gamelisting.rs @@ -17,11 +17,8 @@ impl Plugin for GameListingPlugin { .add_systems(OnExit(MenuState::GameListing), cleanup) .add_systems( Update, - ( - refresh_system.run_if(in_state(MenuState::GameListing)), - list_games_system.run_if(in_state(MenuState::GameListing)), - button_system.run_if(in_state(MenuState::GameListing)), - ), + (refresh_system, list_games_system, button_system) + .run_if(in_state(MenuState::GameListing)), ); } } diff --git a/crates/menu/src/mapselection.rs b/crates/menu/src/mapselection.rs index 7ac8da9a..3593049f 100644 --- a/crates/menu/src/mapselection.rs +++ b/crates/menu/src/mapselection.rs @@ -26,8 +26,7 @@ impl Plugin for MapSelectionPlugin { .add_systems( Update, ( - init_buttons.run_if(in_state(MapState::On)), - button_system.run_if(in_state(MapState::On)), + (init_buttons, button_system).run_if(in_state(MapState::On)), select_map_system .run_if(in_state(AppState::InMenu)) .run_if(on_event::()), diff --git a/crates/menu/src/signin.rs b/crates/menu/src/signin.rs index edc74502..58e9cd60 100644 --- a/crates/menu/src/signin.rs +++ b/crates/menu/src/signin.rs @@ -25,13 +25,12 @@ impl Plugin for SignInPlugin { .add_systems( Update, ( - button_system - .run_if(resource_exists::()) - .run_if(in_state(MenuState::SignIn)), - response_system::.run_if(in_state(MenuState::SignIn)), - response_system::.run_if(in_state(MenuState::SignIn)), - auth_system.run_if(in_state(MenuState::SignIn)), - ), + button_system.run_if(resource_exists::()), + response_system::, + response_system::, + auth_system, + ) + .run_if(in_state(MenuState::SignIn)), ); } } diff --git a/crates/menu/src/singleplayer.rs b/crates/menu/src/singleplayer.rs index 9671ca9f..85334027 100644 --- a/crates/menu/src/singleplayer.rs +++ b/crates/menu/src/singleplayer.rs @@ -21,10 +21,7 @@ impl Plugin for SinglePlayerPlugin { .add_systems(OnExit(MenuState::SinglePlayerGame), cleanup) .add_systems( Update, - ( - button_system.run_if(in_state(MenuState::SinglePlayerGame)), - map_selected_system.run_if(in_state(MenuState::SinglePlayerGame)), - ), + (button_system, map_selected_system).run_if(in_state(MenuState::SinglePlayerGame)), ); } } diff --git a/crates/movement/src/obstacles.rs b/crates/movement/src/obstacles.rs index fb66b8d6..67778bc5 100644 --- a/crates/movement/src/obstacles.rs +++ b/crates/movement/src/obstacles.rs @@ -21,21 +21,16 @@ impl Plugin for ObstaclesPlugin { fn build(&self, app: &mut App) { app.add_systems( PreMovement, - ( - setup_discs.run_if(in_state(GameState::Playing)), - update_discs.run_if(in_state(GameState::Playing)), - ), + (setup_discs, update_discs).run_if(in_state(GameState::Playing)), ) .add_systems( Movement, ( - update_nearby:: - .run_if(in_state(GameState::Playing)) - .in_set(ObstaclesLables::UpdateNearby), - update_nearby:: - .run_if(in_state(GameState::Playing)) - .in_set(ObstaclesLables::UpdateNearby), - ), + update_nearby::, + update_nearby::, + ) + .run_if(in_state(GameState::Playing)) + .in_set(ObstaclesLables::UpdateNearby), ); } } diff --git a/crates/movement/src/repulsion.rs b/crates/movement/src/repulsion.rs index 37d37de4..38d197fd 100644 --- a/crates/movement/src/repulsion.rs +++ b/crates/movement/src/repulsion.rs @@ -30,35 +30,30 @@ impl Plugin for RepulsionPlugin { fn build(&self, app: &mut App) { app.add_systems( PreMovement, - ( - setup_entities.run_if(in_state(AppState::InGame)), - add_desired_velocity::.run_if(in_state(AppState::InGame)), - ), + (setup_entities, add_desired_velocity::) + .run_if(in_state(AppState::InGame)), ) .add_systems( Movement, ( repel_static - .run_if(in_state(GameState::Playing)) .in_set(RepulsionLables::RepelStatic) .after(ObstaclesLables::UpdateNearby) .after(PathingSet::FollowPath), repel_movable - .run_if(in_state(GameState::Playing)) .in_set(RepulsionLables::RepelMovable) .after(ObstaclesLables::UpdateNearby) .after(PathingSet::FollowPath), repel_bounds - .run_if(in_state(GameState::Playing)) .in_set(RepulsionLables::RepelBounds) .after(PathingSet::FollowPath), apply - .run_if(in_state(GameState::Playing)) .in_set(RepulsionLables::Apply) .after(RepulsionLables::RepelStatic) .after(RepulsionLables::RepelMovable) .after(RepulsionLables::RepelBounds), - ), + ) + .run_if(in_state(GameState::Playing)), ); } } diff --git a/crates/multiplayer/src/stats.rs b/crates/multiplayer/src/stats.rs index 98520b3b..81a00b57 100644 --- a/crates/multiplayer/src/stats.rs +++ b/crates/multiplayer/src/stats.rs @@ -36,15 +36,14 @@ impl StatsPlugin { PreMovement, ( pong:: - .run_if(in_state(NetState::Joined)) .run_if(on_event::()) .in_set(StatsSet::Pong) .after(MessagesSet::RecvMessages), unresolved:: - .run_if(in_state(NetState::Joined)) .in_set(StatsSet::Unresolved) .after(StatsSet::Pong), - ), + ) + .run_if(in_state(NetState::Joined)), ); } } @@ -59,14 +58,12 @@ impl Plugin for StatsPlugin { .add_systems( PreMovement, ( - stats_tick - .run_if(in_state(NetState::Joined)) - .in_set(StatsSet::StatsTick), + stats_tick.in_set(StatsSet::StatsTick), delivery_rate - .run_if(in_state(NetState::Joined)) .after(StatsSet::StatsTick) .after(StatsSet::Unresolved), - ), + ) + .run_if(in_state(NetState::Joined)), ); } } diff --git a/crates/pathing/src/fplugin.rs b/crates/pathing/src/fplugin.rs index e2fd89b1..8642af14 100644 --- a/crates/pathing/src/fplugin.rs +++ b/crates/pathing/src/fplugin.rs @@ -51,13 +51,13 @@ impl Plugin for FinderPlugin { check_removed .run_if(in_state(AppState::InGame)) .in_set(FinderSet::CheckRemoved), - check_updated - .run_if(in_state(GameState::Playing)) - .in_set(FinderSet::CheckUpdated), - update - .run_if(in_state(GameState::Playing)) - .after(FinderSet::CheckUpdated) - .after(FinderSet::CheckRemoved), + ( + check_updated.in_set(FinderSet::CheckUpdated), + update + .after(FinderSet::CheckUpdated) + .after(FinderSet::CheckRemoved), + ) + .run_if(in_state(GameState::Playing)), ), ) .add_systems( diff --git a/crates/pathing/src/pplugin.rs b/crates/pathing/src/pplugin.rs index 011fec82..7e7e6dcb 100644 --- a/crates/pathing/src/pplugin.rs +++ b/crates/pathing/src/pplugin.rs @@ -44,16 +44,13 @@ impl Plugin for PathingPlugin { PreMovement, ( update_existing_paths - .run_if(in_state(GameState::Playing)) .run_if(on_event::()) .in_set(PathingSet::UpdateExistingPaths) .after(FinderSet::UpdateFinder), update_requested_paths - .run_if(in_state(GameState::Playing)) .in_set(PathingSet::UpdateRequestedPaths) .after(PathingSet::UpdateExistingPaths), check_path_results - .run_if(in_state(GameState::Playing)) // This is needed to avoid race condition in PathTarget // removal which would happen if path was not-found before // this system is run. @@ -67,7 +64,8 @@ impl Plugin for PathingPlugin { // that a path is either already scheduled or being // computed. Thus this system must run after it. .after(PathingSet::UpdateExistingPaths), - ), + ) + .run_if(in_state(GameState::Playing)), ) .add_systems( PostMovement, diff --git a/crates/signs/src/bars.rs b/crates/signs/src/bars.rs index c4db799f..b321794c 100644 --- a/crates/signs/src/bars.rs +++ b/crates/signs/src/bars.rs @@ -44,19 +44,16 @@ impl Plugin for BarsPlugin { .add_systems( PostUpdate, ( - spawn.run_if(in_state(AppState::InGame)), - update_value.run_if(in_state(AppState::InGame)), - update_visibility_events - .run_if(in_state(AppState::InGame)) + spawn, + update_value, + ( + update_visibility_events, + update_visibility_distance.after(DistanceSet::Update), + update_visibility_timer, + ) .before(VisibilitySet::Update), - update_visibility_distance - .run_if(in_state(AppState::InGame)) - .before(VisibilitySet::Update) - .after(DistanceSet::Update), - update_visibility_timer - .run_if(in_state(AppState::InGame)) - .before(VisibilitySet::Update), - ), + ) + .run_if(in_state(AppState::InGame)), ); } } diff --git a/crates/signs/src/line.rs b/crates/signs/src/line.rs index 24f6b407..dd591666 100644 --- a/crates/signs/src/line.rs +++ b/crates/signs/src/line.rs @@ -25,24 +25,21 @@ impl Plugin for LinePlugin { PostUpdate, ( update_line_end - .run_if(in_state(AppState::InGame)) .run_if(on_event::()) .in_set(LinesSet::LineEnd), update_line_location - .run_if(in_state(AppState::InGame)) .run_if(on_event::()) .in_set(LinesSet::LocationEvents) .after(LinesSet::LineEnd), update_line_visibility - .run_if(in_state(AppState::InGame)) .run_if(on_event::()) .in_set(LinesSet::VisibilityEvents) .after(LinesSet::LocationEvents), owner_despawn - .run_if(in_state(AppState::InGame)) .in_set(LinesSet::Despawn) .after(LinesSet::VisibilityEvents), - ), + ) + .run_if(in_state(AppState::InGame)), ); } } diff --git a/crates/signs/src/pole.rs b/crates/signs/src/pole.rs index 22db6128..9603ce41 100644 --- a/crates/signs/src/pole.rs +++ b/crates/signs/src/pole.rs @@ -20,18 +20,12 @@ impl Plugin for PolePlugin { .add_systems( PostUpdate, ( - location_events - .run_if(in_state(AppState::InGame)) - .in_set(PolesSet::LocationEvents), - visibility_events - .run_if(in_state(AppState::InGame)) - .in_set(PolesSet::VisibilityEvents), + location_events.in_set(PolesSet::LocationEvents), + visibility_events.in_set(PolesSet::VisibilityEvents), despawned - .run_if(in_state(AppState::InGame)) .in_set(PolesSet::Despawned) .after(PolesSet::LocationEvents), update_poles - .run_if(in_state(AppState::InGame)) .run_if(resource_exists_and_changed::()) .after(PolesSet::LocationEvents) .after(PolesSet::VisibilityEvents) @@ -40,17 +34,13 @@ impl Plugin for PolePlugin { .before(PolesSet::DespawnPoles) .before(PolesSet::MovePoles), spawn_poles - .run_if(in_state(AppState::InGame)) .run_if(on_event::()) .in_set(PolesSet::SpawnPoles) .after(PolesSet::DespawnPoles), - despawn_poles - .run_if(in_state(AppState::InGame)) - .in_set(PolesSet::DespawnPoles), - move_poles - .run_if(in_state(AppState::InGame)) - .before(PolesSet::DespawnPoles), - ), + despawn_poles.in_set(PolesSet::DespawnPoles), + move_poles.before(PolesSet::DespawnPoles), + ) + .run_if(in_state(AppState::InGame)), ); } } diff --git a/crates/spawner/src/draft.rs b/crates/spawner/src/draft.rs index 1d95e7b4..52c24810 100644 --- a/crates/spawner/src/draft.rs +++ b/crates/spawner/src/draft.rs @@ -37,17 +37,9 @@ impl Plugin for DraftPlugin { .add_systems(Update, new_draft.run_if(in_state(GameState::Playing))) .add_systems( PostUpdate, - ( - update_draft - .run_if(in_state(GameState::Playing)) - .after(IndexSet::Index), - check_draft_loaded - .run_if(in_state(GameState::Playing)) - .after(IndexSet::Index), - update_draft_colour - .run_if(in_state(GameState::Playing)) - .after(IndexSet::Index), - ), + (update_draft, check_draft_loaded, update_draft_colour) + .run_if(in_state(GameState::Playing)) + .after(IndexSet::Index), ); } } diff --git a/crates/terrain/src/marker.rs b/crates/terrain/src/marker.rs index d5f5410d..f56fba5a 100644 --- a/crates/terrain/src/marker.rs +++ b/crates/terrain/src/marker.rs @@ -25,13 +25,11 @@ impl Plugin for MarkerPlugin { app.add_systems( PostUpdate, ( - update_markers:: - .run_if(in_state(GameState::Playing)) - .after(VisibilitySystems::CheckVisibility), - update_markers:: - .run_if(in_state(GameState::Playing)) - .after(VisibilitySystems::CheckVisibility), - ), + update_markers::, + update_markers::, + ) + .run_if(in_state(GameState::Playing)) + .after(VisibilitySystems::CheckVisibility), ); } }