implement travel to Oscillation Station
This commit is contained in:
parent
a6f6b8b582
commit
9954c19d2a
20
src/chat.rs
20
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<ChatScriptEvent>,
|
||||
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 Position), With<actor::Player>>,
|
||||
mut ew_sfx: EventWriter<audio::PlaySfxEvent>,
|
||||
mut ew_effect: EventWriter<effects::SpawnEffectEvent>,
|
||||
) {
|
||||
for script in er_chatscript.read() {
|
||||
match script.name.as_str() {
|
||||
"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() {
|
||||
suit.oxygen = (suit.oxygen + amount).clamp(0.0, suit.oxygen_max);
|
||||
}
|
||||
|
@ -337,12 +339,26 @@ pub fn handle_chat_scripts(
|
|||
error!("Invalid parameter for command `{}`: `{}`", script.name, script.param);
|
||||
}
|
||||
"cryotrip" => {
|
||||
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 {
|
||||
class: effects::Effects::FadeOut(Color::CYAN),
|
||||
|
|
12
src/defs.txt
12
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"
|
||||
|
|
12
src/hud.rs
12
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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue