jet engine sound

closes HEZ-32
This commit is contained in:
2025-04-14 00:10:28 +02:00
parent 33ddac2f18
commit 2e5ec8f3d8
3 changed files with 14 additions and 2 deletions

Binary file not shown.

View File

@@ -34,6 +34,8 @@ pub struct AudioAssets {
pub throw: Handle<AudioSource>, pub throw: Handle<AudioSource>,
#[asset(path = "sfx/abilities/throw-explosion.ogg")] #[asset(path = "sfx/abilities/throw-explosion.ogg")]
pub throw_explosion: Handle<AudioSource>, pub throw_explosion: Handle<AudioSource>,
#[asset(path = "sfx/abilities/jet.ogg")]
pub jet: Handle<AudioSource>,
#[asset(path = "sfx/ui/backpack_open.ogg")] #[asset(path = "sfx/ui/backpack_open.ogg")]
pub backpack_open: Handle<AudioSource>, pub backpack_open: Handle<AudioSource>,

View File

@@ -9,7 +9,7 @@ use crate::{
heads::HeadChanged, heads::HeadChanged,
heads_database::{HeadControls, HeadsDatabase}, heads_database::{HeadControls, HeadsDatabase},
hitpoints::Hitpoints, hitpoints::Hitpoints,
loading_assets::GameAssets, loading_assets::{AudioAssets, GameAssets},
physics_layers::GameLayer, physics_layers::GameLayer,
sounds::PlaySound, sounds::PlaySound,
tb_entities::SpawnPoint, tb_entities::SpawnPoint,
@@ -203,6 +203,7 @@ fn on_update_head(
head: Query<Entity, With<PlayerHeadMesh>>, head: Query<Entity, With<PlayerHeadMesh>>,
mut player_head: Query<&mut ActiveHead, With<Player>>, mut player_head: Query<&mut ActiveHead, With<Player>>,
head_db: Res<HeadsDatabase>, head_db: Res<HeadsDatabase>,
audio_assets: Res<AudioAssets>,
) { ) {
let Ok(head) = head.get_single() else { let Ok(head) = head.get_single() else {
return; return;
@@ -218,6 +219,7 @@ fn on_update_head(
commands.trigger(PlaySound::Head(head_str.to_string())); commands.trigger(PlaySound::Head(head_str.to_string()));
//TODO: load from dynamic asset collection? or keep lazy?
let mesh = asset_server let mesh = asset_server
.load(GltfAssetLabel::Scene(0).from_asset(format!("models/heads/{}.glb", head_str))); .load(GltfAssetLabel::Scene(0).from_asset(format!("models/heads/{}.glb", head_str)));
@@ -230,6 +232,14 @@ fn on_update_head(
commands commands
.entity(head) .entity(head)
.with_child((Transform::from_xyz(0., -1., 0.), SceneRoot(mesh))); .with_child((Transform::from_xyz(0., -1., 0.), SceneRoot(mesh)))
.with_child((
Name::new("sfx"),
AudioPlayer::new(audio_assets.jet.clone()),
PlaybackSettings {
mode: bevy::audio::PlaybackMode::Loop,
..Default::default()
},
));
} }
} }