Skip to content

Commit b684920

Browse files
committed
Rustfmt the whole thing
1 parent 94f6606 commit b684920

File tree

6 files changed

+32
-17
lines changed

6 files changed

+32
-17
lines changed

src/cell.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,10 @@ impl CellCoordinates {
145145
radial_direction: RadialDirection,
146146
cube_side_length: u32,
147147
) -> Option<(CellCoordinates, bool)> {
148-
if radial_direction.rotation_axis().is_parallel_to(self.normal_direction()) {
148+
if radial_direction
149+
.rotation_axis()
150+
.is_parallel_to(self.normal_direction())
151+
{
149152
// The direction is not possible to go in on this side
150153
return None;
151154
}
@@ -164,7 +167,9 @@ impl CellCoordinates {
164167
cube_side_length: u32,
165168
) -> Option<(CellCoordinates, bool)> {
166169
let cell1 = self.get_cell_in_direction(diagonal.0, cube_side_length)?;
167-
let cell2 = cell1.0.get_cell_in_direction(diagonal.1, cube_side_length)?;
170+
let cell2 = cell1
171+
.0
172+
.get_cell_in_direction(diagonal.1, cube_side_length)?;
168173
if cell1.1 && cell2.1 {
169174
// The second element tells us if the transformation went over a cube edge, in this
170175
// case we are in a corner, which means we have a true neighbor in cell2

src/cube_rotation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use std::time::{Duration, Instant};
44
use bevy::prelude::*;
55
use derivative::Derivative;
66

7-
use crate::MainCamera;
87
use crate::utils::{CartesianDirection, SeeDirection};
8+
use crate::MainCamera;
99

1010
#[derive(Debug, Default, Clone)]
1111
pub(crate) struct RotationData {

src/gamemanager.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,9 @@ fn on_cell_clicked_play_phase(
182182

183183
// Mark cells
184184
reset_cells_new_selection(game);
185-
let Some(unit) = game.units.get_unit(clicked_coords) else { return;};
185+
let Some(unit) = game.units.get_unit(clicked_coords) else {
186+
return;
187+
};
186188
if unit.team != game.turn {
187189
return;
188190
}
@@ -223,13 +225,18 @@ pub(crate) fn make_move(game_move: GameMove, game: &mut Game, commands: &mut Com
223225
game.units.remove_dead_units();
224226
}
225227

226-
let Some(unit) = game.units.get_unit_mut(game_move.from) else {return false};
228+
let Some(unit) = game.units.get_unit_mut(game_move.from) else {
229+
return false;
230+
};
227231
if unit.team != game.turn {
228232
return false;
229233
}
230234

231235
unit.move_unit_to(game_move.to);
232-
let Some(entity) = unit.entity else {warn!("Unit entity was None");return false;};
236+
let Some(entity) = unit.entity else {
237+
warn!("Unit entity was None");
238+
return false;
239+
};
233240
game.entities_to_move.push((entity, game_move.to));
234241
if let UnitType::Pawn(_, ref mut has_moved) = unit.unit_type {
235242
*has_moved = true;

src/main.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ fn main() {
3939
}
4040

4141
#[derive(Component)]
42-
struct MainCamera {
43-
}
42+
struct MainCamera {}
4443

4544
fn setup(
4645
mut commands: Commands,
@@ -73,8 +72,7 @@ fn setup(
7372
transform: Transform::from_xyz(8., 8., 8.),
7473
..default()
7574
},
76-
MainCamera {
77-
},
75+
MainCamera {},
7876
));
7977

8078
commands.spawn((
@@ -83,7 +81,6 @@ fn setup(
8381
..default()
8482
},
8583
RaycastPickCamera::default(), // Enable picking with this camera
86-
MainCamera {
87-
},
84+
MainCamera {},
8885
));
8986
}

src/movement.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use bevy::prelude::error;
22

33
use crate::cell::{Board, CellCoordinates};
4-
54
use crate::units::*;
65
use crate::utils::{CartesianDirection, RadialDirection};
76

@@ -134,7 +133,8 @@ fn pawn_movement(
134133
.iter()
135134
.filter(|diag| diag.0 == forward || diag.1 == forward)
136135
{
137-
let Some(diagonal_coords) = unit_coords.get_diagonal(diagonal, board.cube_side_length) else {
136+
let Some(diagonal_coords) = unit_coords.get_diagonal(diagonal, board.cube_side_length)
137+
else {
138138
continue;
139139
};
140140

@@ -236,7 +236,9 @@ mod parts {
236236
let mut dist = 0;
237237
let mut edge_crossings = 0;
238238
loop {
239-
let Some(next_cell) = latest_cell.get_diagonal(diagonal, cube_side_length) else {break;};
239+
let Some(next_cell) = latest_cell.get_diagonal(diagonal, cube_side_length) else {
240+
break;
241+
};
240242

241243
if output.iter().any(|cell| *cell == next_cell.0) {
242244
break;
@@ -270,7 +272,11 @@ mod parts {
270272
) -> Vec<CellCoordinates> {
271273
let mut output = Vec::new();
272274
for radial_direction in RadialDirection::directions() {
273-
let Some(mut forward_two) = coords.get_cell_in_radial_direction(radial_direction, cube_side_length) else {continue;};
275+
let Some(mut forward_two) =
276+
coords.get_cell_in_radial_direction(radial_direction, cube_side_length)
277+
else {
278+
continue;
279+
};
274280
let mut edge_crossings = 0;
275281

276282
if forward_two.1 {

src/units.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ impl Units {
180180
}
181181

182182
pub(crate) fn remove_unit(&mut self, coords: CellCoordinates) -> Option<Unit> {
183-
let index = self.units.iter().position(|unit| unit.coords==coords)?;
183+
let index = self.units.iter().position(|unit| unit.coords == coords)?;
184184

185185
Some(self.units.swap_remove(index))
186186
}

0 commit comments

Comments
 (0)