Compare commits
11 commits
97141ed73a
...
6c8cdf9af8
Author | SHA1 | Date | |
---|---|---|---|
yuni | 6c8cdf9af8 | ||
yuni | 32537315d0 | ||
yuni | 2d5348956e | ||
yuni | 2a7714661f | ||
yuni | a46d29715e | ||
yuni | e47e175fc5 | ||
yuni | 51089049ae | ||
yuni | eb3353bb07 | ||
yuni | b857d46119 | ||
yuni | 73beb451dd | ||
yuni | ba1269627d |
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -2769,7 +2769,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "outfly"
|
||||
version = "0.6.1"
|
||||
version = "0.7.0"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
"bevy_embedded_assets",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "outfly"
|
||||
version = "0.6.1"
|
||||
version = "0.7.0"
|
||||
edition = "2021"
|
||||
homepage = "https://codeberg.org/hut/outfly"
|
||||
repository = "https://codeberg.org/hut/outfly"
|
||||
|
|
|
@ -154,6 +154,12 @@ python -m http.server -d wasm
|
|||
|
||||
# Changelog
|
||||
|
||||
- v0.7.0:
|
||||
- Overhaul conversation system, now defined in YAML files
|
||||
- Implement conversation variables and if-branches
|
||||
- Improve dialogues
|
||||
- Improve HUD
|
||||
- Add teleport-to-target cheat
|
||||
- v0.6.1:
|
||||
- Implement free public transport with 3 bus stations
|
||||
- Implement Clippy™ Convenience Companion drone
|
||||
|
|
|
@ -661,6 +661,7 @@ pub fn handle_chat_events(
|
|||
time: Res<Time>,
|
||||
settings: Res<var::Settings>,
|
||||
) {
|
||||
let mut choice_key = q_choices.iter().len();
|
||||
for event in er_chatevent.read() {
|
||||
let now = time.elapsed_seconds_f64();
|
||||
let chat_maybe = q_chats.get_single_mut();
|
||||
|
@ -674,6 +675,7 @@ pub fn handle_chat_events(
|
|||
for entity in &q_choices {
|
||||
commands.entity(entity).despawn();
|
||||
}
|
||||
choice_key = 0;
|
||||
}
|
||||
ChatEvent::DespawnAllChats => {
|
||||
commands.entity(chat_entity).despawn();
|
||||
|
@ -695,7 +697,7 @@ pub fn handle_chat_events(
|
|||
let sfx = audio::str2sfx(sound);
|
||||
ew_sfx.send(audio::PlaySfxEvent(sfx));
|
||||
}
|
||||
ChatEvent::SpawnChoice(replytext, key, goto, nowait, condition) => {
|
||||
ChatEvent::SpawnChoice(replytext, _key, goto, nowait, condition) => {
|
||||
'out: {
|
||||
if let Some(condition) = condition {
|
||||
if !vars.evaluate_condition(condition, &chat.talker.actor_id) {
|
||||
|
@ -706,10 +708,11 @@ pub fn handle_chat_events(
|
|||
world::DespawnOnPlayerDeath,
|
||||
Choice {
|
||||
text: replytext.into(),
|
||||
key: *key,
|
||||
key: choice_key,
|
||||
goto: goto.clone(),
|
||||
}
|
||||
));
|
||||
choice_key += 1;
|
||||
if !nowait {
|
||||
chat.timer = now + CHOICE_TIMER / settings.chat_speed as f64;
|
||||
}
|
||||
|
|
|
@ -53,17 +53,23 @@
|
|||
- But take care, your suit seems to be leaking. I'd patch it up if I were you.
|
||||
- I'm all out of SuitPatch™ SuperGlue™ right now, otherwise I'd share.
|
||||
- Can I help you with anything else, maybe?
|
||||
- goto: help
|
||||
- I got this apocalyptic headache...:
|
||||
- set: friends
|
||||
- Heh, probably related to why you were passed out.
|
||||
- Go easy on yourself, I'm sure things will turn for the better.
|
||||
- Meanwhile, can I help you with anything?
|
||||
- goto: help
|
||||
- I... don't know, I'm pretty disoriented.:
|
||||
- set: friends
|
||||
- Oh no. Do you need a lowdown on reality?
|
||||
- goto: help
|
||||
- I just want to be alone right now:
|
||||
- Oh, sure. Ping me if you need anything. I'll go back to playing my VR game.
|
||||
- goto: EXIT
|
||||
- Not so chatty right now?
|
||||
- I... guess I'll go back to playing my VR game. Ping me if you need anything.
|
||||
- goto: EXIT
|
||||
|
||||
|
||||
- label: help
|
||||
|
@ -252,7 +258,6 @@
|
|||
- It's really delicious:
|
||||
- Right, of course.
|
||||
- Nevermind:
|
||||
- So?
|
||||
- set: $knows-pineapple
|
||||
- goto: eat
|
||||
- I made up my mind.:
|
||||
|
|
337
src/hud.rs
337
src/hud.rs
|
@ -9,8 +9,9 @@ use std::time::SystemTime;
|
|||
|
||||
pub const HUD_REFRESH_TIME: f32 = 0.1;
|
||||
pub const FONT: &str = "fonts/Yupiter-Regular.ttf";
|
||||
pub const LOG_MAX: usize = 20;
|
||||
pub const LOG_MAX_TIME_S: u64 = 20;
|
||||
pub const LOG_MAX: usize = 4;
|
||||
pub const LOG_MAX_TIME_S: f64 = 15.0;
|
||||
pub const LOG_MAX_ROWS: usize = 30;
|
||||
pub const AMBIENT_LIGHT: f32 = 0.0; // Space is DARK
|
||||
pub const AMBIENT_LIGHT_AR: f32 = 15.0;
|
||||
//pub const REPLY_NUMBERS: [char; 10] = ['❶', '❷', '❸', '❹', '❺', '❻', '❼', '❽', '❾', '⓿'];
|
||||
|
@ -83,7 +84,15 @@ struct Message {
|
|||
text: String,
|
||||
sender: String,
|
||||
level: LogLevel,
|
||||
time: u64,
|
||||
time: f64,
|
||||
}
|
||||
impl Message {
|
||||
pub fn get_freshness(&self) -> f64 {
|
||||
if let Ok(epoch) = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH) {
|
||||
return (1.0 - (epoch.as_secs_f64() - self.time) / LOG_MAX_TIME_S).clamp(0.0, 1.0);
|
||||
}
|
||||
return 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Component)]
|
||||
|
@ -128,16 +137,17 @@ impl Log {
|
|||
text,
|
||||
sender,
|
||||
level,
|
||||
time: epoch.as_secs(),
|
||||
time: epoch.as_secs_f64(),
|
||||
});
|
||||
self.needs_rerendering = true;
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn remove_old(&mut self) {
|
||||
if let Some(message) = self.logs.front() {
|
||||
if let Ok(epoch) = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH) {
|
||||
if epoch.as_secs() - message.time > LOG_MAX_TIME_S {
|
||||
if epoch.as_secs_f64() - message.time > LOG_MAX_TIME_S {
|
||||
self.logs.pop_front();
|
||||
}
|
||||
}
|
||||
|
@ -163,147 +173,34 @@ fn setup(
|
|||
} else {
|
||||
Visibility::Hidden
|
||||
};
|
||||
let style = TextStyle {
|
||||
font: asset_server.load(FONT),
|
||||
font_size: settings.font_size_hud,
|
||||
color: Color::GRAY,
|
||||
..default()
|
||||
};
|
||||
let mut bundle_fps = TextBundle::from_sections([
|
||||
TextSection::new(
|
||||
"",
|
||||
TextStyle {
|
||||
font: asset_server.load(FONT),
|
||||
font_size: settings.font_size_hud,
|
||||
color: Color::GRAY,
|
||||
..default()
|
||||
}
|
||||
),
|
||||
TextSection::new(
|
||||
" ⚡ ",
|
||||
TextStyle {
|
||||
font: asset_server.load(FONT),
|
||||
font_size: settings.font_size_hud,
|
||||
color: Color::GRAY,
|
||||
..default()
|
||||
},
|
||||
),
|
||||
TextSection::new(
|
||||
"",
|
||||
TextStyle {
|
||||
font: asset_server.load(FONT),
|
||||
font_size: settings.font_size_hud,
|
||||
color: Color::GRAY,
|
||||
..default()
|
||||
}
|
||||
),
|
||||
TextSection::new(
|
||||
" ☣ ",
|
||||
TextStyle {
|
||||
font: asset_server.load(FONT),
|
||||
font_size: settings.font_size_hud,
|
||||
color: Color::GRAY,
|
||||
..default()
|
||||
},
|
||||
),
|
||||
TextSection::new(
|
||||
"",
|
||||
TextStyle {
|
||||
font: asset_server.load(FONT),
|
||||
font_size: settings.font_size_hud,
|
||||
color: Color::GRAY,
|
||||
..default()
|
||||
}
|
||||
),
|
||||
TextSection::new(
|
||||
"",
|
||||
TextStyle {
|
||||
font: asset_server.load(FONT),
|
||||
font_size: settings.font_size_hud,
|
||||
color: Color::GRAY,
|
||||
..default()
|
||||
}
|
||||
),
|
||||
TextSection::new(
|
||||
"\n氧 OXYGEN ",
|
||||
TextStyle {
|
||||
font: asset_server.load(FONT),
|
||||
font_size: settings.font_size_hud,
|
||||
color: Color::GRAY,
|
||||
..default()
|
||||
},
|
||||
),
|
||||
TextSection::new(
|
||||
"",
|
||||
TextStyle {
|
||||
font: asset_server.load(FONT),
|
||||
font_size: settings.font_size_hud,
|
||||
color: Color::MAROON,
|
||||
..default()
|
||||
}
|
||||
),
|
||||
TextSection::new(
|
||||
"\nProximity 警告 ",
|
||||
TextStyle {
|
||||
font: asset_server.load(FONT),
|
||||
font_size: settings.font_size_hud,
|
||||
color: Color::GRAY,
|
||||
..default()
|
||||
},
|
||||
),
|
||||
TextSection::new(
|
||||
"",
|
||||
TextStyle {
|
||||
font: asset_server.load(FONT),
|
||||
font_size: settings.font_size_hud,
|
||||
color: Color::GRAY,
|
||||
..default()
|
||||
}
|
||||
),
|
||||
TextSection::new(
|
||||
"\nSuit Integrity ",
|
||||
TextStyle {
|
||||
font: asset_server.load(FONT),
|
||||
font_size: settings.font_size_hud,
|
||||
color: Color::GRAY,
|
||||
..default()
|
||||
},
|
||||
),
|
||||
TextSection::new(
|
||||
"",
|
||||
TextStyle {
|
||||
font: asset_server.load(FONT),
|
||||
font_size: settings.font_size_hud,
|
||||
color: Color::GRAY,
|
||||
..default()
|
||||
}
|
||||
),
|
||||
TextSection::new(
|
||||
"\nVitals ",
|
||||
TextStyle {
|
||||
font: asset_server.load(FONT),
|
||||
font_size: settings.font_size_hud,
|
||||
color: Color::GRAY,
|
||||
..default()
|
||||
},
|
||||
),
|
||||
TextSection::new(
|
||||
"",
|
||||
TextStyle {
|
||||
font: asset_server.load(FONT),
|
||||
font_size: settings.font_size_hud,
|
||||
color: Color::GRAY,
|
||||
..default()
|
||||
}
|
||||
),
|
||||
TextSection::new( // Target
|
||||
"",
|
||||
TextStyle {
|
||||
font: asset_server.load(FONT),
|
||||
font_size: settings.font_size_hud,
|
||||
color: Color::GRAY,
|
||||
..default()
|
||||
}
|
||||
),
|
||||
TextSection::new("", style.clone()),
|
||||
TextSection::new(" ⚡ ", style.clone()),
|
||||
TextSection::new("", style.clone()),
|
||||
TextSection::new(" ☣ ", style.clone()),
|
||||
TextSection::new("", style.clone()),
|
||||
TextSection::new("", style.clone()),
|
||||
TextSection::new("\n氧 OXYGEN ", style.clone()),
|
||||
TextSection::new("", style.clone()),
|
||||
TextSection::new("\nProximity 警告 ", style.clone()),
|
||||
TextSection::new("", style.clone()),
|
||||
TextSection::new("\nSuit Integrity ", style.clone()),
|
||||
TextSection::new("", style.clone()),
|
||||
TextSection::new("\nVitals ", style.clone()),
|
||||
TextSection::new("", style.clone()),
|
||||
TextSection::new("", style.clone()), // Target
|
||||
]).with_style(Style {
|
||||
position_type: PositionType::Absolute,
|
||||
top: Val::VMin(2.0),
|
||||
left: Val::VMin(3.0),
|
||||
right: Val::VMin(3.0),
|
||||
..default()
|
||||
});
|
||||
}).with_text_justify(JustifyText::Right);
|
||||
bundle_fps.visibility = visibility;
|
||||
commands.spawn((
|
||||
GaugesText,
|
||||
|
@ -313,47 +210,50 @@ fn setup(
|
|||
|
||||
// Add Chat Box
|
||||
let bundle_chatbox = TextBundle::from_sections([
|
||||
TextSection::new(
|
||||
"Warning: System Log Uninitialized",
|
||||
TextStyle {
|
||||
font: asset_server.load(FONT),
|
||||
font_size: settings.font_size_hud,
|
||||
color: Color::rgb(0.7, 0.7, 0.7),
|
||||
..default()
|
||||
}
|
||||
),
|
||||
TextSection::new(
|
||||
"\n",
|
||||
TextStyle {
|
||||
font: asset_server.load(FONT),
|
||||
font_size: settings.font_size_hud,
|
||||
color: Color::WHITE,
|
||||
..default()
|
||||
}
|
||||
),
|
||||
TextSection::new(
|
||||
"\n\n\n",
|
||||
TextStyle {
|
||||
font: asset_server.load(FONT),
|
||||
font_size: settings.font_size_hud,
|
||||
color: Color::WHITE,
|
||||
..default()
|
||||
}
|
||||
),
|
||||
TextSection::new("", style.clone()),
|
||||
TextSection::new("", style.clone()),
|
||||
TextSection::new("", style.clone()),
|
||||
TextSection::new("", style.clone()),
|
||||
TextSection::new("", style.clone()),
|
||||
TextSection::new("", style.clone()),
|
||||
TextSection::new("", style.clone()),
|
||||
TextSection::new("", style.clone()),
|
||||
TextSection::new("", style.clone()),
|
||||
TextSection::new("", style.clone()),
|
||||
TextSection::new("", style.clone()),
|
||||
TextSection::new("", style.clone()),
|
||||
TextSection::new("", style.clone()),
|
||||
TextSection::new("", style.clone()),
|
||||
TextSection::new("", style.clone()),
|
||||
TextSection::new("", style.clone()),
|
||||
TextSection::new("", style.clone()),
|
||||
TextSection::new("", style.clone()),
|
||||
TextSection::new("", style.clone()),
|
||||
TextSection::new("", style.clone()),
|
||||
TextSection::new("", style.clone()),
|
||||
TextSection::new("", style.clone()),
|
||||
TextSection::new("", style.clone()),
|
||||
TextSection::new("", style.clone()),
|
||||
TextSection::new("", style.clone()),
|
||||
TextSection::new("", style.clone()),
|
||||
TextSection::new("", style.clone()),
|
||||
TextSection::new("", style.clone()),
|
||||
TextSection::new("", style.clone()),
|
||||
TextSection::new("", style.clone()),
|
||||
]).with_style(Style {
|
||||
position_type: PositionType::Absolute,
|
||||
bottom: Val::VMin(0.0),
|
||||
top: Val::VMin(0.0),
|
||||
left: Val::VMin(0.0),
|
||||
..default()
|
||||
}).with_text_justify(JustifyText::Left);
|
||||
commands.spawn((
|
||||
NodeBundle {
|
||||
style: Style {
|
||||
width: Val::Percent(50.),
|
||||
width: Val::Percent(45.0),
|
||||
align_items: AlignItems::Start,
|
||||
position_type: PositionType::Absolute,
|
||||
bottom: Val::Vh(10.0),
|
||||
left: Val::Vw(25.0),
|
||||
top: Val::VMin(2.0),
|
||||
left: Val::VMin(3.0),
|
||||
..default()
|
||||
},
|
||||
..default()
|
||||
|
@ -421,6 +321,7 @@ fn update_hud(
|
|||
if timer.0.tick(time.delta()).just_finished() || log.needs_rerendering {
|
||||
let q_camera_result = q_camera.get_single();
|
||||
let player = player.get_single();
|
||||
let mut freshest_line: f64 = 0.0;
|
||||
if player.is_ok() && q_camera_result.is_ok() {
|
||||
let (hp, suit, gforce) = player.unwrap();
|
||||
let (pos, cam_v) = q_camera_result.unwrap();
|
||||
|
@ -440,18 +341,30 @@ fn update_hud(
|
|||
if suit.oxygen > nature::OXY_H {
|
||||
let oxy_hour = suit.oxygen / nature::OXY_H;
|
||||
text.sections[7].value = format!("{oxy_percent:.1}% [lasts {oxy_hour:.1} hours]");
|
||||
text.sections[7].style.color = Color::GRAY;
|
||||
} else {
|
||||
let oxy_min = suit.oxygen / nature::OXY_M;
|
||||
text.sections[7].value = format!("{oxy_percent:.1}% [lasts {oxy_min:.1} min]");
|
||||
text.sections[7].style.color = Color::MAROON;
|
||||
}
|
||||
//let adrenaline = lifeform.adrenaline * 990.0 + 10.0;
|
||||
//text.sections[11].value = format!("{adrenaline:.0}pg/mL");
|
||||
let vitals = 100.0 * hp.current / hp.max;
|
||||
text.sections[13].value = format!("{vitals:.0}%");
|
||||
if vitals < 50.0 {
|
||||
text.sections[13].style.color = Color::MAROON;
|
||||
} else {
|
||||
text.sections[13].style.color = Color::GRAY;
|
||||
}
|
||||
let all_actors = query_all_actors.iter().len();
|
||||
text.sections[9].value = format!("{all_actors:.0}");
|
||||
let integrity = suit.integrity * 100.0;
|
||||
text.sections[11].value = format!("{integrity:.0}%");
|
||||
if integrity < 50.0 {
|
||||
text.sections[11].style.color = Color::MAROON;
|
||||
} else {
|
||||
text.sections[11].style.color = Color::GRAY;
|
||||
}
|
||||
//text.sections[17].value = format!("{speed_readable}/s / {kmh:.0}km/h / {gforce:.1}g");
|
||||
|
||||
// Target display
|
||||
|
@ -514,6 +427,49 @@ fn update_hud(
|
|||
}
|
||||
|
||||
if let Ok(mut chat) = query_chat.get_single_mut() {
|
||||
let mut row = 0;
|
||||
let bright = Color::rgb(0.8, 0.75, 0.78);
|
||||
|
||||
// Chat Log and System Log
|
||||
let logfilter = if settings.hud_active {
|
||||
|_msg: &&Message| { true }
|
||||
} else {
|
||||
|msg: &&Message| { match msg.level {
|
||||
LogLevel::Chat => true,
|
||||
LogLevel::Warning => true,
|
||||
LogLevel::Info => true,
|
||||
_ => false
|
||||
}}
|
||||
};
|
||||
let mut messages: Vec<&Message> = log.logs.iter()
|
||||
.filter(logfilter)
|
||||
.rev()
|
||||
.take(15)
|
||||
.collect();
|
||||
messages.reverse();
|
||||
for msg in &messages {
|
||||
if msg.sender.is_empty() {
|
||||
chat.sections[row].value = msg.text.clone() + "\n";
|
||||
}
|
||||
else {
|
||||
chat.sections[row].value = format!("{}: {}\n", msg.sender, msg.text);
|
||||
}
|
||||
let freshness = msg.get_freshness();
|
||||
let clr: f32 = (freshness.powf(1.5) as f32).clamp(0.1, 1.0);
|
||||
freshest_line = freshest_line.max(freshness);
|
||||
chat.sections[row].style.color = Color::rgba(0.7, 0.7, 0.7, clr);
|
||||
row += 1;
|
||||
}
|
||||
|
||||
// Highlight most recent line if in a conversation
|
||||
if row > 0 && (q_choices.is_empty() || freshest_line > 0.5) {
|
||||
chat.sections[row-1].style.color = bright;
|
||||
}
|
||||
|
||||
// Add padding between chat and choices
|
||||
chat.sections[row].value = "\n".to_string();
|
||||
row += 1;
|
||||
|
||||
// Choices
|
||||
let mut choices: Vec<String> = Vec::new();
|
||||
let mut count = 0;
|
||||
|
@ -533,31 +489,24 @@ fn update_hud(
|
|||
choices.push(" ".to_string());
|
||||
}
|
||||
}
|
||||
chat.sections[2].value = choices.join("\n");
|
||||
for choice in choices {
|
||||
chat.sections[row].value = choice + "\n";
|
||||
chat.sections[row].style.color = bright;
|
||||
row += 1;
|
||||
}
|
||||
|
||||
// Chat Log and System Log
|
||||
let logfilter = if settings.hud_active {
|
||||
|_msg: &&Message| { true }
|
||||
} else {
|
||||
|msg: &&Message| { match msg.level {
|
||||
LogLevel::Chat => true,
|
||||
LogLevel::Warning => true,
|
||||
LogLevel::Info => true,
|
||||
_ => false
|
||||
}}
|
||||
};
|
||||
let logs_vec: Vec<String> = log.logs.iter()
|
||||
.filter(logfilter)
|
||||
.map(|s| if s.sender.is_empty() {
|
||||
format!("{}", s.text)
|
||||
} else {
|
||||
format!("{}: {}", s.sender, s.text)
|
||||
}).collect();
|
||||
chat.sections[0].value = logs_vec.join("\n");
|
||||
// Blank the remaining rows
|
||||
while row < LOG_MAX_ROWS {
|
||||
chat.sections[row].value = "".to_string();
|
||||
row += 1;
|
||||
}
|
||||
}
|
||||
log.needs_rerendering = false;
|
||||
|
||||
if q_choices.is_empty() && freshest_line < 0.2 {
|
||||
log.remove_old();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_input(
|
||||
|
@ -649,7 +598,7 @@ fn update_target_selectagon(
|
|||
}
|
||||
selectagon_trans.translation = target_trans.translation;
|
||||
selectagon_trans.scale = target_trans.scale;
|
||||
selectagon_trans.rotation = camera_trans.rotation;
|
||||
selectagon_trans.rotation = Quat::from_rotation_arc(Vec3::Z, (-selectagon_trans.translation).normalize());
|
||||
|
||||
// Enlarge Selectagon to a minimum angular diameter
|
||||
let (angular_diameter, _, _) = camera::calc_angular_diameter(
|
||||
|
|
Loading…
Reference in a new issue