diff --git a/src/chat.rs b/src/chat.rs index 5e6969f..3c8cb7b 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -778,6 +778,7 @@ pub fn handle_chat_scripts( mut q_playercam: Query<(&mut Position, &mut LinearVelocity), With>, mut ew_sfx: EventWriter, mut ew_effect: EventWriter, + id2pos: Res, ) { for script in er_chatscript.read() { // Parse the script string @@ -834,19 +835,20 @@ pub fn handle_chat_scripts( } else { if let Ok((mut pos, mut v)) = q_playercam.get_single_mut() { - if param1 == "oscillation".to_string() { - *pos = Position(DVec3::new(-184968e3, 149410e3, -134273e3)); - v.0 = DVec3::ZERO; - } - else if param1 == "metisprime".to_string() { - *pos = Position(DVec3::new(27643e3, -47e3, -124434e3)); - v.0 = DVec3::ZERO; - } - else if param1 == "serenity".to_string() { - *pos = Position(DVec3::new(-121095e3, 582e3, -190816e3)); - v.0 = DVec3::ZERO; - } - else { + let busstop = match param1 { + "serenity" => Some("busstop"), + "oscillation" => Some("busstop2"), + "metisprime" => Some("busstop3"), + _ => None + }; + if let Some(station) = busstop { + if let Some(target) = id2pos.0.get(&station.to_string()) { + pos.0 = *target + DVec3::new(0.0, -1000.0, 0.0); + v.0 = DVec3::ZERO; + } else { + error!("Could not determine position of actor with ID: '{}'", station); + } + } else { error!("Invalid destination for cryotrip chat script: '{}'", param1); } }