cargo fmt

main
Elijah C. Voigt 2 years ago
parent 18f3797340
commit 0e2308929c

@ -748,10 +748,7 @@ fn select(
meshes: Res<Assets<Mesh>>,
cameras: Query<(&Camera, &GlobalTransform)>,
windows: Query<&Window, With<PrimaryWindow>>,
selectable: Query<
(Entity, &BoardIndex, &Side),
(With<game::Selectable>, With<Display3d>),
>,
selectable: Query<(Entity, &BoardIndex, &Side), (With<game::Selectable>, With<Display3d>)>,
selected: Query<Entity, With<game::Selected>>,
children: Query<&Children>,
mut selections: EventWriter<game::Selection>,
@ -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)

@ -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<Board>,
mut next_state: ResMut<NextState<GameState>>,
) {
fn check_endgame(board: Res<Board>, mut next_state: ResMut<NextState<GameState>>) {
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<Score>,
mut commands: Commands,
) {
fn set_endgame(score: Res<Score>, mut commands: Commands) {
commands
.spawn((
Endgame,
@ -642,10 +642,7 @@ fn set_endgame(
});
}
fn clear_endgame(
query: Query<Entity, With<Endgame>>,
mut commands: Commands,
) {
fn clear_endgame(query: Query<Entity, With<Endgame>>, mut commands: Commands) {
query.iter().for_each(|e| {
commands.entity(e).despawn_recursive();
})
@ -695,7 +692,6 @@ fn handle_selection(
mut latest: Local<Option<BoardIndex>>, // 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

Loading…
Cancel
Save