chore: fix clippy lints part 972

This commit is contained in:
Ryan Walters
2025-09-08 23:31:20 -05:00
parent 088c496ad9
commit b4990af109
2 changed files with 40 additions and 31 deletions

View File

@@ -32,6 +32,7 @@ pub fn can_traverse(entity_type: EntityType, edge: Edge) -> bool {
/// toggling, audio muting, and game exit requests. Movement commands are buffered
/// to allow direction changes before reaching intersections, improving gameplay
/// responsiveness. Non-movement commands immediately modify global game state.
#[allow(clippy::type_complexity)]
pub fn player_control_system(
mut events: EventReader<GameEvent>,
mut state: ResMut<GlobalState>,

View File

@@ -23,6 +23,7 @@ use sdl2::pixels::Color;
use sdl2::rect::{Point, Rect};
use sdl2::render::{BlendMode, Canvas, Texture};
use sdl2::video::Window;
use std::cmp::Ordering;
use std::time::Instant;
/// A component for entities that have a sprite, with a layer for ordering.
@@ -83,8 +84,11 @@ pub fn player_life_sprite_system(
// Calculate the difference
let diff = (displayed_lives as i8) - (current_count as i8);
if diff > 0 {
match diff.cmp(&0) {
// Ignore when the number of lives displayed is correct
Ordering::Equal => {}
// Spawn new life sprites
Ordering::Greater => {
let life_sprite = match atlas.get_tile(&GameSprite::Pacman(PacmanSprite::Moving(Direction::Left, 1)).to_path()) {
Ok(sprite) => sprite,
Err(e) => {
@@ -93,7 +97,7 @@ pub fn player_life_sprite_system(
}
};
for i in 0..diff.abs() {
for i in 0..diff {
let position = calculate_life_sprite_position(i as u32);
commands.spawn((
@@ -107,9 +111,10 @@ pub fn player_life_sprite_system(
},
));
}
} else if diff < 0 {
}
// Remove excess life sprites (highest indices first)
let to_remove = diff.abs() as usize;
Ordering::Less => {
let to_remove = diff.unsigned_abs();
let sprites_to_remove: Vec<_> = current_sprites
.iter()
.rev() // Start from highest index
@@ -122,6 +127,7 @@ pub fn player_life_sprite_system(
}
}
}
}
/// Component for Renderables to store an exact pixel position
#[derive(Component)]
@@ -297,6 +303,7 @@ pub fn hud_render_system(
}
#[allow(clippy::too_many_arguments)]
#[allow(clippy::type_complexity)]
pub fn render_system(
canvas: &mut Canvas<Window>,
map_texture: &NonSendMut<MapTextureResource>,
@@ -362,6 +369,7 @@ pub fn render_system(
/// Combined render system that renders to both backbuffer and debug textures in a single
/// with_multiple_texture_canvas call for reduced overhead
#[allow(clippy::too_many_arguments)]
#[allow(clippy::type_complexity)]
pub fn combined_render_system(
mut canvas: NonSendMut<&mut Canvas<Window>>,
map_texture: NonSendMut<MapTextureResource>,