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::{Defense, Health, Team};
use combat::{DeathAudio, Defense, Health, Team};
use combat_damagers::ContactDamage;
use inhabitant::Inhabitant;
use inhabitant_simbert::SpawnSimbert;
@ -40,6 +40,7 @@ pub struct SpawnEndrake {
struct EndrakeResources {
material: Handle<StandardMaterial>,
mesh: Handle<Mesh>,
death_sound: Handle<AudioSource>,
}
const BASE_RADIUS: f32 = 3.;
@ -50,6 +51,7 @@ fn init(
mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
assets: Res<AssetServer>,
) {
commands.insert_resource(EndrakeResources {
material: materials.add(StandardMaterial {
@ -64,6 +66,7 @@ fn init(
radius_bottom: BASE_RADIUS,
height: HEIGHT,
}),
death_sound: assets.load("sounds/weird1.ogg"),
});
}
fn spawn(
@ -74,20 +77,23 @@ fn spawn(
) {
for SpawnEndrake { transform } in reader.read() {
commands.spawn((
RigidBody::Dynamic,
Collider::cuboid(TOP_RADIUS * 2., HEIGHT, TOP_RADIUS * 2.),
Mesh3d(res.mesh.clone()),
MeshMaterial3d(res.material.clone()),
MaxLinearSpeed(0.5),
Mass(10.),
Endrake {
spawn_timer: Timer::from_seconds(2.0, TimerMode::Repeating),
spawn_count: 10,
},
Drops(Quantity {
souls: 50,
bones: 25,
}),
(
RigidBody::Dynamic,
Collider::cuboid(TOP_RADIUS * 2., HEIGHT, TOP_RADIUS * 2.),
Mesh3d(res.mesh.clone()),
MeshMaterial3d(res.material.clone()),
MaxLinearSpeed(0.5),
Mass(10.),
Endrake {
spawn_timer: Timer::from_seconds(2.0, TimerMode::Repeating),
spawn_count: 10,
},
Drops(Quantity {
souls: 50,
bones: 25,
}),
),
DeathAudio(res.death_sound.clone()),
transform.clone(),
Health::new(2000.0 + 100. * phase.get().phase_count() as f32),
Defense::new(5.),