sound effects of reloading
This commit is contained in:
BIN
assets/sfx/ui/invalid.ogg
Normal file
BIN
assets/sfx/ui/invalid.ogg
Normal file
Binary file not shown.
BIN
assets/sfx/ui/reloaded.ogg
Normal file
BIN
assets/sfx/ui/reloaded.ogg
Normal file
Binary file not shown.
@@ -6,6 +6,7 @@ use crate::{
|
||||
heads::ActiveHeads,
|
||||
npc::Hit,
|
||||
player::{Player, PlayerRig},
|
||||
sounds::PlaySound,
|
||||
tb_entities::EnemySpawn,
|
||||
};
|
||||
use avian3d::prelude::*;
|
||||
@@ -90,7 +91,7 @@ fn on_trigger_state(
|
||||
};
|
||||
|
||||
if !state.has_ammo() {
|
||||
//TOOD: play sound
|
||||
commands.trigger(PlaySound::Invalid);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||
commands.insert_resource(HeadsImages { heads });
|
||||
}
|
||||
|
||||
fn reload(mut active: ResMut<ActiveHeads>, time: Res<Time>) {
|
||||
fn reload(mut commands: Commands, mut active: ResMut<ActiveHeads>, time: Res<Time>) {
|
||||
if !active.reloading() {
|
||||
return;
|
||||
}
|
||||
@@ -144,6 +144,7 @@ fn reload(mut active: ResMut<ActiveHeads>, time: Res<Time>) {
|
||||
};
|
||||
|
||||
if !head.has_ammo() && (head.last_use + head.reload_duration <= time.elapsed_secs()) {
|
||||
commands.trigger(PlaySound::Reloaded);
|
||||
head.ammo = head.ammo_max;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,11 @@ pub struct AudioAssets {
|
||||
#[asset(path = "sfx/ui/selection.ogg")]
|
||||
pub selection: Handle<AudioSource>,
|
||||
|
||||
#[asset(path = "sfx/ui/invalid.ogg")]
|
||||
pub invalid: Handle<AudioSource>,
|
||||
#[asset(path = "sfx/ui/reloaded.ogg")]
|
||||
pub reloaded: Handle<AudioSource>,
|
||||
|
||||
#[asset(path = "sfx/abilities/throw.ogg")]
|
||||
pub throw: Handle<AudioSource>,
|
||||
#[asset(path = "sfx/abilities/throw-explosion.ogg")]
|
||||
|
||||
@@ -11,6 +11,8 @@ pub enum PlaySound {
|
||||
Gate,
|
||||
CashCollect,
|
||||
Selection,
|
||||
Invalid,
|
||||
Reloaded,
|
||||
Backpack { open: bool },
|
||||
Head(String),
|
||||
}
|
||||
@@ -44,6 +46,8 @@ fn spawn_sounds(
|
||||
PlaySound::Selection => assets.selection.clone(),
|
||||
PlaySound::Throw => assets.throw.clone(),
|
||||
PlaySound::ThrowHit => assets.throw_explosion.clone(),
|
||||
PlaySound::Reloaded => assets.reloaded.clone(),
|
||||
PlaySound::Invalid => assets.invalid.clone(),
|
||||
PlaySound::Backpack { open } => {
|
||||
if *open {
|
||||
assets.backpack_open.clone()
|
||||
|
||||
Reference in New Issue
Block a user