implement travel to Oscillation Station
This commit is contained in:
parent
a6f6b8b582
commit
9954c19d2a
30
src/chat.rs
30
src/chat.rs
|
@ -1,4 +1,6 @@
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
use bevy_xpbd_3d::prelude::*;
|
||||||
|
use bevy::math::DVec3;
|
||||||
use crate::{actor, audio, hud, settings, world, effects};
|
use crate::{actor, audio, hud, settings, world, effects};
|
||||||
|
|
||||||
pub struct ChatPlugin;
|
pub struct ChatPlugin;
|
||||||
|
@ -300,14 +302,14 @@ 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), 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_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);
|
||||||
}
|
}
|
||||||
|
@ -337,11 +339,25 @@ pub fn handle_chat_scripts(
|
||||||
error!("Invalid parameter for command `{}`: `{}`", script.name, script.param);
|
error!("Invalid parameter for command `{}`: `{}`", script.name, script.param);
|
||||||
}
|
}
|
||||||
"cryotrip" => {
|
"cryotrip" => {
|
||||||
ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::WakeUp));
|
if script.param.is_empty() {
|
||||||
ew_effect.send(effects::SpawnEffectEvent {
|
error!("Chat script cryotrip needs a parameter");
|
||||||
class: effects::Effects::FadeIn(Color::CYAN),
|
}
|
||||||
duration: 1.0,
|
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" => {
|
"cryofadeout" => {
|
||||||
ew_effect.send(effects::SpawnEffectEvent {
|
ew_effect.send(effects::SpawnEffectEvent {
|
||||||
|
|
12
src/defs.txt
12
src/defs.txt
|
@ -364,7 +364,7 @@ actor -300 0 40 suit
|
||||||
actor 100 -18000 2000 "orb_busstop"
|
actor 100 -18000 2000 "orb_busstop"
|
||||||
relativeto player
|
relativeto player
|
||||||
id "busstop"
|
id "busstop"
|
||||||
name "StarTrans Bus Station 'River of Time'"
|
name "StarTrans Bus Stop: Serenity Station"
|
||||||
scale 100
|
scale 100
|
||||||
wants maxrotation 0
|
wants maxrotation 0
|
||||||
wants maxvelocity 0
|
wants maxvelocity 0
|
||||||
|
@ -382,7 +382,7 @@ actor 100 -18000 2000 "orb_busstop"
|
||||||
chatid "busstopclippy"
|
chatid "busstopclippy"
|
||||||
chat "busstopclippy"
|
chat "busstopclippy"
|
||||||
name "StarTrans Clippy™"
|
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 2 question wait "Ready for a trip? Available stops: Oscillation Station, J-Prime Station"
|
||||||
msg 40 wait answer ""
|
msg 40 wait answer ""
|
||||||
sound none
|
sound none
|
||||||
|
@ -440,6 +440,14 @@ actor 100 -18000 2000 "orb_busstop"
|
||||||
msg 0 cryo EXIT "Lifeform in cryostasis detected."
|
msg 0 cryo EXIT "Lifeform in cryostasis detected."
|
||||||
lvl info
|
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
|
chat error
|
||||||
name ERROR
|
name ERROR
|
||||||
msg 0 INIT EXIT "Unspecified conversation ID"
|
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;
|
let gforce = gforce.gforce;
|
||||||
if let Ok((clickable, _, target_v_maybe)) = q_target.get_single() {
|
if let Ok((clickable, _, target_v_maybe)) = q_target.get_single() {
|
||||||
let distance = if dist_scalar.is_nan() {
|
let distance = if dist_scalar.is_nan() {
|
||||||
|
@ -496,12 +504,12 @@ fn update_hud(
|
||||||
};
|
};
|
||||||
let speed_readable = nature::readable_distance(speed);
|
let speed_readable = nature::readable_distance(speed);
|
||||||
let target_name = clickable.name.clone().unwrap_or("Unnamed".to_string());
|
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 {
|
else {
|
||||||
let speed = cam_v.length();
|
let speed = cam_v.length();
|
||||||
let speed_readable = nature::readable_distance(speed);
|
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