Skip to content

Commit

Permalink
Add backspace sfx for Refactor upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
necrashter committed Dec 9, 2023
1 parent b53fa84 commit af0c7ea
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
Binary file added assets/audio/backspace0.ogg
Binary file not shown.
18 changes: 13 additions & 5 deletions src/audio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ impl Plugin for AudioPlugin {
pub enum SoundEffectKind {
DefaultUpgrade,
Keyboard,
Backspace,
}

#[derive(AssetCollection, Resource, Reflect, Default)]
Expand All @@ -33,18 +34,25 @@ pub struct AudioAssets {
collection(typed)
)]
pub keyboard_sounds: Vec<Handle<AudioSource>>,
#[asset(path = "audio/backspace0.ogg")]
pub backspace_sound: Handle<AudioSource>,
#[asset(path = "music/ingame.ogg")]
pub music: Handle<AudioSource>,
}

impl AudioAssets {
pub fn get_sfx(&self, kind: SoundEffectKind) -> Handle<AudioSource> {
use SoundEffectKind::*;
let options: &Vec<Handle<AudioSource>> = match kind {
DefaultUpgrade => &self.upgrade_sounds,
Keyboard => &self.keyboard_sounds,
};
options.choose(&mut thread_rng()).unwrap().clone()
macro_rules! select_from {
($a:expr) => {
$a.choose(&mut thread_rng()).unwrap().clone()
};
}
match kind {
DefaultUpgrade => select_from!(self.upgrade_sounds),
Keyboard => select_from!(self.keyboard_sounds),
Backspace => self.backspace_sound.clone(),
}
}
}

Expand Down
1 change: 1 addition & 0 deletions src/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,7 @@ generate_upgrade_list!(
Refactor: Upgrade {
name: "Refactor".to_string(),
desc: "Improves the quality of the codebase.".to_string(),
sound: Some(SoundEffectKind::Backspace),
tech_debt: -5.0,
base_cost: 10.0,
cost_scale_factor: 1.5,
Expand Down

0 comments on commit af0c7ea

Please sign in to comment.