Skip to content

Commit 85ea78a

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

File tree

9 files changed

+50
-33
lines changed

9 files changed

+50
-33
lines changed

src/ai.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
use crate::{cell::*, movement};
12
use crate::gamemanager::*;
23
use crate::movement::*;
34
use crate::units::*;
4-
use crate::{cell::*, movement};
55

66
#[derive(Default)]
77
pub(crate) struct AICache {

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: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
use crate::ai::AICache;
2-
use crate::movement::GameMove;
3-
use crate::{ai, movement, units::*};
1+
use bevy::prelude::*;
2+
use bevy_mod_picking::prelude::*;
43

4+
use crate::{ai, movement, units::*};
5+
use crate::ai::AICache;
56
use crate::cell::*;
7+
use crate::movement::GameMove;
68
use crate::scene::{self, MainCube, SceneChild};
7-
use bevy::prelude::*;
8-
use bevy_mod_picking::prelude::*;
99

1010
#[derive(Resource, Debug)]
1111
pub(crate) struct Game {
@@ -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: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
use bevy::log::*;
2+
use bevy::prelude::*;
3+
use bevy_mod_picking::prelude::*;
4+
15
mod ai;
26
mod cell;
37
mod cube_rotation;
@@ -8,10 +12,6 @@ mod scene;
812
mod units;
913
mod utils;
1014

11-
use bevy::log::*;
12-
use bevy::prelude::*;
13-
use bevy_mod_picking::prelude::*;
14-
1515
fn main() {
1616
App::new()
1717
.add_plugins(
@@ -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/materials.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
use bevy::prelude::*;
2+
13
use crate::cell::CellColor;
24
use crate::gamemanager::Palette;
3-
use bevy::prelude::*;
45

56
pub(crate) fn select_cell_material(
67
material: &mut StandardMaterial,

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/scene.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
use bevy::prelude::*;
2-
use bevy::scene::SceneInstance;
3-
use bevy_mod_picking::prelude::*;
41
use std::f32::consts::PI;
52

3+
use bevy::prelude::*;
64
use bevy::prelude::Vec3;
5+
use bevy::scene::SceneInstance;
6+
use bevy_mod_picking::prelude::*;
77

88
use crate::cell::{Cell, CellColor, CellCoordinates};
9-
use crate::gamemanager::{self, spawn_unit_entity, Game};
9+
use crate::gamemanager::{self, Game, spawn_unit_entity};
1010
use crate::materials;
1111

1212
pub(crate) fn construct_cube(

src/units.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
use std::slice::{Iter, IterMut};
22

3+
use bevy::prelude::*;
4+
35
use crate::cell::CellCoordinates;
46
use crate::gamemanager::Team;
57
use crate::utils::RadialDirection;
6-
use bevy::prelude::*;
78

89
#[derive(Clone, Debug)]
910
pub(crate) struct Unit {
@@ -180,7 +181,7 @@ impl Units {
180181
}
181182

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

185186
Some(self.units.swap_remove(index))
186187
}

0 commit comments

Comments
 (0)