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

@ -4,7 +4,7 @@
use bevy::prelude::*;
use building::{BuildingInfo, BuildingPreview, PREVIEW_ALPHA, PopulatePlacedBuilding};
use combat::{Defense, Health};
use combat::{DeathAudio, Defense, Health};
use combat_damagers::ContactDamage;
use resources::{Cost, Quantity};
use upgrade::{Upgrade, UpgradeApplied, UpgradeTree};
@ -25,6 +25,7 @@ struct ImpalerResources {
mesh: Handle<Mesh>,
material: Handle<StandardMaterial>,
info_entity: Entity,
death_audio: Handle<AudioSource>,
}
const SIZE: UVec3 = UVec3::ONE;
@ -33,6 +34,7 @@ fn register(
mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
assets: Res<AssetServer>,
) {
let mesh = meshes.add(Cuboid::from_length(1.0));
let base_material = StandardMaterial {
@ -143,6 +145,7 @@ fn register(
preview,
size: SIZE,
unlocked: true,
place_sound: assets.load("sounds/thump1.ogg"),
},
UpgradeTree { upgrades },
Cost(Quantity { souls: 5, bones: 0 }),
@ -153,6 +156,7 @@ fn register(
mesh: mesh,
material: material,
info_entity: info,
death_audio: assets.load("sounds/pop3.ogg"),
});
}
@ -168,6 +172,7 @@ fn populate(
Impaler,
ContactDamage::new(5.0),
Mesh3d(res.mesh.clone()),
DeathAudio(res.death_audio.clone()),
MeshMaterial3d(res.material.clone()),
));
}