initial hit sounds

This commit is contained in:
Llywelwyn 2023-10-14 21:04:24 +01:00
parent 7ac2e14471
commit be7ff6b895
6 changed files with 26 additions and 0 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -15,6 +15,7 @@ use crate::{
HungerState, HungerState,
Bleeds, Bleeds,
HasDamageModifiers, HasDamageModifiers,
DamageType,
}; };
use crate::gui::with_article; use crate::gui::with_article;
use crate::consts::visuals::{ DEFAULT_PARTICLE_LIFETIME, LONG_PARTICLE_LIFETIME }; use crate::consts::visuals::{ DEFAULT_PARTICLE_LIFETIME, LONG_PARTICLE_LIFETIME };
@ -99,6 +100,27 @@ pub fn inflict_damage(ecs: &mut World, damage: &EffectSpawner, target: Entity) {
} else if let Some(_destructible) = ecs.read_storage::<Destructible>().get(target) { } else if let Some(_destructible) = ecs.read_storage::<Destructible>().get(target) {
add_effect(damage.source, EffectType::EntityDeath, Targets::Entity { target }); add_effect(damage.source, EffectType::EntityDeath, Targets::Entity { target });
} }
if let EffectType::Damage { amount: _, damage_type } = &damage.effect_type {
get_random_damage_sound(ecs, damage_type, target);
}
}
fn get_random_damage_sound(ecs: &World, damage_type: &DamageType, target: Entity) {
let mut rng = ecs.write_resource::<RandomNumberGenerator>();
match damage_type {
DamageType::Physical => {
let sound = (
match rng.roll_dice(1, 4) {
1 => "whoosh1",
2 => "whoosh2",
3 => "whoosh3",
_ => "whoosh4",
}
).to_string();
add_effect(None, EffectType::Sound { sound }, Targets::Entity { target });
}
_ => {}
}
} }
pub fn heal_damage(ecs: &mut World, heal: &EffectSpawner, target: Entity) { pub fn heal_damage(ecs: &mut World, heal: &EffectSpawner, target: Entity) {

View file

@ -76,6 +76,10 @@ pub fn init_sounds(app: &mut App) {
let sound_data: &[(&str, &[u8], AudioType)] = &[ let sound_data: &[(&str, &[u8], AudioType)] = &[
// (key, file_path, audiotype) // (key, file_path, audiotype)
("a_relax", include_bytes!("../../resources/sounds/amb/relaxed.ogg"), AudioType::Ambient), ("a_relax", include_bytes!("../../resources/sounds/amb/relaxed.ogg"), AudioType::Ambient),
("whoosh1", include_bytes!("../../resources/sounds/hit/whoosh1.ogg"), AudioType::SFX),
("whoosh2", include_bytes!("../../resources/sounds/hit/whoosh2.ogg"), AudioType::SFX),
("whoosh3", include_bytes!("../../resources/sounds/hit/whoosh3.ogg"), AudioType::SFX),
("whoosh4", include_bytes!("../../resources/sounds/hit/whoosh4.ogg"), AudioType::SFX),
("d_blocked1", include_bytes!("../../resources/sounds/door/blocked1.wav"), AudioType::SFX), ("d_blocked1", include_bytes!("../../resources/sounds/door/blocked1.wav"), AudioType::SFX),
("d_blocked2", include_bytes!("../../resources/sounds/door/blocked2.wav"), AudioType::SFX), ("d_blocked2", include_bytes!("../../resources/sounds/door/blocked2.wav"), AudioType::SFX),
("d_blocked3", include_bytes!("../../resources/sounds/door/blocked3.wav"), AudioType::SFX), ("d_blocked3", include_bytes!("../../resources/sounds/door/blocked3.wav"), AudioType::SFX),