From 7b6dad0c745cbacf45acf78c2664576e18b4e938 Mon Sep 17 00:00:00 2001 From: Ryan Walters Date: Wed, 10 Sep 2025 11:17:12 -0500 Subject: [PATCH] refactor: remove unused component, simplify visibility check defaulting behavior, reformat STORY.md --- STORY.md | 2 +- src/map/builder.rs | 5 ----- src/systems/ghost.rs | 4 ---- src/systems/render.rs | 2 +- src/systems/state.rs | 6 +++--- 5 files changed, 5 insertions(+), 14 deletions(-) diff --git a/STORY.md b/STORY.md index 94c29b1..35a0e1e 100644 --- a/STORY.md +++ b/STORY.md @@ -412,8 +412,8 @@ The bigger downside was that I had to toss out almost all the existing code for This ended up being okay though, as I was able to clean up a lot of gross code, and the system ended up being easier to work with by comparison. -[code-review-video]: https://www.youtube.com/watch?v=OKs_JewEeOo [code-review-thumbnail]: https://img.youtube.com/vi/OKs_JewEeOo/hqdefault.jpg +[code-review-video]: https://www.youtube.com/watch?v=OKs_JewEeOo [fighting-lifetimes-1]: https://devcry.heiho.net/html/2022/20220709-rust-and-sdl2-fighting-with-lifetimes.html [fighting-lifetimes-2]: https://devcry.heiho.net/html/2022/20220716-rust-and-sdl2-fighting-with-lifetimes-2.html [fighting-lifetimes-3]: https://devcry.heiho.net/html/2022/20220724-rust-and-sdl2-fighting-with-lifetimes-3.html diff --git a/src/map/builder.rs b/src/map/builder.rs index 89e6bef..3c5c24e 100644 --- a/src/map/builder.rs +++ b/src/map/builder.rs @@ -175,11 +175,6 @@ impl Map { remaining_distance: distance / 2.0, }; - tracing::warn!( - fruit_spawn_position = ?fruit_spawn_position, - "Fruit spawn position found" - ); - let start_positions = NodePositions { pacman: grid_to_node[&start_pos], blinky: house_entrance_node_id, diff --git a/src/systems/ghost.rs b/src/systems/ghost.rs index 594fced..8f56239 100644 --- a/src/systems/ghost.rs +++ b/src/systems/ghost.rs @@ -22,10 +22,6 @@ use bevy_ecs::system::{Commands, Query, Res}; use rand::seq::IndexedRandom; use smallvec::SmallVec; -/// Tag component for eaten ghosts -#[derive(Component, Debug, Clone, Copy)] -pub struct Eaten; - /// Tag component for Pac-Man during his death animation. /// This is mainly because the Frozen tag would stop both movement and animation, while the Dying tag can signal that the animation should continue despite being frozen. #[derive(Component, Debug, Clone, Copy)] diff --git a/src/systems/render.rs b/src/systems/render.rs index b9afb31..5f50398 100644 --- a/src/systems/render.rs +++ b/src/systems/render.rs @@ -146,7 +146,7 @@ pub fn render_system( // Collect and filter visible entities, then sort by layer let mut visible_entities: Vec<_> = renderables .iter() - .filter(|(_, _, _, _, visibility)| visibility.map(|v| v.is_visible()).unwrap_or(true)) + .filter(|(_, _, _, _, visibility)| visibility.copied().unwrap_or_default().is_visible()) .collect(); visible_entities.sort_by_key(|(_, renderable, _, _, _)| renderable.layer); diff --git a/src/systems/state.rs b/src/systems/state.rs index 5f35853..5707729 100644 --- a/src/systems/state.rs +++ b/src/systems/state.rs @@ -6,8 +6,8 @@ use crate::systems::SpawnTrigger; use crate::{ map::builder::Map, systems::{ - AudioEvent, Blinking, DirectionalAnimation, Dying, Eaten, Frozen, Ghost, GhostCollider, GhostState, LinearAnimation, - Looping, NodeId, PlayerControlled, Position, Visibility, + AudioEvent, Blinking, DirectionalAnimation, Dying, Frozen, Ghost, GhostCollider, GhostState, LinearAnimation, Looping, + NodeId, PlayerControlled, Position, Visibility, }, }; use bevy_ecs::{ @@ -296,7 +296,7 @@ pub fn stage_system( }; commands .entity(ghost_entity) - .remove::<(Frozen, Eaten)>() + .remove::() .insert((Visibility::visible(), GhostState::Normal)); } }