mirror of
https://github.com/kristoferssolo/maze-ascension.git
synced 2025-10-21 19:20:34 +00:00
fix: clippy warnings
This commit is contained in:
parent
45511e4d80
commit
b966d38e94
@ -60,6 +60,8 @@ dev_native = [
|
||||
too_many_arguments = "allow"
|
||||
# Queries that access many components may trigger this lint.
|
||||
type_complexity = "allow"
|
||||
nursery = { level = "warn", priority = -1 }
|
||||
unwrap_used = "warn"
|
||||
|
||||
|
||||
# Compile with Performance Optimizations:
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
//! A high-level way to load collections of asset handles as resources.
|
||||
|
||||
use std::collections::VecDeque;
|
||||
|
||||
use bevy::prelude::*;
|
||||
use std::collections::VecDeque;
|
||||
|
||||
pub(super) fn plugin(app: &mut App) {
|
||||
app.init_resource::<ResourceHandles>();
|
||||
@ -51,7 +50,9 @@ fn load_resource_assets(world: &mut World) {
|
||||
world.resource_scope(|world, mut resource_handles: Mut<ResourceHandles>| {
|
||||
world.resource_scope(|world, assets: Mut<AssetServer>| {
|
||||
for _ in 0..resource_handles.waiting.len() {
|
||||
let (handle, insert_fn) = resource_handles.waiting.pop_front().unwrap();
|
||||
let Some((handle, insert_fn)) = resource_handles.waiting.pop_front() else {
|
||||
continue;
|
||||
};
|
||||
if assets.is_loaded_with_dependencies(&handle) {
|
||||
insert_fn(world, &handle);
|
||||
resource_handles.finished.push(handle);
|
||||
|
||||
@ -12,7 +12,7 @@ use hexx::{Hex, HexOrientation};
|
||||
use rand::{thread_rng, Rng};
|
||||
use std::ops::RangeInclusive;
|
||||
|
||||
pub(crate) fn maze_controls_ui(world: &mut World) {
|
||||
pub fn maze_controls_ui(world: &mut World) {
|
||||
if world.get_resource::<MazePluginLoaded>().is_none() {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
mod maze_controls;
|
||||
|
||||
pub(crate) use maze_controls::maze_controls_ui;
|
||||
pub use maze_controls::maze_controls_ui;
|
||||
|
||||
@ -19,7 +19,7 @@ impl Default for Floor {
|
||||
}
|
||||
|
||||
impl Floor {
|
||||
pub fn increased(&self) -> Self {
|
||||
pub const fn increased(&self) -> Self {
|
||||
Self(self.0.saturating_add(1))
|
||||
}
|
||||
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
use bevy::prelude::*;
|
||||
|
||||
pub(super) fn despawn_floor(mut commands: Commands) {}
|
||||
pub const fn despawn_floor(mut _commands: Commands) {}
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
mod asset_tracking;
|
||||
pub mod asset_tracking;
|
||||
pub mod audio;
|
||||
#[cfg(feature = "dev")]
|
||||
mod dev_tools;
|
||||
pub mod dev_tools;
|
||||
pub mod floor;
|
||||
pub mod maze;
|
||||
pub mod player;
|
||||
mod screens;
|
||||
pub mod screens;
|
||||
pub mod theme;
|
||||
|
||||
use bevy::{
|
||||
|
||||
@ -8,26 +8,26 @@ const WALL_OVERLAP_MODIFIER: f32 = 1.25;
|
||||
const HEX_SIDES: u32 = 6;
|
||||
const WHITE_EMISSION_INTENSITY: f32 = 10.;
|
||||
|
||||
pub(crate) struct MazeAssets {
|
||||
pub(crate) hex_mesh: Handle<Mesh>,
|
||||
pub(crate) wall_mesh: Handle<Mesh>,
|
||||
pub(crate) hex_material: Handle<StandardMaterial>,
|
||||
pub(crate) wall_material: Handle<StandardMaterial>,
|
||||
pub(crate) custom_materials: HashMap<String, Handle<StandardMaterial>>,
|
||||
pub struct MazeAssets {
|
||||
pub hex_mesh: Handle<Mesh>,
|
||||
pub wall_mesh: Handle<Mesh>,
|
||||
pub hex_material: Handle<StandardMaterial>,
|
||||
pub wall_material: Handle<StandardMaterial>,
|
||||
pub custom_materials: HashMap<String, Handle<StandardMaterial>>,
|
||||
}
|
||||
|
||||
impl MazeAssets {
|
||||
pub(crate) fn new(
|
||||
pub fn new(
|
||||
meshes: &mut ResMut<Assets<Mesh>>,
|
||||
materials: &mut ResMut<Assets<StandardMaterial>>,
|
||||
global_config: &GlobalMazeConfig,
|
||||
) -> MazeAssets {
|
||||
) -> Self {
|
||||
let mut custom_materials = HashMap::new();
|
||||
custom_materials.extend(vec![
|
||||
("LOVE".to_string(), materials.add(red_material())),
|
||||
("PINE".to_string(), materials.add(blue_material())),
|
||||
]);
|
||||
MazeAssets {
|
||||
Self {
|
||||
hex_mesh: meshes.add(generate_hex_mesh(
|
||||
global_config.hex_size,
|
||||
global_config.height,
|
||||
@ -62,7 +62,7 @@ fn generate_square_mesh(depth: f32, wall_size: f32) -> Mesh {
|
||||
Mesh::from(rectangular_prism).rotated_by(rotation)
|
||||
}
|
||||
|
||||
pub(crate) fn white_material() -> StandardMaterial {
|
||||
pub fn white_material() -> StandardMaterial {
|
||||
StandardMaterial {
|
||||
emissive: LinearRgba::new(
|
||||
WHITE_EMISSION_INTENSITY,
|
||||
@ -74,14 +74,14 @@ pub(crate) fn white_material() -> StandardMaterial {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn red_material() -> StandardMaterial {
|
||||
pub fn red_material() -> StandardMaterial {
|
||||
StandardMaterial {
|
||||
emissive: LOVE.to_linear(),
|
||||
..default()
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn blue_material() -> StandardMaterial {
|
||||
pub fn blue_material() -> StandardMaterial {
|
||||
StandardMaterial {
|
||||
emissive: PINE.to_linear(),
|
||||
..default()
|
||||
|
||||
@ -32,7 +32,7 @@ impl MazeError {
|
||||
Self::ConfigurationError(msg.into())
|
||||
}
|
||||
|
||||
pub fn generation_failed(radius: u32, seed: u64) -> Self {
|
||||
pub const fn generation_failed(radius: u32, seed: u64) -> Self {
|
||||
Self::GenerationFailed { radius, seed }
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
use crate::maze::events::SpawnMaze;
|
||||
use bevy::prelude::*;
|
||||
|
||||
pub(crate) fn setup(mut commands: Commands) {
|
||||
pub fn setup(mut commands: Commands) {
|
||||
commands.trigger(SpawnMaze::default());
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@ use crate::maze::{
|
||||
};
|
||||
use hexlab::{GeneratorType, HexMaze, MazeBuilder};
|
||||
|
||||
pub(crate) fn generate_maze(config: &MazeConfig) -> MazeResult<HexMaze> {
|
||||
pub fn generate_maze(config: &MazeConfig) -> MazeResult<HexMaze> {
|
||||
MazeBuilder::new()
|
||||
.with_radius(config.radius)
|
||||
.with_seed(config.seed)
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
use super::common::generate_maze;
|
||||
use crate::{
|
||||
floor::components::{CurrentFloor, Floor, NextFloor},
|
||||
maze::{
|
||||
@ -12,9 +13,7 @@ use hexlab::prelude::*;
|
||||
use hexx::HexOrientation;
|
||||
use std::f32::consts::{FRAC_PI_2, FRAC_PI_3, FRAC_PI_6};
|
||||
|
||||
use super::common::generate_maze;
|
||||
|
||||
pub(crate) const FLOOR_Y_OFFSET: u8 = 100;
|
||||
pub const FLOOR_Y_OFFSET: u8 = 100;
|
||||
|
||||
pub(super) fn spawn_maze(
|
||||
trigger: Trigger<SpawnMaze>,
|
||||
@ -31,7 +30,7 @@ pub(super) fn spawn_maze(
|
||||
return;
|
||||
}
|
||||
|
||||
let maze = match generate_maze(&config) {
|
||||
let maze = match generate_maze(config) {
|
||||
Ok(m) => m,
|
||||
Err(e) => {
|
||||
error!("Failed to generate maze for floor {floor}: {:?}", e);
|
||||
@ -60,12 +59,12 @@ pub(super) fn spawn_maze(
|
||||
entity,
|
||||
&maze,
|
||||
&assets,
|
||||
&config,
|
||||
config,
|
||||
&global_config,
|
||||
);
|
||||
}
|
||||
|
||||
pub(crate) fn spawn_maze_tiles(
|
||||
pub fn spawn_maze_tiles(
|
||||
commands: &mut Commands,
|
||||
parent_entity: Entity,
|
||||
maze: &HexMaze,
|
||||
@ -98,14 +97,12 @@ pub(super) fn spawn_single_hex_tile(
|
||||
.custom_materials
|
||||
.get("PINE")
|
||||
.cloned()
|
||||
.to_owned()
|
||||
.unwrap(),
|
||||
.unwrap_or_default(),
|
||||
pos if pos == maze_config.end_pos => assets
|
||||
.custom_materials
|
||||
.get("LOVE")
|
||||
.cloned()
|
||||
.to_owned()
|
||||
.unwrap(),
|
||||
.unwrap_or_default(),
|
||||
_ => assets.hex_material.clone(),
|
||||
};
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
use crate::player::events::SpawnPlayer;
|
||||
use bevy::prelude::*;
|
||||
|
||||
pub(crate) fn setup(mut commands: Commands) {
|
||||
pub fn setup(mut commands: Commands) {
|
||||
commands.trigger(SpawnPlayer);
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ fn continue_to_title_screen(mut next_screen: ResMut<NextState<Screen>>) {
|
||||
next_screen.set(Screen::Title);
|
||||
}
|
||||
|
||||
fn all_assets_loaded(
|
||||
const fn all_assets_loaded(
|
||||
interaction_assets: Option<Res<InteractionAssets>>,
|
||||
credits_music: Option<Res<CreditsMusic>>,
|
||||
gameplay_music: Option<Res<GameplayMusic>>,
|
||||
|
||||
@ -101,7 +101,7 @@ impl UiImageFadeInOut {
|
||||
let fade = self.fade_duration / self.total_duration;
|
||||
|
||||
// Regular trapezoid-shaped graph, flat at the top with alpha = 1.0.
|
||||
((1.0 - (2.0 * t - 1.0).abs()) / fade).min(1.0)
|
||||
((1.0 - 2.0f32.mul_add(t, -1.0).abs()) / fade).min(1.0)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user