* Get bevy 0.17 compiling and running (#72) * get bevy 0.17 compiling and running * try to fix CI breaking from const assertion for client/server features * fix `bin` -> `lib` for `shared` in CI * typo * fix some collider issues (#73) * Physics/controller improvements (#74) * trying to fix physics prediction * fixed prediction desync * substantial controller improvements * Finish off main bevy 0.17 migration (#75) * fix lookdir issues - airplane moving backwards - player model facing backwards - camera was technically backwards the whole time, and player models were facing the right way; camera is now facing forwards - firing without a target now respects lookdir * fix aim targeting * migrate to bevy_trenchbroom 0.10 crates release * fixed colliders not being adjusted out of worldspace * predict platforms to stop constant rollbacks while riding them * fix key/head drop visuals not working * Fix key/head drop random initial force * fixed static head drops duplicating * fix platform velocity inheritance * fix thrown projectiles not autorotating * fix inconsistent explosion animations * update avian3d to 0.4.1 * fix controller snapping to fixed angle upon switching heads * clean up commented code * fix broken physics positions * Clean comments, fix warnings (#77) * clean comments, fix warnings * fix missing import * steamworks 162 libs * fix mouselook --------- Co-authored-by: extrawurst <mail@rusticorn.com>
68 lines
2.2 KiB
Rust
68 lines
2.2 KiB
Rust
use crate::{global_observer, loading_assets::AudioAssets};
|
|
use bevy::prelude::*;
|
|
use shared::protocol::PlaySound;
|
|
|
|
pub fn plugin(app: &mut App) {
|
|
global_observer!(app, on_spawn_sounds);
|
|
}
|
|
|
|
fn on_spawn_sounds(
|
|
trigger: On<PlaySound>,
|
|
mut commands: Commands,
|
|
// settings: SettingsRead,
|
|
assets: Res<AudioAssets>,
|
|
) {
|
|
let event = trigger.event();
|
|
|
|
// if !settings.is_sound_on() {
|
|
// continue;
|
|
// }
|
|
|
|
let source = match event {
|
|
PlaySound::Hit => {
|
|
let version = rand::random::<u8>() % 3;
|
|
assets.hit[version as usize].clone()
|
|
}
|
|
PlaySound::KeyCollect => assets.key_collect.clone(),
|
|
PlaySound::Gun => assets.gun.clone(),
|
|
PlaySound::Crossbow => assets.crossbow.clone(),
|
|
PlaySound::Gate => assets.gate.clone(),
|
|
PlaySound::CashCollect => assets.cash_collect.clone(),
|
|
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::CashHeal => assets.cash_heal.clone(),
|
|
PlaySound::HeadDrop => assets.head_drop.clone(),
|
|
PlaySound::HeadCollect => assets.head_collect.clone(),
|
|
PlaySound::SecretHeadCollect => assets.secret_head_collect.clone(),
|
|
PlaySound::MissileExplosion => assets.missile_explosion.clone(),
|
|
PlaySound::Beaming => assets.beaming.clone(),
|
|
PlaySound::Backpack { open } => {
|
|
if *open {
|
|
assets.backpack_open.clone()
|
|
} else {
|
|
assets.backpack_close.clone()
|
|
}
|
|
}
|
|
PlaySound::Head(name) => {
|
|
let filename = format!("{name}.ogg");
|
|
assets
|
|
.head
|
|
.get(filename.as_str())
|
|
.unwrap_or_else(|| panic!("invalid head '{filename}'"))
|
|
.clone()
|
|
}
|
|
};
|
|
|
|
commands.spawn((
|
|
Name::new("sfx"),
|
|
AudioPlayer::new(source),
|
|
PlaybackSettings {
|
|
mode: bevy::audio::PlaybackMode::Despawn,
|
|
..Default::default()
|
|
},
|
|
));
|
|
}
|