automatically face towards points of interest on fast travel

This commit is contained in:
yuni 2024-10-26 23:43:19 +02:00
parent 7a66740f15
commit bb724c9a10

View file

@ -894,7 +894,7 @@ pub fn handle_chat_scripts(
),
With<actor::Player>,
>,
mut q_playercam: Query<(&mut Position, &mut LinearVelocity), With<actor::PlayerCamera>>,
mut q_playercam: Query<(&mut Position, &mut Rotation, &mut LinearVelocity), With<actor::PlayerCamera>>,
mut q_chats: Query<&mut Chat>,
mut ew_sfx: EventWriter<audio::PlaySfxEvent>,
mut ew_effect: EventWriter<visual::SpawnEffectEvent>,
@ -960,13 +960,20 @@ pub fn handle_chat_scripts(
if param1.is_empty() {
error!("Chat script cryotrip needs a parameter");
} else {
if let Ok((mut pos, mut v)) = q_playercam.get_single_mut() {
if let Ok((mut pos, mut rot, mut v)) = q_playercam.get_single_mut() {
let busstop = match param1 {
"serenity" => Some("busstopclippy"),
"farview" => Some("busstopclippy2"),
"metisprime" => Some("busstopclippy3"),
_ => None,
};
let looktarget = match param1 {
"serenity" => Some("pizzeria"),
"farview" => Some("jupiter"),
"metisprime" => Some("busstopclippy3"),
_ => None,
};
if let Some(station) = busstop {
if let Some(target_pos) = id2pos.0.get(&station.to_string()) {
pos.0 = *target_pos + DVec3::new(0.0, 9000.0, 0.0);
@ -987,6 +994,12 @@ pub fn handle_chat_scripts(
} else {
error!("Invalid destination for cryotrip chat script: '{}'", param1);
}
if let Some(looktarget) = looktarget {
if let Some(target_pos) = id2pos.0.get(&looktarget.to_string()) {
rot.0 = look_at_quat(**pos, *target_pos, Dir3::X.as_dvec3());
}
}
}
if let Ok((_, mut suit, mut gforce)) = q_player.get_single_mut() {
suit.oxygen = suit.oxygen_max;