Add new sound effects and sprites; refactor sound management

- Added new audio files for sound effects including pop sounds, phone ring, gym bro, and manager get out.
- Introduced new sprites for character animations and icons.
- Removed outdated sprite files to clean up the project.
- Updated project configuration to reflect new icon and name changes.
- Enhanced the sound manager to handle new sound effects and manage active hazard sounds more effectively.
- Refactored hazard spawning and resolution logic to utilize new sound effects based on hazard types.
This commit is contained in:
2026-01-24 20:56:50 +01:00
parent 77ae997af4
commit cdfd4cbbd2
76 changed files with 593 additions and 422 deletions

View File

@@ -1,6 +1,6 @@
use godot::{classes::SpriteFrames, prelude::*};
#[derive(GodotConvert, Export, Var, Default, Clone, PartialEq, Eq, Debug)]
#[derive(GodotConvert, Export, Var, Default, Clone, PartialEq, Eq, Debug, Hash)]
#[godot(via=GString)]
pub enum HazardType {
#[default]

View File

@@ -19,6 +19,12 @@ pub struct SoundBank {
pub hazard_resolve: Option<Gd<AudioStream>>,
#[export]
pub camera_trauma: Option<Gd<AudioStream>>,
#[export]
pub phone_ring: Option<Gd<AudioStream>>,
#[export]
pub gym_bro: Option<Gd<AudioStream>>,
#[export]
pub manager_get_out: Option<Gd<AudioStream>>,
#[export]
pub menu_music: Option<Gd<AudioStream>>,
@@ -40,6 +46,9 @@ impl IResource for SoundBank {
hazard_spawn: None,
hazard_resolve: None,
camera_trauma: None,
phone_ring: None,
gym_bro: None,
manager_get_out: None,
menu_music: None,
game_music: None,
base,

View File

@@ -1,4 +1,10 @@
use crate::{consts, core::event_bus::EventBus, data::sound_bank::SoundBank};
use std::collections::HashMap;
use crate::{
consts,
core::event_bus::EventBus,
data::{hazard_def::HazardType, sound_bank::SoundBank},
};
use godot::{
classes::{AudioServer, AudioStream, AudioStreamPlayer},
prelude::*,
@@ -24,6 +30,7 @@ pub struct SoundManager {
is_lifting: bool,
current_lift_progress: f32,
active_hazard_sounds: HashMap<HazardType, usize>,
master_bus_idx: i32,
music_bus_idx: i32,
@@ -50,6 +57,7 @@ impl INode for SoundManager {
master_bus_idx: audio_server.get_bus_index("Master"),
music_bus_idx: audio_server.get_bus_index("Music"),
sfx_bus_idx: audio_server.get_bus_index("Sfx"),
active_hazard_sounds: HashMap::new(),
event_bus: None,
base,
}
@@ -116,16 +124,18 @@ impl SoundManager {
self.bank.as_ref().and_then(|b| selector(&b.bind()))
}
fn play_bank_sfx<F>(&mut self, selector: F, pitch: f32)
fn play_bank_sfx<F>(&mut self, selector: F, pitch: f32) -> Option<usize>
where
F: FnOnce(&SoundBank) -> Option<Gd<AudioStream>>,
{
if let Some(clip) = self.get_stream(selector) {
self.play_sfx(clip, pitch);
self.play_sfx(clip, pitch)
} else {
None
}
}
fn play_sfx(&mut self, clip: Gd<AudioStream>, pitch: f32) {
fn play_sfx(&mut self, clip: Gd<AudioStream>, pitch: f32) -> Option<usize> {
let mut chosen_index = None;
for (i, p) in self.sfx_pool.iter_mut().enumerate() {
@@ -149,12 +159,16 @@ impl SoundManager {
}
if let Some(idx) = chosen_index {
self.active_hazard_sounds.retain(|_, v| *v != idx);
if let Some(p) = self.sfx_pool.get_mut(idx) {
p.set_stream(&clip);
p.set_pitch_scale(pitch);
p.play();
}
}
chosen_index
}
fn play_music(&mut self, clip: Gd<AudioStream>) {
@@ -238,13 +252,28 @@ impl SoundManager {
}
#[func]
fn on_hazard_resolved(&mut self, _type: String) {
fn on_hazard_resolved(&mut self, hazard_type: HazardType) {
if let Some(idx) = self.active_hazard_sounds.remove(&hazard_type) {
if let Some(p) = self.sfx_pool.get_mut(idx) {
p.stop();
}
}
self.play_bank_sfx(|b| b.hazard_resolve.clone(), 1.0);
}
#[func]
fn on_hazard_spawned(&mut self, _type: String) {
self.play_bank_sfx(|b| b.hazard_spawn.clone(), 1.0);
fn on_hazard_spawned(&mut self, hazard_type: HazardType) {
let player_idx = match hazard_type {
HazardType::GymBro => self.play_bank_sfx(|b| b.gym_bro.clone(), 1.0),
HazardType::PhoneDistraction => self.play_bank_sfx(|b| b.phone_ring.clone(), 1.0),
HazardType::Manager => self.play_bank_sfx(|b| b.manager_get_out.clone(), 1.0),
_ => self.play_bank_sfx(|b| b.hazard_spawn.clone(), 1.0),
};
if let Some(idx) = player_idx {
self.active_hazard_sounds.insert(hazard_type, idx);
}
}
#[func]