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