From 8f454cb2c6284a0700b95014594a0e582bf631f3 Mon Sep 17 00:00:00 2001 From: Kristofers Solo Date: Mon, 4 Nov 2024 20:37:25 +0200 Subject: [PATCH] fix: warnings --- Cargo.lock | 2 +- src/lib.rs | 2 +- src/maze/grid.rs | 29 +++++++++++++---------------- src/maze/mod.rs | 2 +- src/maze/prism.rs | 11 +++++------ src/maze/tile.rs | 2 +- 6 files changed, 22 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5c39b4e..b5c5dcc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3918,7 +3918,7 @@ dependencies = [ [[package]] name = "the-labyrinth-of-echoes" -version = "0.0.3" +version = "0.0.4" dependencies = [ "bevy", "bevy-inspector-egui", diff --git a/src/lib.rs b/src/lib.rs index f1e343c..be714f8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -63,7 +63,7 @@ impl Plugin for AppPlugin { #[cfg(feature = "demo")] demo::plugin, #[cfg(not(feature = "demo"))] - maze::plugin::MazePlugin::default(), + maze::plugin::MazePlugin, screens::plugin, theme::plugin, )); diff --git a/src/maze/grid.rs b/src/maze/grid.rs index bc4bc78..babf67b 100644 --- a/src/maze/grid.rs +++ b/src/maze/grid.rs @@ -1,10 +1,7 @@ -use std::usize; - use bevy::{ - color::palettes::css::{BLACK, GREEN, RED, SILVER}, - pbr::wireframe::{Wireframe, WireframeConfig, WireframePlugin}, + color::palettes::css::{BLACK, GREEN, RED}, + pbr::wireframe::{WireframeConfig, WireframePlugin}, prelude::*, - render::{mesh::PrimitiveTopology, render_asset::RenderAssetUsages}, utils::hashbrown::HashMap, }; use bevy_prototype_lyon::{ @@ -31,7 +28,7 @@ pub(super) fn plugin(app: &mut App) { }); } -pub(super) fn spawn_hex_grid(mut commands: Commands, config: Res) { +pub(super) fn _spawn_hex_grid(mut commands: Commands, config: Res) { let radius = config.radius as i32; for q in -radius..=radius { @@ -50,7 +47,7 @@ pub(super) fn spawn_hex_grid(mut commands: Commands, config: Res) { } } -pub(super) fn generate_maze( +pub(super) fn _generate_maze( mut commands: Commands, query: Query<(Entity, &Tile, &Walls)>, config: Res, @@ -61,7 +58,7 @@ pub(super) fn generate_maze( .collect(); let mut rng = thread_rng(); - recursive_maze(&mut tiles, config.start_pos, &mut rng); + _recursive_maze(&mut tiles, config.start_pos, &mut rng); for (entity, tile, walls) in tiles.values() { commands @@ -71,14 +68,14 @@ pub(super) fn generate_maze( } } -fn recursive_maze( +fn _recursive_maze( tiles: &mut HashMap, current_hex: Hex, rng: &mut ThreadRng, ) { { let (_, tile, _) = tiles.get_mut(¤t_hex).unwrap(); - tile.visit(); + tile._visit(); } let mut directions = EdgeDirection::ALL_DIRECTIONS; @@ -88,14 +85,14 @@ fn recursive_maze( let neighbor_hex = current_hex + direction; if let Some((_, neighbor_tile, _)) = tiles.get(&neighbor_hex) { if !neighbor_tile.visited { - remove_wall_between(tiles, current_hex, neighbor_hex, direction); - recursive_maze(tiles, neighbor_hex, rng); + _remove_wall_between(tiles, current_hex, neighbor_hex, direction); + _recursive_maze(tiles, neighbor_hex, rng); } } } } -fn remove_wall_between( +fn _remove_wall_between( tiles: &mut HashMap, current_hex: Hex, neighbor_hex: Hex, @@ -111,7 +108,7 @@ fn remove_wall_between( } } -fn add_hex_tile( +fn _add_hex_tile( commands: &mut Commands, position: Vec3, size: f32, @@ -197,7 +194,7 @@ fn add_hex_tile( } } -pub(super) fn render_maze( +pub(super) fn _render_maze( mut commands: Commands, query: Query<(&Tile, &mut Walls)>, layout: Res, @@ -210,7 +207,7 @@ pub(super) fn render_maze( pos if pos == config.end_pos => RED.into(), _ => Color::srgb(0.8, 0.8, 0.8), }; - add_hex_tile( + _add_hex_tile( &mut commands, world_pos, HEX_SIZE, diff --git a/src/maze/mod.rs b/src/maze/mod.rs index 31264df..c3266d1 100644 --- a/src/maze/mod.rs +++ b/src/maze/mod.rs @@ -7,5 +7,5 @@ pub mod resource; pub mod tile; pub fn spawn_grid(world: &mut World) { - MazePlugin::default().apply(world); + MazePlugin.apply(world); } diff --git a/src/maze/prism.rs b/src/maze/prism.rs index c6d649c..0310a0a 100644 --- a/src/maze/prism.rs +++ b/src/maze/prism.rs @@ -1,7 +1,6 @@ -use bevy::{pbr::UvChannel, prelude::*}; +use bevy::prelude::*; use core::f32; -use hexx::{EdgeDirection, GridEdge, Hex}; -use std::f32::consts::{FRAC_PI_2, FRAC_PI_3, FRAC_PI_6}; +use std::f32::consts::{FRAC_PI_2, FRAC_PI_3}; use super::{ resource::{Layout, MazeConfig, HEX_SIZE}, @@ -30,13 +29,13 @@ pub(super) fn setup( ..default() }, )) - .with_children(|mut parent| { + .with_children(|parent| { for q in -radius..=radius { let r1 = (-radius).max(-q - radius); let r2 = radius.min(-q + radius); for r in r1..=r2 { let tile = Tile::new(q, r); - spawn_single_hex_tile(&mut parent, &tile, &layout, &assets, &config); + spawn_single_hex_tile(parent, &tile, &layout, &assets, &config); } } }); @@ -49,7 +48,7 @@ fn spawn_single_hex_tile( assets: &MazeAssets, config: &Res, ) { - let pos = tile.to_vec3(&layout); + let pos = tile.to_vec3(layout); parent .spawn(( Name::new(format!("Hex {}", &tile.to_string())), diff --git a/src/maze/tile.rs b/src/maze/tile.rs index 0548edc..7c75af7 100644 --- a/src/maze/tile.rs +++ b/src/maze/tile.rs @@ -28,7 +28,7 @@ impl Tile { } } - pub fn visit(&mut self) { + pub fn _visit(&mut self) { self.visited = true; }