add sound effects

This commit is contained in:
Jim 2025-09-02 21:13:21 -04:00
parent 86f2345667
commit 587b902e79
Signed by: jim
GPG key ID: 3D7D94BA53088BF4
39 changed files with 234 additions and 40 deletions

View file

@ -6,6 +6,7 @@ edition = "2024"
[dependencies]
bevy = { workspace = true }
avian3d = { workspace = true }
rand = { workspace = true }
combat = { path = "../combat" }
state = { path = "../state" }
resources = { path = "../resources" }

View file

@ -10,6 +10,7 @@ use bevy::{
};
use combat::{Defense, Health, Range, Team};
use input::Selectable;
use rand::{Rng, thread_rng};
use resources::{Cost, Resources};
use state::GameSystemSet;
use ui_health_bar::BarSettings;
@ -45,6 +46,7 @@ pub struct BuildingInfo {
pub preview: Entity,
pub size: UVec3,
pub unlocked: bool,
pub place_sound: Handle<AudioSource>,
}
impl BuildingInfo {
@ -189,6 +191,16 @@ fn place_building(
continue;
}
commands.spawn((
AudioPlayer(info.place_sound.clone()),
PlaybackSettings {
mode: bevy::audio::PlaybackMode::Despawn,
speed: thread_rng().gen_range(0.8..1.2),
spatial: false,
..default()
},
Transform::from_translation(position),
));
let mut ec = commands.spawn((
// adjust model up slightly so base of all towers are aligned
Transform::from_translation(position),