diff --git a/README.md b/README.md index 8dbd35e..40b122c 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ Source code: https://codeberg.org/hut/outfly - AWSD/Shift/Ctrl: Accelerate - R: Rotate (hold & move mouse) - E: Interact: Talk to people, enter vehicles +- H: Flashlight - Q: Exit vehicle - JKULIO: Mouseless camera rotation - Augmented Reality: (toggle with Tab) diff --git a/src/actor.rs b/src/actor.rs index 543b293..db833b6 100644 --- a/src/actor.rs +++ b/src/actor.rs @@ -135,6 +135,7 @@ impl Default for ExperiencesGForce { fn default() -> Self { Self { #[derive(Component)] pub struct JustNowEnteredVehicle; #[derive(Component)] pub struct ActorEnteringVehicle; #[derive(Component)] pub struct ActorVehicleBeingEntered; +#[derive(Component)] pub struct PlayersFlashLight; #[derive(Component)] pub struct WantsMaxRotation(pub f64); #[derive(Component)] pub struct WantsMaxVelocity(pub f64); #[derive(Component)] pub struct Identifier(pub String); @@ -263,10 +264,12 @@ pub fn handle_input( q_talker: Query<(&chat::Talker, &Transform), (Without, Without)>, player: Query>, q_camera: Query<&Transform, With>, + mut q_flashlight: Query<&mut Visibility, With>, q_vehicles: Query<(Entity, &Transform), (With, Without, Without)>, mut ew_conv: EventWriter, mut ew_vehicle: EventWriter, mut ew_playerdies: EventWriter, + mut ew_sfx: EventWriter, q_player_drives: Query>, ) { if q_camera.is_empty() || player.is_empty() { @@ -320,6 +323,16 @@ pub fn handle_input( break; } } + else if keyboard_input.just_pressed(settings.key_flashlight) { + for mut flashlight_vis in &mut q_flashlight { + ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::Click)); + if *flashlight_vis == Visibility::Hidden { + *flashlight_vis = Visibility::Visible; + } else { + *flashlight_vis = Visibility::Hidden; + } + } + } else if keyboard_input.just_pressed(settings.key_restart) { settings.god_mode = false; ew_playerdies.send(PlayerDiesEvent(DamageType::Mental)); diff --git a/src/commands.rs b/src/commands.rs index b251c0a..8a4cd3b 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -748,6 +748,7 @@ fn spawn_entities( actor.with_children(|builder| { builder.spawn(( world::DespawnOnPlayerDeath, + actor::PlayersFlashLight, SpotLightBundle { transform: Transform { translation: Vec3::new(0.0, 0.0, 1.0), @@ -763,6 +764,7 @@ fn spawn_entities( range: 2000.0, ..default() }, + visibility: Visibility::Hidden, ..default() } )); diff --git a/src/data/keybindings.in b/src/data/keybindings.in index 996ba6c..55e2aae 100644 --- a/src/data/keybindings.in +++ b/src/data/keybindings.in @@ -3,6 +3,7 @@ AWSD/Shift/Ctrl: Movement R: Rotate (hold + move mouse) E: Interact: Talk to people, enter vehicles Q: Exit vehicle +H: Flashlight M: Map Tab: Toggle HUD + Augmented Reality Left click: Target objects [AUGMENTED REALITY ONLY] diff --git a/src/var.rs b/src/var.rs index f548337..d7e9309 100644 --- a/src/var.rs +++ b/src/var.rs @@ -91,6 +91,7 @@ pub struct Settings { pub key_interact: KeyCode, pub key_vehicle: KeyCode, pub key_camera: KeyCode, + pub key_flashlight: KeyCode, pub key_shadows: KeyCode, pub key_rotate: KeyCode, pub key_rotation_stabilizer: KeyCode, @@ -196,6 +197,7 @@ impl Default for Settings { key_interact: KeyCode::KeyE, key_vehicle: KeyCode::KeyQ, key_camera: KeyCode::KeyF, + key_flashlight: KeyCode::KeyH, key_shadows: KeyCode::F2, key_rotate: KeyCode::KeyR, key_rotation_stabilizer: KeyCode::KeyY,