fix bringing space crafts along with a bus ride

This commit is contained in:
yuni 2024-04-11 02:14:36 +02:00
parent dc1037e5a3
commit 0d312edeee

View file

@ -302,14 +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, &mut Position), With<actor::Player>>, mut q_player: Query<(&mut actor::Actor, &mut actor::Suit), With<actor::Player>>,
mut q_playercam: Query<&mut Position, 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 _actor, 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);
} }
@ -343,7 +344,7 @@ 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 suit, mut pos)) = q_player.get_single_mut() { if let Ok(mut pos) = 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));
} }
@ -356,6 +357,8 @@ pub fn handle_chat_scripts(
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() {
suit.oxygen = suit.oxygen_max; suit.oxygen = suit.oxygen_max;
} }
ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::WakeUp)); ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::WakeUp));