mirror of
https://github.com/Xevion/Pac-Man.git
synced 2025-12-06 01:15:42 -06:00
62 lines
2.0 KiB
Rust
62 lines
2.0 KiB
Rust
use bevy_ecs::{entity::Entity, event::Event};
|
|
|
|
use crate::{map::direction::Direction, systems::Ghost};
|
|
|
|
/// Player input commands that trigger specific game actions.
|
|
///
|
|
/// Commands are generated by the input system in response to keyboard events
|
|
/// and processed by appropriate game systems to modify state or behavior.
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
pub enum GameCommand {
|
|
/// Request immediate game shutdown
|
|
Exit,
|
|
/// Set Pac-Man's movement direction
|
|
MovePlayer(Direction),
|
|
/// Cycle through debug visualization modes
|
|
ToggleDebug,
|
|
/// Toggle audio mute state
|
|
MuteAudio,
|
|
/// Restart the current level with fresh entity positions and items
|
|
ResetLevel,
|
|
/// Pause or resume game ticking logic
|
|
/// TODO: Display pause state, fix debug rendering pause distress
|
|
TogglePause,
|
|
/// Toggle fullscreen mode (desktop only)
|
|
ToggleFullscreen,
|
|
}
|
|
|
|
/// Global events that flow through the ECS event system to coordinate game behavior.
|
|
///
|
|
/// Events enable loose coupling between systems - input generates commands and
|
|
/// various systems respond appropriately without direct dependencies.
|
|
#[derive(Event, Clone, Copy, Debug, PartialEq, Eq)]
|
|
pub enum GameEvent {
|
|
/// Player input command to be processed by relevant game systems
|
|
Command(GameCommand),
|
|
}
|
|
|
|
impl From<GameCommand> for GameEvent {
|
|
fn from(command: GameCommand) -> Self {
|
|
GameEvent::Command(command)
|
|
}
|
|
}
|
|
|
|
/// Data for requesting stage transitions; processed centrally in stage_system
|
|
#[derive(Event, Clone, Copy, Debug, PartialEq, Eq)]
|
|
pub enum StageTransition {
|
|
GhostEatenPause { ghost_entity: Entity, ghost_type: Ghost },
|
|
}
|
|
|
|
/// Collision triggers for immediate collision handling via observers
|
|
#[derive(Event, Clone, Copy, Debug, PartialEq, Eq)]
|
|
pub enum CollisionTrigger {
|
|
/// Pac-Man collided with a ghost
|
|
GhostCollision {
|
|
pacman: Entity,
|
|
ghost: Entity,
|
|
ghost_type: Ghost,
|
|
},
|
|
/// Pac-Man collided with an item
|
|
ItemCollision { item: Entity },
|
|
}
|