From f9ba6aa1b0bd6a280b37de49d4901c7bccf73fd9 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Mon, 9 Feb 2026 01:04:53 -0800 Subject: [PATCH] Add MountSoundManager skeleton for mount audio Implement framework for playing mount sounds (flapping, galloping) based on mount type and movement state. Actual sound playback to be implemented next. --- CMakeLists.txt | 2 + include/audio/mount_sound_manager.hpp | 58 +++++++++++ include/rendering/renderer.hpp | 4 +- src/audio/mount_sound_manager.cpp | 133 ++++++++++++++++++++++++++ src/rendering/renderer.cpp | 2 + 5 files changed, 198 insertions(+), 1 deletion(-) create mode 100644 include/audio/mount_sound_manager.hpp create mode 100644 src/audio/mount_sound_manager.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 792e56fe..e2eb88c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -103,6 +103,7 @@ set(WOWEE_SOURCES src/audio/music_manager.cpp src/audio/footstep_manager.cpp src/audio/activity_sound_manager.cpp + src/audio/mount_sound_manager.cpp # Pipeline (asset loaders) src/pipeline/mpq_manager.cpp @@ -199,6 +200,7 @@ set(WOWEE_HEADERS include/audio/music_manager.hpp include/audio/footstep_manager.hpp include/audio/activity_sound_manager.hpp + include/audio/mount_sound_manager.hpp include/pipeline/mpq_manager.hpp include/pipeline/blp_loader.hpp diff --git a/include/audio/mount_sound_manager.hpp b/include/audio/mount_sound_manager.hpp new file mode 100644 index 00000000..5a586379 --- /dev/null +++ b/include/audio/mount_sound_manager.hpp @@ -0,0 +1,58 @@ +#pragma once + +#include +#include + +namespace wowee { +namespace pipeline { class AssetManager; } + +namespace audio { + +enum class MountType { + NONE, + GROUND, // Horse, wolf, raptor, etc. + FLYING, // Griffin, wyvern, drake, etc. + SWIMMING // Sea turtle, etc. +}; + +class MountSoundManager { +public: + MountSoundManager(); + ~MountSoundManager(); + + bool initialize(pipeline::AssetManager* assets); + void shutdown(); + void update(float deltaTime); + + // Called when mounting/dismounting + void onMount(uint32_t creatureDisplayId, bool isFlying); + void onDismount(); + + // Update movement state + void setMoving(bool moving); + void setFlying(bool flying); + void setGrounded(bool grounded); + + bool isMounted() const { return mounted_; } + void setVolumeScale(float scale) { volumeScale_ = scale; } + +private: + MountType detectMountType(uint32_t creatureDisplayId) const; + void updateMountSounds(); + void stopAllMountSounds(); + + pipeline::AssetManager* assetManager_ = nullptr; + bool mounted_ = false; + bool moving_ = false; + bool flying_ = false; + MountType currentMountType_ = MountType::NONE; + uint32_t currentDisplayId_ = 0; + float volumeScale_ = 1.0f; + + // Sound state tracking + bool playingMovementSound_ = false; + bool playingIdleSound_ = false; +}; + +} // namespace audio +} // namespace wowee diff --git a/include/rendering/renderer.hpp b/include/rendering/renderer.hpp index e72ae52e..69f65ae9 100644 --- a/include/rendering/renderer.hpp +++ b/include/rendering/renderer.hpp @@ -8,7 +8,7 @@ namespace wowee { namespace core { class Window; } namespace game { class World; class ZoneManager; } -namespace audio { class MusicManager; class FootstepManager; class ActivitySoundManager; enum class FootstepSurface : uint8_t; } +namespace audio { class MusicManager; class FootstepManager; class ActivitySoundManager; class MountSoundManager; enum class FootstepSurface : uint8_t; } namespace pipeline { class AssetManager; } namespace rendering { @@ -147,6 +147,7 @@ public: audio::MusicManager* getMusicManager() { return musicManager.get(); } audio::FootstepManager* getFootstepManager() { return footstepManager.get(); } audio::ActivitySoundManager* getActivitySoundManager() { return activitySoundManager.get(); } + audio::MountSoundManager* getMountSoundManager() { return mountSoundManager.get(); } private: core::Window* window = nullptr; @@ -171,6 +172,7 @@ private: std::unique_ptr musicManager; std::unique_ptr footstepManager; std::unique_ptr activitySoundManager; + std::unique_ptr mountSoundManager; std::unique_ptr zoneManager; std::unique_ptr underwaterOverlayShader; uint32_t underwaterOverlayVAO = 0; diff --git a/src/audio/mount_sound_manager.cpp b/src/audio/mount_sound_manager.cpp new file mode 100644 index 00000000..85908d7a --- /dev/null +++ b/src/audio/mount_sound_manager.cpp @@ -0,0 +1,133 @@ +#include "audio/mount_sound_manager.hpp" +#include "audio/audio_engine.hpp" +#include "pipeline/asset_manager.hpp" +#include "core/logger.hpp" + +namespace wowee { +namespace audio { + +MountSoundManager::MountSoundManager() = default; + +MountSoundManager::~MountSoundManager() { + shutdown(); +} + +bool MountSoundManager::initialize(pipeline::AssetManager* assets) { + assetManager_ = assets; + LOG_INFO("Mount sound manager initialized"); + return true; +} + +void MountSoundManager::shutdown() { + stopAllMountSounds(); + mounted_ = false; + assetManager_ = nullptr; +} + +void MountSoundManager::update(float deltaTime) { + (void)deltaTime; + + if (!mounted_) { + return; + } + + updateMountSounds(); +} + +void MountSoundManager::onMount(uint32_t creatureDisplayId, bool isFlying) { + mounted_ = true; + currentDisplayId_ = creatureDisplayId; + currentMountType_ = detectMountType(creatureDisplayId); + flying_ = isFlying; + moving_ = false; + + LOG_INFO("Mount sound: mounted on display ID ", creatureDisplayId, + " type=", static_cast(currentMountType_), + " flying=", flying_); + + updateMountSounds(); +} + +void MountSoundManager::onDismount() { + stopAllMountSounds(); + mounted_ = false; + currentMountType_ = MountType::NONE; + currentDisplayId_ = 0; + flying_ = false; + moving_ = false; +} + +void MountSoundManager::setMoving(bool moving) { + if (moving_ != moving) { + moving_ = moving; + if (mounted_) { + updateMountSounds(); + } + } +} + +void MountSoundManager::setFlying(bool flying) { + if (flying_ != flying) { + flying_ = flying; + if (mounted_) { + updateMountSounds(); + } + } +} + +void MountSoundManager::setGrounded(bool grounded) { + setFlying(!grounded); +} + +MountType MountSoundManager::detectMountType(uint32_t creatureDisplayId) const { + // TODO: Load from CreatureDisplayInfo.dbc or CreatureModelData.dbc + // For now, use simple heuristics based on common display IDs + // This is a placeholder - we'd need proper DBC parsing for accuracy + + // Common flying mount display IDs (approximate ranges) + // Gryphons: ~2300-2310 + // Wyverns: ~1566-1570 + // Drakes: ~25830-25870 + // Phoenixes: ~17890-17900 + + if (creatureDisplayId >= 2300 && creatureDisplayId <= 2320) return MountType::FLYING; // Gryphons + if (creatureDisplayId >= 1560 && creatureDisplayId <= 1580) return MountType::FLYING; // Wyverns + if (creatureDisplayId >= 25800 && creatureDisplayId <= 25900) return MountType::FLYING; // Drakes + if (creatureDisplayId >= 17880 && creatureDisplayId <= 17910) return MountType::FLYING; // Phoenixes + + // Most other mounts are ground + return MountType::GROUND; +} + +void MountSoundManager::updateMountSounds() { + if (!AudioEngine::instance().isInitialized() || !mounted_) { + return; + } + + // TODO: Implement actual mount sound playback + // For now, just log state changes + static bool lastMoving = false; + static bool lastFlying = false; + + if (moving_ != lastMoving || flying_ != lastFlying) { + LOG_INFO("Mount sound state: moving=", moving_, " flying=", flying_, + " type=", static_cast(currentMountType_)); + lastMoving = moving_; + lastFlying = flying_; + } + + // TODO: Load and play appropriate looping sounds: + // - Flying + moving: wing flaps (fast loop) + // - Flying + idle: wing flaps (slow loop) or hovering sound + // - Ground + moving: galloping/hoofbeats (pace based on speed) + // - Ground + idle: breathing, fidgeting sounds (occasional) +} + +void MountSoundManager::stopAllMountSounds() { + // TODO: Stop any active looping mount sounds + playingMovementSound_ = false; + playingIdleSound_ = false; +} + +} // namespace audio +} // namespace wowee diff --git a/src/rendering/renderer.cpp b/src/rendering/renderer.cpp index d05bfb28..e354ecc8 100644 --- a/src/rendering/renderer.cpp +++ b/src/rendering/renderer.cpp @@ -35,6 +35,7 @@ #include "audio/music_manager.hpp" #include "audio/footstep_manager.hpp" #include "audio/activity_sound_manager.hpp" +#include "audio/mount_sound_manager.hpp" #include #include #include @@ -332,6 +333,7 @@ bool Renderer::initialize(core::Window* win) { musicManager = std::make_unique(); footstepManager = std::make_unique(); activitySoundManager = std::make_unique(); + mountSoundManager = std::make_unique(); // Underwater full-screen tint overlay (applies to all world geometry). underwaterOverlayShader = std::make_unique();