From b2e6ba2b774def964485d877b0d416859f86661d Mon Sep 17 00:00:00 2001 From: hut Date: Thu, 11 Apr 2024 21:30:27 +0200 Subject: [PATCH] reset velocity when waking up after bus station cryo --- src/chat.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/chat.rs b/src/chat.rs index e78269a..eef5710 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -302,15 +302,15 @@ pub fn handle_conversations( pub fn handle_chat_scripts( mut er_chatscript: EventReader, mut q_actor: Query<(&mut actor::Actor, &mut actor::Suit), Without>, - mut q_player: Query<(&mut actor::Actor, &mut actor::Suit), With>, - mut q_playercam: Query<&mut Position, With>, + mut q_player: Query<(&mut actor::Actor, &mut actor::Suit, &mut actor::ExperiencesGForce), With>, + mut q_playercam: Query<(&mut Position, &mut LinearVelocity), With>, mut ew_sfx: EventWriter, mut ew_effect: EventWriter, ) { for script in er_chatscript.read() { match script.name.as_str() { "refilloxygen" => if let Ok(mut amount) = script.param.parse::() { - for (mut _actor, mut suit) in q_player.iter_mut() { + for (_, mut suit, _) in q_player.iter_mut() { if script.param2.is_empty() { suit.oxygen = (suit.oxygen + amount).clamp(0.0, suit.oxygen_max); } @@ -344,22 +344,26 @@ pub fn handle_chat_scripts( error!("Chat script cryotrip needs a parameter"); } else { - if let Ok(mut pos) = q_playercam.get_single_mut() { + if let Ok((mut pos, mut v)) = q_playercam.get_single_mut() { if script.param == "oscillation".to_string() { *pos = Position(DVec3::new(147e6, 165e6, 336e6)); + v.0 = DVec3::ZERO; } else if script.param == "metisprime".to_string() { *pos = Position(DVec3::new(27643e3, -47e3, -124434e3)); + v.0 = DVec3::ZERO; } else if script.param == "serenity".to_string() { *pos = Position(DVec3::new(-121095e3, 582e3, -190816e3)); + v.0 = DVec3::ZERO; } else { error!("Invalid destination for cryotrip chat script: '{}'", script.param); } } - if let Ok((_, mut suit)) = q_player.get_single_mut() { + if let Ok((_, mut suit, mut gforce)) = q_player.get_single_mut() { suit.oxygen = suit.oxygen_max; + gforce.ignore_gforce_seconds = 1.0; } ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::WakeUp)); ew_effect.send(effects::SpawnEffectEvent {