reset velocity when waking up after bus station cryo

This commit is contained in:
yuni 2024-04-11 21:30:27 +02:00
parent ef0ada9dac
commit b2e6ba2b77

View file

@ -302,15 +302,15 @@ pub fn handle_conversations(
pub fn handle_chat_scripts( pub fn handle_chat_scripts(
mut er_chatscript: EventReader<ChatScriptEvent>, mut er_chatscript: EventReader<ChatScriptEvent>,
mut q_actor: Query<(&mut actor::Actor, &mut actor::Suit), Without<actor::Player>>, mut q_actor: Query<(&mut actor::Actor, &mut actor::Suit), Without<actor::Player>>,
mut q_player: Query<(&mut actor::Actor, &mut actor::Suit), With<actor::Player>>, mut q_player: Query<(&mut actor::Actor, &mut actor::Suit, &mut actor::ExperiencesGForce), With<actor::Player>>,
mut q_playercam: Query<&mut Position, With<actor::PlayerCamera>>, mut q_playercam: Query<(&mut Position, &mut LinearVelocity), With<actor::PlayerCamera>>,
mut ew_sfx: EventWriter<audio::PlaySfxEvent>, mut ew_sfx: EventWriter<audio::PlaySfxEvent>,
mut ew_effect: EventWriter<effects::SpawnEffectEvent>, mut ew_effect: EventWriter<effects::SpawnEffectEvent>,
) { ) {
for script in er_chatscript.read() { for script in er_chatscript.read() {
match script.name.as_str() { match script.name.as_str() {
"refilloxygen" => if let Ok(mut amount) = script.param.parse::<f32>() { "refilloxygen" => if let Ok(mut amount) = script.param.parse::<f32>() {
for (mut _actor, mut suit) in q_player.iter_mut() { for (_, mut suit, _) in q_player.iter_mut() {
if script.param2.is_empty() { if script.param2.is_empty() {
suit.oxygen = (suit.oxygen + amount).clamp(0.0, suit.oxygen_max); 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"); error!("Chat script cryotrip needs a parameter");
} }
else { 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() { if script.param == "oscillation".to_string() {
*pos = Position(DVec3::new(147e6, 165e6, 336e6)); *pos = Position(DVec3::new(147e6, 165e6, 336e6));
v.0 = DVec3::ZERO;
} }
else if script.param == "metisprime".to_string() { else if script.param == "metisprime".to_string() {
*pos = Position(DVec3::new(27643e3, -47e3, -124434e3)); *pos = Position(DVec3::new(27643e3, -47e3, -124434e3));
v.0 = DVec3::ZERO;
} }
else if script.param == "serenity".to_string() { else if script.param == "serenity".to_string() {
*pos = Position(DVec3::new(-121095e3, 582e3, -190816e3)); *pos = Position(DVec3::new(-121095e3, 582e3, -190816e3));
v.0 = DVec3::ZERO;
} }
else { else {
error!("Invalid destination for cryotrip chat script: '{}'", script.param); 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; suit.oxygen = suit.oxygen_max;
gforce.ignore_gforce_seconds = 1.0;
} }
ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::WakeUp)); ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::WakeUp));
ew_effect.send(effects::SpawnEffectEvent { ew_effect.send(effects::SpawnEffectEvent {