add "Find Earth" achievement
This commit is contained in:
parent
c00a47fe7f
commit
fce2cfdce1
|
@ -18,6 +18,10 @@ use crate::prelude::*;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use std::time::SystemTime;
|
use std::time::SystemTime;
|
||||||
|
|
||||||
|
pub const ID_EARTH: &str = "earth";
|
||||||
|
pub const ID_SOL: &str = "sol";
|
||||||
|
pub const ID_JUPITER: &str = "jupiter";
|
||||||
|
|
||||||
pub struct CmdPlugin;
|
pub struct CmdPlugin;
|
||||||
impl Plugin for CmdPlugin {
|
impl Plugin for CmdPlugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
|
|
|
@ -35,6 +35,7 @@ actor 0 0 0
|
||||||
physics off
|
physics off
|
||||||
actor 0 0 0 earth
|
actor 0 0 0 earth
|
||||||
name Earth
|
name Earth
|
||||||
|
id earth
|
||||||
planet yes
|
planet yes
|
||||||
sphere yes
|
sphere yes
|
||||||
physics off
|
physics off
|
||||||
|
|
|
@ -49,6 +49,7 @@ pub enum AchievementEvent {
|
||||||
RideVehicle(String),
|
RideVehicle(String),
|
||||||
DrinkPizza,
|
DrinkPizza,
|
||||||
InJupitersShadow,
|
InJupitersShadow,
|
||||||
|
FindEarth,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Event)]
|
#[derive(Event)]
|
||||||
|
@ -379,6 +380,12 @@ fn handle_achievement_event(
|
||||||
}
|
}
|
||||||
tracker.drink_a_pizza = true;
|
tracker.drink_a_pizza = true;
|
||||||
}
|
}
|
||||||
|
AchievementEvent::FindEarth => {
|
||||||
|
if !tracker.find_earth {
|
||||||
|
ew_game.send(GameEvent::Achievement("Find Earth".into()));
|
||||||
|
}
|
||||||
|
tracker.find_earth = true;
|
||||||
|
}
|
||||||
AchievementEvent::RideVehicle(name) => {
|
AchievementEvent::RideVehicle(name) => {
|
||||||
tracker.vehicles_ridden.insert(name.clone());
|
tracker.vehicles_ridden.insert(name.clone());
|
||||||
let len = tracker.vehicles_ridden.len();
|
let len = tracker.vehicles_ridden.len();
|
||||||
|
|
|
@ -974,7 +974,9 @@ fn handle_target_event(
|
||||||
settings: Res<Settings>,
|
settings: Res<Settings>,
|
||||||
mut er_target: EventReader<TargetEvent>,
|
mut er_target: EventReader<TargetEvent>,
|
||||||
mut ew_sfx: EventWriter<audio::PlaySfxEvent>,
|
mut ew_sfx: EventWriter<audio::PlaySfxEvent>,
|
||||||
|
mut ew_achievement: EventWriter<game::AchievementEvent>,
|
||||||
q_target: Query<Entity, With<IsTargeted>>,
|
q_target: Query<Entity, With<IsTargeted>>,
|
||||||
|
q_ids: Query<&actor::Identifier>,
|
||||||
) {
|
) {
|
||||||
let mut play_sfx = false;
|
let mut play_sfx = false;
|
||||||
|
|
||||||
|
@ -986,6 +988,12 @@ fn handle_target_event(
|
||||||
if let Some(entity) = target {
|
if let Some(entity) = target {
|
||||||
commands.entity(*entity).insert(IsTargeted);
|
commands.entity(*entity).insert(IsTargeted);
|
||||||
play_sfx = true;
|
play_sfx = true;
|
||||||
|
|
||||||
|
if let Ok(id) = q_ids.get(*entity) {
|
||||||
|
if id.0 == cmd::ID_EARTH {
|
||||||
|
ew_achievement.send(game::AchievementEvent::FindEarth);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if play_sfx && !settings.mute_sfx {
|
if play_sfx && !settings.mute_sfx {
|
||||||
ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::Click));
|
ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::Click));
|
||||||
|
|
|
@ -71,6 +71,7 @@ pub enum MenuAction {
|
||||||
pub fn setup(
|
pub fn setup(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
asset_server: Res<AssetServer>,
|
asset_server: Res<AssetServer>,
|
||||||
|
achievement_tracker: Res<var::AchievementTracker>,
|
||||||
settings: Res<Settings>,
|
settings: Res<Settings>,
|
||||||
) {
|
) {
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
|
@ -195,6 +196,7 @@ pub fn setup(
|
||||||
color: settings.hud_color_achievement,
|
color: settings.hud_color_achievement,
|
||||||
..default()
|
..default()
|
||||||
};
|
};
|
||||||
|
let achievement_count = achievement_tracker.to_bool_vec().len();
|
||||||
|
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
MenuElement,
|
MenuElement,
|
||||||
|
@ -215,7 +217,7 @@ pub fn setup(
|
||||||
let mut sections = vec![
|
let mut sections = vec![
|
||||||
TextSection::new("Achievements\n", style_achievement_header)
|
TextSection::new("Achievements\n", style_achievement_header)
|
||||||
];
|
];
|
||||||
sections.extend(Vec::from_iter((0..var::ACHIEVEMENT_COUNT).map(|_|
|
sections.extend(Vec::from_iter((0..achievement_count).map(|_|
|
||||||
TextSection::new("", style_achievement.clone())
|
TextSection::new("", style_achievement.clone())
|
||||||
)));
|
)));
|
||||||
builder.spawn((
|
builder.spawn((
|
||||||
|
|
|
@ -20,7 +20,6 @@ use toml_edit::DocumentMut;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
||||||
pub const ACHIEVEMENT_COUNT: usize = 5;
|
|
||||||
pub const SCOPE_SEPARATOR: &str = "$";
|
pub const SCOPE_SEPARATOR: &str = "$";
|
||||||
|
|
||||||
pub const TOKEN_EQUALS: &str = "==";
|
pub const TOKEN_EQUALS: &str = "==";
|
||||||
|
@ -303,6 +302,7 @@ pub struct AchievementTracker {
|
||||||
pub repair_suit: bool,
|
pub repair_suit: bool,
|
||||||
pub drink_a_pizza: bool,
|
pub drink_a_pizza: bool,
|
||||||
pub in_jupiters_shadow: bool,
|
pub in_jupiters_shadow: bool,
|
||||||
|
pub find_earth: bool,
|
||||||
|
|
||||||
pub ride_every_vehicle: bool,
|
pub ride_every_vehicle: bool,
|
||||||
pub vehicles_ridden: HashSet<String>,
|
pub vehicles_ridden: HashSet<String>,
|
||||||
|
@ -320,6 +320,7 @@ impl AchievementTracker {
|
||||||
self.drink_a_pizza,
|
self.drink_a_pizza,
|
||||||
self.ride_every_vehicle,
|
self.ride_every_vehicle,
|
||||||
self.talk_to_everyone,
|
self.talk_to_everyone,
|
||||||
|
self.find_earth,
|
||||||
self.in_jupiters_shadow,
|
self.in_jupiters_shadow,
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -338,6 +339,8 @@ impl AchievementTracker {
|
||||||
format!("Talk To Everyone ({}/{})\n",
|
format!("Talk To Everyone ({}/{})\n",
|
||||||
self.people_talked_to.len(),
|
self.people_talked_to.len(),
|
||||||
self.all_people.len()),
|
self.all_people.len()),
|
||||||
|
format!("Find Earth ({})\n",
|
||||||
|
bool2string(self.find_earth)),
|
||||||
format!("Let Jupiter Eclipse The Sun ({})\n",
|
format!("Let Jupiter Eclipse The Sun ({})\n",
|
||||||
bool2string(self.in_jupiters_shadow)),
|
bool2string(self.in_jupiters_shadow)),
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in a new issue