diff --git a/src/chat.rs b/src/chat.rs index c02351f..d959988 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -1,4 +1,6 @@ use bevy::prelude::*; +use bevy_xpbd_3d::prelude::*; +use bevy::math::DVec3; use crate::{actor, audio, hud, settings, world, effects}; pub struct ChatPlugin; @@ -300,14 +302,14 @@ 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_player: Query<(&mut actor::Actor, &mut actor::Suit, &mut Position), 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 _actor, mut suit, _) in q_player.iter_mut() { if script.param2.is_empty() { suit.oxygen = (suit.oxygen + amount).clamp(0.0, suit.oxygen_max); } @@ -337,11 +339,25 @@ pub fn handle_chat_scripts( error!("Invalid parameter for command `{}`: `{}`", script.name, script.param); } "cryotrip" => { - ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::WakeUp)); - ew_effect.send(effects::SpawnEffectEvent { - class: effects::Effects::FadeIn(Color::CYAN), - duration: 1.0, - }); + if script.param.is_empty() { + error!("Chat script cryotrip needs a parameter"); + } + else { + if let Ok((_, mut suit, mut pos)) = q_player.get_single_mut() { + if script.param == "oscillation".to_string() { + *pos = Position(DVec3::new(147e6, 165e6, 336e6)); + } + else { + error!("Invalid destination for cryotrip chat script: '{}'", script.param); + } + suit.oxygen = suit.oxygen_max; + } + ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::WakeUp)); + ew_effect.send(effects::SpawnEffectEvent { + class: effects::Effects::FadeIn(Color::CYAN), + duration: 1.0, + }); + } } "cryofadeout" => { ew_effect.send(effects::SpawnEffectEvent { diff --git a/src/defs.txt b/src/defs.txt index 0bc92cd..bb43f1b 100644 --- a/src/defs.txt +++ b/src/defs.txt @@ -364,7 +364,7 @@ actor -300 0 40 suit actor 100 -18000 2000 "orb_busstop" relativeto player id "busstop" - name "StarTrans Bus Station 'River of Time'" + name "StarTrans Bus Stop: Serenity Station" scale 100 wants maxrotation 0 wants maxvelocity 0 @@ -382,7 +382,7 @@ actor 100 -18000 2000 "orb_busstop" chatid "busstopclippy" chat "busstopclippy" name "StarTrans Clippy™" - msg 2 INIT question "You have reached the bus station 'River of Time'" + msg 2 INIT question "You have reached the bus stop 'Serenity Station'" msg 2 question wait "Ready for a trip? Available stops: Oscillation Station, J-Prime Station" msg 40 wait answer "" sound none @@ -440,6 +440,14 @@ actor 100 -18000 2000 "orb_busstop" msg 0 cryo EXIT "Lifeform in cryostasis detected." lvl info +actor 147002e3 165e6 336e6 "orb_busstop" + relativeto jupiter + id "busstop2" + name "StarTrans Bus Station 'Oscillation Station'" + scale 100 + wants maxrotation 0 + wants maxvelocity 0 + chat error name ERROR msg 0 INIT EXIT "Unspecified conversation ID" diff --git a/src/hud.rs b/src/hud.rs index d3fa444..70c2386 100644 --- a/src/hud.rs +++ b/src/hud.rs @@ -480,6 +480,14 @@ fn update_hud( } } + let dev_speed = if settings.dev_mode { + let x = pos.x; + let y = pos.y; + let z = pos.z; + format!("\n{x:.0}\n{y:.0}\n{z:.0}") + } else { + "".to_string() + }; let gforce = gforce.gforce; if let Ok((clickable, _, target_v_maybe)) = q_target.get_single() { let distance = if dist_scalar.is_nan() { @@ -496,12 +504,12 @@ fn update_hud( }; let speed_readable = nature::readable_distance(speed); let target_name = clickable.name.clone().unwrap_or("Unnamed".to_string()); - text.sections[14].value = format!("\n\nTarget: {target_name}\nDistance: {distance}\nΔv {speed_readable}/s + {gforce:.1}g"); + text.sections[14].value = format!("\n\nTarget: {target_name}\nDistance: {distance}\nΔv {speed_readable}/s + {gforce:.1}g{dev_speed}"); } else { let speed = cam_v.length(); let speed_readable = nature::readable_distance(speed); - text.sections[14].value = format!("\nv {speed_readable}/s + {gforce:.1}g"); + text.sections[14].value = format!("\nv {speed_readable}/s + {gforce:.1}g{dev_speed}"); } } }