summarize achievements on death screen
This commit is contained in:
parent
22d7a8cc4c
commit
d20dc5c60d
|
@ -162,7 +162,6 @@ fn handle_player_death(
|
||||||
mut active_asteroids: ResMut<world::ActiveAsteroids>,
|
mut active_asteroids: ResMut<world::ActiveAsteroids>,
|
||||||
mut ew_effect: EventWriter<visual::SpawnEffectEvent>,
|
mut ew_effect: EventWriter<visual::SpawnEffectEvent>,
|
||||||
mut ew_deathscreen: EventWriter<menu::DeathScreenEvent>,
|
mut ew_deathscreen: EventWriter<menu::DeathScreenEvent>,
|
||||||
mut achievement_tracker: ResMut<var::AchievementTracker>,
|
|
||||||
mut log: ResMut<hud::Log>,
|
mut log: ResMut<hud::Log>,
|
||||||
mut settings: ResMut<Settings>,
|
mut settings: ResMut<Settings>,
|
||||||
) {
|
) {
|
||||||
|
@ -171,7 +170,6 @@ fn handle_player_death(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
settings.reset_player_settings();
|
settings.reset_player_settings();
|
||||||
*achievement_tracker = var::AchievementTracker::default();
|
|
||||||
active_asteroids.0.clear();
|
active_asteroids.0.clear();
|
||||||
for entity in &q_noscenes {
|
for entity in &q_noscenes {
|
||||||
cmd.entity(entity).despawn();
|
cmd.entity(entity).despawn();
|
||||||
|
@ -338,7 +336,7 @@ fn debug(
|
||||||
keyboard_input: Res<ButtonInput<KeyCode>>,
|
keyboard_input: Res<ButtonInput<KeyCode>>,
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
mut extended_materials: ResMut<Assets<ExtendedMaterial<StandardMaterial, load::AsteroidSurface>>>,
|
mut extended_materials: ResMut<Assets<ExtendedMaterial<StandardMaterial, load::AsteroidSurface>>>,
|
||||||
achievement_tracker: Res<var::AchievementTracker>,
|
mut achievement_tracker: ResMut<var::AchievementTracker>,
|
||||||
materials: Query<(Entity, Option<&Name>, &Handle<Mesh>)>,
|
materials: Query<(Entity, Option<&Name>, &Handle<Mesh>)>,
|
||||||
) {
|
) {
|
||||||
if settings.dev_mode && keyboard_input.just_pressed(KeyCode::KeyP) {
|
if settings.dev_mode && keyboard_input.just_pressed(KeyCode::KeyP) {
|
||||||
|
@ -351,7 +349,7 @@ fn debug(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if settings.dev_mode && keyboard_input.just_pressed(KeyCode::KeyN) {
|
if settings.dev_mode && keyboard_input.just_pressed(KeyCode::KeyN) {
|
||||||
dbg!(achievement_tracker);
|
achievement_tracker.achieve_all();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
15
src/menu.rs
15
src/menu.rs
|
@ -88,7 +88,7 @@ pub fn setup(
|
||||||
let style_death = TextStyle {
|
let style_death = TextStyle {
|
||||||
font: font_handle.clone(),
|
font: font_handle.clone(),
|
||||||
font_size: settings.font_size_deathtext,
|
font_size: settings.font_size_deathtext,
|
||||||
color: settings.hud_color_subtitles,
|
color: settings.hud_color_death,
|
||||||
..default()
|
..default()
|
||||||
};
|
};
|
||||||
let style_death_poem = TextStyle {
|
let style_death_poem = TextStyle {
|
||||||
|
@ -100,13 +100,19 @@ pub fn setup(
|
||||||
let style_death_subtext = TextStyle {
|
let style_death_subtext = TextStyle {
|
||||||
font: font_handle.clone(),
|
font: font_handle.clone(),
|
||||||
font_size: settings.font_size_deathsubtext,
|
font_size: settings.font_size_deathsubtext,
|
||||||
color: settings.hud_color_subtitles,
|
color: settings.hud_color_death,
|
||||||
..default()
|
..default()
|
||||||
};
|
};
|
||||||
let style_death_subsubtext = TextStyle {
|
let style_death_subsubtext = TextStyle {
|
||||||
font: font_handle.clone(),
|
font: font_handle.clone(),
|
||||||
font_size: settings.font_size_deathsubtext * 0.8,
|
font_size: settings.font_size_deathsubtext * 0.8,
|
||||||
color: settings.hud_color_subtitles,
|
color: settings.hud_color_death,
|
||||||
|
..default()
|
||||||
|
};
|
||||||
|
let style_death_achievements = TextStyle {
|
||||||
|
font: font_handle.clone(),
|
||||||
|
font_size: settings.font_size_death_achievements,
|
||||||
|
color: settings.hud_color_death_achievements,
|
||||||
..default()
|
..default()
|
||||||
};
|
};
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
|
@ -126,6 +132,7 @@ pub fn setup(
|
||||||
TextSection::new("You are dead.\n", style_death),
|
TextSection::new("You are dead.\n", style_death),
|
||||||
TextSection::new("Cause: ", style_death_subtext.clone()),
|
TextSection::new("Cause: ", style_death_subtext.clone()),
|
||||||
TextSection::new("Unknown", style_death_subtext),
|
TextSection::new("Unknown", style_death_subtext),
|
||||||
|
TextSection::new("", style_death_achievements),
|
||||||
TextSection::new("\n\n\n\nPress E to begin anew.", style_death_subsubtext),
|
TextSection::new("\n\n\n\nPress E to begin anew.", style_death_subsubtext),
|
||||||
],
|
],
|
||||||
justify: JustifyText::Center,
|
justify: JustifyText::Center,
|
||||||
|
@ -247,6 +254,7 @@ pub fn show_deathscreen(
|
||||||
mut timer: ResMut<DeathScreenInputDelayTimer>,
|
mut timer: ResMut<DeathScreenInputDelayTimer>,
|
||||||
mut menustate: ResMut<MenuState>,
|
mut menustate: ResMut<MenuState>,
|
||||||
mut settings: ResMut<Settings>,
|
mut settings: ResMut<Settings>,
|
||||||
|
achievement_tracker: Res<var::AchievementTracker>,
|
||||||
) {
|
) {
|
||||||
for event in er_deathscreen.read() {
|
for event in er_deathscreen.read() {
|
||||||
let show = *event == DeathScreenEvent::Show;
|
let show = *event == DeathScreenEvent::Show;
|
||||||
|
@ -269,6 +277,7 @@ pub fn show_deathscreen(
|
||||||
text.sections[0].value = poem + "\n\n\n\n";
|
text.sections[0].value = poem + "\n\n\n\n";
|
||||||
}
|
}
|
||||||
text.sections[3].value = settings.death_cause.clone();
|
text.sections[3].value = settings.death_cause.clone();
|
||||||
|
text.sections[4].value = achievement_tracker.to_summary();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ew_respawnaudiosinks.send(audio::RespawnSinksEvent);
|
ew_respawnaudiosinks.send(audio::RespawnSinksEvent);
|
||||||
|
|
48
src/var.rs
48
src/var.rs
|
@ -56,6 +56,7 @@ pub struct Settings {
|
||||||
pub font_size_deathtext: f32,
|
pub font_size_deathtext: f32,
|
||||||
pub font_size_deathsubtext: f32,
|
pub font_size_deathsubtext: f32,
|
||||||
pub font_size_deathpoem: f32,
|
pub font_size_deathpoem: f32,
|
||||||
|
pub font_size_death_achievements: f32,
|
||||||
pub font_size_achievement: f32,
|
pub font_size_achievement: f32,
|
||||||
pub font_size_achievement_header: f32,
|
pub font_size_achievement_header: f32,
|
||||||
pub hud_color: Color,
|
pub hud_color: Color,
|
||||||
|
@ -71,6 +72,8 @@ pub struct Settings {
|
||||||
pub hud_color_achievement: Color,
|
pub hud_color_achievement: Color,
|
||||||
pub hud_color_achievement_header: Color,
|
pub hud_color_achievement_header: Color,
|
||||||
pub hud_color_achievement_accomplished: Color,
|
pub hud_color_achievement_accomplished: Color,
|
||||||
|
pub hud_color_death: Color,
|
||||||
|
pub hud_color_death_achievements: Color,
|
||||||
pub chat_speed: f32,
|
pub chat_speed: f32,
|
||||||
pub flashlight_active: bool,
|
pub flashlight_active: bool,
|
||||||
pub hud_active: bool,
|
pub hud_active: bool,
|
||||||
|
@ -174,6 +177,7 @@ impl Default for Settings {
|
||||||
font_size_deathtext: 64.0,
|
font_size_deathtext: 64.0,
|
||||||
font_size_deathsubtext: 32.0,
|
font_size_deathsubtext: 32.0,
|
||||||
font_size_deathpoem: 18.0,
|
font_size_deathpoem: 18.0,
|
||||||
|
font_size_death_achievements: 24.0,
|
||||||
font_size_achievement: 24.0,
|
font_size_achievement: 24.0,
|
||||||
font_size_achievement_header: 32.0,
|
font_size_achievement_header: 32.0,
|
||||||
hud_color: Color::hex("#BE1251").unwrap(),
|
hud_color: Color::hex("#BE1251").unwrap(),
|
||||||
|
@ -189,6 +193,8 @@ impl Default for Settings {
|
||||||
hud_color_achievement: Color::hex("#666666").unwrap(),
|
hud_color_achievement: Color::hex("#666666").unwrap(),
|
||||||
hud_color_achievement_accomplished: Color::hex("#F0D50C").unwrap(),
|
hud_color_achievement_accomplished: Color::hex("#F0D50C").unwrap(),
|
||||||
hud_color_achievement_header: Color::hex("#BE1251").unwrap(),
|
hud_color_achievement_header: Color::hex("#BE1251").unwrap(),
|
||||||
|
hud_color_death: Color::hex("#CCCCCC").unwrap(),
|
||||||
|
hud_color_death_achievements: Color::hex("#CCCCCC").unwrap(),
|
||||||
chat_speed: DEFAULT_CHAT_SPEED * if dev_mode { 2.5 } else { 1.0 },
|
chat_speed: DEFAULT_CHAT_SPEED * if dev_mode { 2.5 } else { 1.0 },
|
||||||
flashlight_active: false,
|
flashlight_active: false,
|
||||||
hud_active: true,
|
hud_active: true,
|
||||||
|
@ -324,6 +330,14 @@ impl AchievementTracker {
|
||||||
self.in_jupiters_shadow,
|
self.in_jupiters_shadow,
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
pub fn achieve_all(&mut self) {
|
||||||
|
self.repair_suit = true;
|
||||||
|
self.drink_a_pizza = true;
|
||||||
|
self.ride_every_vehicle = true;
|
||||||
|
self.talk_to_everyone = true;
|
||||||
|
self.find_earth = true;
|
||||||
|
self.in_jupiters_shadow = true;
|
||||||
|
}
|
||||||
pub fn to_textsections(&self) -> Vec<String> {
|
pub fn to_textsections(&self) -> Vec<String> {
|
||||||
fn collectible(current: usize, total: usize) -> String {
|
fn collectible(current: usize, total: usize) -> String {
|
||||||
if current < total {
|
if current < total {
|
||||||
|
@ -343,6 +357,40 @@ impl AchievementTracker {
|
||||||
"Let Jupiter Eclipse The Sun\n".to_string(),
|
"Let Jupiter Eclipse The Sun\n".to_string(),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
pub fn to_overview(&self) -> Vec<(bool, String)> {
|
||||||
|
vec![
|
||||||
|
(self.repair_suit, "repair your suit".into()),
|
||||||
|
(self.drink_a_pizza, "consume a pizza".into()),
|
||||||
|
(self.ride_every_vehicle, "ride every vehicle".into()),
|
||||||
|
(self.talk_to_everyone, "talk to everyone".into()),
|
||||||
|
(self.find_earth, "find Earth".into()),
|
||||||
|
(self.in_jupiters_shadow, "let Jupiter eclipse the Sun".into()),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
pub fn to_summary(&self) -> String {
|
||||||
|
let list = self.to_overview();
|
||||||
|
let count = list.iter().filter(|(achieved, _)| *achieved).count();
|
||||||
|
if count == 0 {
|
||||||
|
return "".to_string()
|
||||||
|
}
|
||||||
|
let mut summary = "\n\n\nYou managed to ".to_string();
|
||||||
|
for (i, (_, text)) in list.iter().filter(|(achieved, _)| *achieved).enumerate() {
|
||||||
|
summary += text.as_str();
|
||||||
|
if i + 2 == count {
|
||||||
|
summary += ", and ";
|
||||||
|
}
|
||||||
|
else if i + 1 == count {
|
||||||
|
summary += " before you perished.";
|
||||||
|
if count == list.len() {
|
||||||
|
summary += "\nA truly astounding achievement, a glimmer in the void, before it all fades, into nothingness.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
summary += ", ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
summary
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Resource, Deserialize, Debug, Default)]
|
#[derive(Resource, Deserialize, Debug, Default)]
|
||||||
|
|
|
@ -346,6 +346,8 @@ fn handle_despawn(
|
||||||
|
|
||||||
fn handle_respawn(
|
fn handle_respawn(
|
||||||
ew_spawn: EventWriter<cmd::SpawnEvent>,
|
ew_spawn: EventWriter<cmd::SpawnEvent>,
|
||||||
|
mut achievement_tracker: ResMut<var::AchievementTracker>,
|
||||||
) {
|
) {
|
||||||
|
*achievement_tracker = var::AchievementTracker::default();
|
||||||
cmd::load_defs(ew_spawn);
|
cmd::load_defs(ew_spawn);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue