From 0e2308929cd97d481b788623de7e819ba2e609ed Mon Sep 17 00:00:00 2001 From: "Elijah C. Voigt" Date: Sat, 3 Feb 2024 22:27:49 -0800 Subject: [PATCH] cargo fmt --- src/display3d.rs | 8 +++----- src/game.rs | 44 ++++++++++++++++++++------------------------ 2 files changed, 23 insertions(+), 29 deletions(-) diff --git a/src/display3d.rs b/src/display3d.rs index 891c20a..179e8da 100644 --- a/src/display3d.rs +++ b/src/display3d.rs @@ -748,10 +748,7 @@ fn select( meshes: Res>, cameras: Query<(&Camera, &GlobalTransform)>, windows: Query<&Window, With>, - selectable: Query< - (Entity, &BoardIndex, &Side), - (With, With), - >, + selectable: Query<(Entity, &BoardIndex, &Side), (With, With)>, selected: Query>, children: Query<&Children>, mut selections: EventWriter, @@ -777,7 +774,8 @@ fn select( .find_map(|(e, &board_index, &side)| { // Check the side of the selection if no piece is selected // Otherwise this is fine, select away - let side_check = !selected.is_empty() || *state.get() == side; + let side_check = + !selected.is_empty() || *state.get() == side; let hit_check = { // This entity was hit (tile hitboxes) diff --git a/src/game.rs b/src/game.rs index 34c55c6..cfd12fe 100644 --- a/src/game.rs +++ b/src/game.rs @@ -208,7 +208,7 @@ pub(crate) struct BoardIndex { #[derive(Debug, Component, PartialEq, Clone, Default, Copy, Eq, Hash)] pub(crate) struct Previous { - board_index: BoardIndex + board_index: BoardIndex, } #[derive(Debug, Component, PartialEq, Clone, Copy)] @@ -240,21 +240,27 @@ impl Board { match side { Side::A => { // X: 0..3, Y: 0..3 - (0..=3).flat_map(|x| { - (0..=3).map(move |y| { - self.at(BoardIndex { x, y }).map(|p| (p, BoardIndex { x, y })) + (0..=3) + .flat_map(|x| { + (0..=3).map(move |y| { + self.at(BoardIndex { x, y }) + .map(|p| (p, BoardIndex { x, y })) + }) }) - }).filter_map(|r| r) - .collect() + .filter_map(|r| r) + .collect() } Side::B => { // X: 4..7, Y: 0..3 - (4..=7).flat_map(|x| { - (0..=3).map(move |y| { - self.at(BoardIndex { x, y }).map(|p| (p, BoardIndex { x, y })) + (4..=7) + .flat_map(|x| { + (0..=3).map(move |y| { + self.at(BoardIndex { x, y }) + .map(|p| (p, BoardIndex { x, y })) + }) }) - }).filter_map(|r| r) - .collect() + .filter_map(|r| r) + .collect() } } } @@ -582,20 +588,14 @@ fn track_previous_move( #[derive(Debug, Component)] struct Endgame; -fn check_endgame( - board: Res, - mut next_state: ResMut>, -) { +fn check_endgame(board: Res, mut next_state: ResMut>) { if board.on(Side::A).is_empty() || board.on(Side::B).is_empty() { warn!("The game is over!"); next_state.set(GameState::Endgame); } } -fn set_endgame( - score: Res, - mut commands: Commands, -) { +fn set_endgame(score: Res, mut commands: Commands) { commands .spawn(( Endgame, @@ -642,10 +642,7 @@ fn set_endgame( }); } -fn clear_endgame( - query: Query>, - mut commands: Commands, -) { +fn clear_endgame(query: Query>, mut commands: Commands) { query.iter().for_each(|e| { commands.entity(e).despawn_recursive(); }) @@ -695,7 +692,6 @@ fn handle_selection( mut latest: Local>, // Tracks the last one worked on ) { selections.read().for_each(|Selection(index)| { - // Skip indexes already processed if Some(*index) != *latest { // Set the latest index to the current index