add suffocation sound effects

This commit is contained in:
yuni 2024-06-07 23:55:04 +02:00
parent 727d28089f
commit 1433773784
3 changed files with 28 additions and 0 deletions

BIN
assets/sounds/gasp.ogg Normal file

Binary file not shown.

Binary file not shown.

View file

@ -23,6 +23,7 @@ impl Plugin for AudioPlugin {
Update,
(
play_zoom_sfx,
play_gasp_sfx,
respawn_sinks.run_if(on_event::<RespawnSinksEvent>()),
pause_all.run_if(on_event::<PauseAllSfxEvent>()),
),
@ -64,6 +65,8 @@ const PATHS: &[(SfxType, Sfx, &str)] = &[
(SfxType::LoopSfx, Sfx::Ion, "sounds/ion.ogg"),
(SfxType::LoopSfx, Sfx::Rocket, "sounds/rocket.ogg"),
(SfxType::LoopSfx, Sfx::Thruster, "sounds/thruster.ogg"),
(SfxType::LoopSfx, Sfx::Gasp, "sounds/gasp.ogg"),
(SfxType::OneOff, Sfx::GaspRelief, "sounds/gasprelief.ogg"),
(SfxType::OneOff, Sfx::Achieve, "sounds/achieve.ogg"),
(
SfxType::OneOff,
@ -99,6 +102,8 @@ pub enum Sfx {
Crash,
ElectricMotor,
EnterVehicle,
Gasp,
GaspRelief,
IncomingChatMessage,
Ion,
Ping,
@ -272,6 +277,29 @@ pub fn play_zoom_sfx(
}
}
pub fn play_gasp_sfx(
player: Query<&actor::Suit, With<actor::Player>>,
mut ew_sfx: EventWriter<PlaySfxEvent>,
q_audiosinks: Query<(&audio::Sfx, &AudioSink)>,
) {
if let Ok(suit) = player.get_single() {
for (sfxtype, sink) in &q_audiosinks {
if *sfxtype != Sfx::Gasp {
continue;
}
if suit.oxygen <= 0.0 {
sink.set_volume(0.6);
sink.play();
} else {
if !sink.is_paused() {
ew_sfx.send(PlaySfxEvent(Sfx::GaspRelief));
sink.pause();
}
}
}
}
}
pub fn pause_all(q_audiosinks: Query<&AudioSink, With<Sfx>>) {
for sink in &q_audiosinks {
sink.pause();