fix: warnings

This commit is contained in:
Kristofers Solo 2024-11-04 20:37:25 +02:00
parent 1aa1bd1c41
commit 8f454cb2c6
6 changed files with 22 additions and 26 deletions

2
Cargo.lock generated
View File

@ -3918,7 +3918,7 @@ dependencies = [
[[package]] [[package]]
name = "the-labyrinth-of-echoes" name = "the-labyrinth-of-echoes"
version = "0.0.3" version = "0.0.4"
dependencies = [ dependencies = [
"bevy", "bevy",
"bevy-inspector-egui", "bevy-inspector-egui",

View File

@ -63,7 +63,7 @@ impl Plugin for AppPlugin {
#[cfg(feature = "demo")] #[cfg(feature = "demo")]
demo::plugin, demo::plugin,
#[cfg(not(feature = "demo"))] #[cfg(not(feature = "demo"))]
maze::plugin::MazePlugin::default(), maze::plugin::MazePlugin,
screens::plugin, screens::plugin,
theme::plugin, theme::plugin,
)); ));

View File

@ -1,10 +1,7 @@
use std::usize;
use bevy::{ use bevy::{
color::palettes::css::{BLACK, GREEN, RED, SILVER}, color::palettes::css::{BLACK, GREEN, RED},
pbr::wireframe::{Wireframe, WireframeConfig, WireframePlugin}, pbr::wireframe::{WireframeConfig, WireframePlugin},
prelude::*, prelude::*,
render::{mesh::PrimitiveTopology, render_asset::RenderAssetUsages},
utils::hashbrown::HashMap, utils::hashbrown::HashMap,
}; };
use bevy_prototype_lyon::{ 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<MazeConfig>) { pub(super) fn _spawn_hex_grid(mut commands: Commands, config: Res<MazeConfig>) {
let radius = config.radius as i32; let radius = config.radius as i32;
for q in -radius..=radius { for q in -radius..=radius {
@ -50,7 +47,7 @@ pub(super) fn spawn_hex_grid(mut commands: Commands, config: Res<MazeConfig>) {
} }
} }
pub(super) fn generate_maze( pub(super) fn _generate_maze(
mut commands: Commands, mut commands: Commands,
query: Query<(Entity, &Tile, &Walls)>, query: Query<(Entity, &Tile, &Walls)>,
config: Res<MazeConfig>, config: Res<MazeConfig>,
@ -61,7 +58,7 @@ pub(super) fn generate_maze(
.collect(); .collect();
let mut rng = thread_rng(); 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() { for (entity, tile, walls) in tiles.values() {
commands commands
@ -71,14 +68,14 @@ pub(super) fn generate_maze(
} }
} }
fn recursive_maze( fn _recursive_maze(
tiles: &mut HashMap<Hex, (Entity, Tile, Walls)>, tiles: &mut HashMap<Hex, (Entity, Tile, Walls)>,
current_hex: Hex, current_hex: Hex,
rng: &mut ThreadRng, rng: &mut ThreadRng,
) { ) {
{ {
let (_, tile, _) = tiles.get_mut(&current_hex).unwrap(); let (_, tile, _) = tiles.get_mut(&current_hex).unwrap();
tile.visit(); tile._visit();
} }
let mut directions = EdgeDirection::ALL_DIRECTIONS; let mut directions = EdgeDirection::ALL_DIRECTIONS;
@ -88,14 +85,14 @@ fn recursive_maze(
let neighbor_hex = current_hex + direction; let neighbor_hex = current_hex + direction;
if let Some((_, neighbor_tile, _)) = tiles.get(&neighbor_hex) { if let Some((_, neighbor_tile, _)) = tiles.get(&neighbor_hex) {
if !neighbor_tile.visited { if !neighbor_tile.visited {
remove_wall_between(tiles, current_hex, neighbor_hex, direction); _remove_wall_between(tiles, current_hex, neighbor_hex, direction);
recursive_maze(tiles, neighbor_hex, rng); _recursive_maze(tiles, neighbor_hex, rng);
} }
} }
} }
} }
fn remove_wall_between( fn _remove_wall_between(
tiles: &mut HashMap<Hex, (Entity, Tile, Walls)>, tiles: &mut HashMap<Hex, (Entity, Tile, Walls)>,
current_hex: Hex, current_hex: Hex,
neighbor_hex: Hex, neighbor_hex: Hex,
@ -111,7 +108,7 @@ fn remove_wall_between(
} }
} }
fn add_hex_tile( fn _add_hex_tile(
commands: &mut Commands, commands: &mut Commands,
position: Vec3, position: Vec3,
size: f32, size: f32,
@ -197,7 +194,7 @@ fn add_hex_tile(
} }
} }
pub(super) fn render_maze( pub(super) fn _render_maze(
mut commands: Commands, mut commands: Commands,
query: Query<(&Tile, &mut Walls)>, query: Query<(&Tile, &mut Walls)>,
layout: Res<Layout>, layout: Res<Layout>,
@ -210,7 +207,7 @@ pub(super) fn render_maze(
pos if pos == config.end_pos => RED.into(), pos if pos == config.end_pos => RED.into(),
_ => Color::srgb(0.8, 0.8, 0.8), _ => Color::srgb(0.8, 0.8, 0.8),
}; };
add_hex_tile( _add_hex_tile(
&mut commands, &mut commands,
world_pos, world_pos,
HEX_SIZE, HEX_SIZE,

View File

@ -7,5 +7,5 @@ pub mod resource;
pub mod tile; pub mod tile;
pub fn spawn_grid(world: &mut World) { pub fn spawn_grid(world: &mut World) {
MazePlugin::default().apply(world); MazePlugin.apply(world);
} }

View File

@ -1,7 +1,6 @@
use bevy::{pbr::UvChannel, prelude::*}; use bevy::prelude::*;
use core::f32; use core::f32;
use hexx::{EdgeDirection, GridEdge, Hex}; use std::f32::consts::{FRAC_PI_2, FRAC_PI_3};
use std::f32::consts::{FRAC_PI_2, FRAC_PI_3, FRAC_PI_6};
use super::{ use super::{
resource::{Layout, MazeConfig, HEX_SIZE}, resource::{Layout, MazeConfig, HEX_SIZE},
@ -30,13 +29,13 @@ pub(super) fn setup(
..default() ..default()
}, },
)) ))
.with_children(|mut parent| { .with_children(|parent| {
for q in -radius..=radius { for q in -radius..=radius {
let r1 = (-radius).max(-q - radius); let r1 = (-radius).max(-q - radius);
let r2 = radius.min(-q + radius); let r2 = radius.min(-q + radius);
for r in r1..=r2 { for r in r1..=r2 {
let tile = Tile::new(q, r); 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, assets: &MazeAssets,
config: &Res<MazeConfig>, config: &Res<MazeConfig>,
) { ) {
let pos = tile.to_vec3(&layout); let pos = tile.to_vec3(layout);
parent parent
.spawn(( .spawn((
Name::new(format!("Hex {}", &tile.to_string())), Name::new(format!("Hex {}", &tile.to_string())),

View File

@ -28,7 +28,7 @@ impl Tile {
} }
} }
pub fn visit(&mut self) { pub fn _visit(&mut self) {
self.visited = true; self.visited = true;
} }