chore: remove LevelTiming resource

This commit is contained in:
Ryan Walters
2025-08-28 13:21:21 -05:00
parent d3e83262db
commit 633d467f2c
3 changed files with 5 additions and 44 deletions
+3 -12
View File
@@ -18,8 +18,8 @@ use crate::systems::{
ghost_movement_system, hud_render_system, item_system, profile, ready_visibility_system, render_system, AudioEvent, ghost_movement_system, hud_render_system, item_system, profile, ready_visibility_system, render_system, AudioEvent,
AudioResource, AudioState, BackbufferResource, Collider, DebugFontResource, DebugState, DebugTextureResource, DeltaTime, AudioResource, AudioState, BackbufferResource, Collider, DebugFontResource, DebugState, DebugTextureResource, DeltaTime,
DirectionalAnimated, EntityType, Frozen, Ghost, GhostBundle, GhostCollider, GlobalState, ItemBundle, ItemCollider, DirectionalAnimated, EntityType, Frozen, Ghost, GhostBundle, GhostCollider, GlobalState, ItemBundle, ItemCollider,
LevelTiming, MapTextureResource, PacmanCollider, PlayerBundle, PlayerControlled, PlayerStateBundle, Renderable, MapTextureResource, PacmanCollider, PlayerBundle, PlayerControlled, PlayerStateBundle, Renderable, ScoreResource,
ScoreResource, StartupSequence, SystemTimings, StartupSequence, SystemTimings,
}; };
use crate::texture::animated::AnimatedTexture; use crate::texture::animated::AnimatedTexture;
use bevy_ecs::event::EventRegistry; use bevy_ecs::event::EventRegistry;
@@ -227,7 +227,6 @@ impl Game {
world.insert_resource(DebugState::default()); world.insert_resource(DebugState::default());
world.insert_resource(AudioState::default()); world.insert_resource(AudioState::default());
world.insert_resource(CursorPosition::default()); world.insert_resource(CursorPosition::default());
world.insert_resource(LevelTiming::for_level(1));
world.add_observer( world.add_observer(
|event: Trigger<GameEvent>, mut state: ResMut<GlobalState>, _score: ResMut<ScoreResource>| { |event: Trigger<GameEvent>, mut state: ResMut<GlobalState>, _score: ResMut<ScoreResource>| {
@@ -295,15 +294,7 @@ impl Game {
.chain(), .chain(),
)); ));
// Initialize StartupSequence as a global resource world.insert_resource(StartupSequence::new(60 * 3, 60));
let ready_duration_ticks = {
let duration = world
.get_resource::<LevelTiming>()
.map(|t| t.spawn_freeze_duration)
.unwrap_or(1.5);
(duration * 60.0) as u32 // Convert to ticks at 60 FPS
};
world.insert_resource(StartupSequence::new(ready_duration_ticks, 60));
// Spawn ghosts // Spawn ghosts
Self::spawn_ghosts(&mut world)?; Self::spawn_ghosts(&mut world)?;
-29
View File
@@ -141,35 +141,6 @@ impl Default for MovementModifiers {
} }
} }
/// Level-dependent timing configuration
#[derive(Resource, Debug, Clone, Copy)]
pub struct LevelTiming {
/// Duration of energizer effect in seconds
pub energizer_duration: f32,
/// Freeze duration at spawn/ready in seconds
pub spawn_freeze_duration: f32,
/// When to start flashing relative to energizer end (seconds)
pub energizer_flash_threshold: f32,
}
impl Default for LevelTiming {
fn default() -> Self {
Self {
energizer_duration: 6.0,
spawn_freeze_duration: 1.5,
energizer_flash_threshold: 2.0,
}
}
}
impl LevelTiming {
/// Returns timing configuration for a given level.
pub fn for_level(_level: u32) -> Self {
// Placeholder: tune per the Pac-Man Dossier tables
Self::default()
}
}
/// Tag component for entities that should be frozen during startup /// Tag component for entities that should be frozen during startup
#[derive(Component, Debug, Clone, Copy)] #[derive(Component, Debug, Clone, Copy)]
pub struct Frozen; pub struct Frozen;
+2 -3
View File
@@ -7,7 +7,7 @@ use bevy_ecs::{
use crate::{ use crate::{
events::GameEvent, events::GameEvent,
systems::{AudioEvent, EntityType, GhostCollider, ItemCollider, LevelTiming, PacmanCollider, ScoreResource, Vulnerable}, systems::{AudioEvent, EntityType, GhostCollider, ItemCollider, PacmanCollider, ScoreResource, Vulnerable},
}; };
/// Determines if a collision between two entity types should be handled by the item system. /// Determines if a collision between two entity types should be handled by the item system.
@@ -29,7 +29,6 @@ pub fn item_system(
item_query: Query<(Entity, &EntityType), With<ItemCollider>>, item_query: Query<(Entity, &EntityType), With<ItemCollider>>,
ghost_query: Query<Entity, With<GhostCollider>>, ghost_query: Query<Entity, With<GhostCollider>>,
mut events: EventWriter<AudioEvent>, mut events: EventWriter<AudioEvent>,
level_timing: Res<LevelTiming>,
) { ) {
for event in collision_events.read() { for event in collision_events.read() {
if let GameEvent::Collision(entity1, entity2) = event { if let GameEvent::Collision(entity1, entity2) = event {
@@ -58,7 +57,7 @@ pub fn item_system(
// Make ghosts vulnerable when power pellet is collected // Make ghosts vulnerable when power pellet is collected
if *entity_type == EntityType::PowerPellet { if *entity_type == EntityType::PowerPellet {
// Convert seconds to frames (assumes 60 FPS) // Convert seconds to frames (assumes 60 FPS)
let total_ticks = (level_timing.energizer_duration * 60.0).round().clamp(0.0, u32::MAX as f32) as u32; let total_ticks = 60 * 5;
// Add Vulnerable component to all ghosts // Add Vulnerable component to all ghosts
for ghost_entity in ghost_query.iter() { for ghost_entity in ghost_query.iter() {