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

@ -5,7 +5,7 @@
use avian3d::prelude::*;
use bevy::prelude::*;
use building::Core;
use combat::{GaveDamage, Health, Team};
use combat::{DeathAudio, GaveDamage, Health, Team};
use combat_damagers::ContactDamage;
use inhabitant::Inhabitant;
use state::{BasePhaseState, GameSystemSet};
@ -35,12 +35,14 @@ struct CoranthResources {
material: Handle<StandardMaterial>,
mesh: Handle<Mesh>,
charge_timer: Timer,
death_sound: Handle<AudioSource>,
}
fn init(
mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
assets: Res<AssetServer>,
) {
commands.insert_resource(CoranthResources {
material: materials.add(StandardMaterial {
@ -51,6 +53,7 @@ fn init(
}),
mesh: meshes.add(Sphere::new(0.25)),
charge_timer: Timer::from_seconds(1.5, TimerMode::Repeating),
death_sound: assets.load("sounds/gasp1.ogg"),
});
}
fn spawn(
@ -69,6 +72,7 @@ fn spawn(
MeshMaterial3d(res.material.clone()),
MaxLinearSpeed(25.),
Coranth,
DeathAudio(res.death_sound.clone()),
transform.clone(),
Health::new(1.0 + phase as f32),
ContactDamage::new(if phase < 8 { 4.0 } else { 5.0 }),