From 2c64ffc3d11782a0bccb0245fc1b18b91d2b00ad Mon Sep 17 00:00:00 2001 From: stiffly Date: Mon, 8 Feb 2016 16:52:35 +0100 Subject: [PATCH] No longer using a variable to see if we're in editor mode. --- include/Engine/Sound/SoundManager.h | 3 +-- src/Engine/Sound/SoundManager.cpp | 26 ++++++++++---------------- src/Game/Game.cpp | 2 +- 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/include/Engine/Sound/SoundManager.h b/include/Engine/Sound/SoundManager.h index 2c07578c..38ec62ff 100644 --- a/include/Engine/Sound/SoundManager.h +++ b/include/Engine/Sound/SoundManager.h @@ -49,7 +49,7 @@ class SoundManager { public: SoundManager() { } - SoundManager(World* world, EventBroker* eventBroker, bool editorMode); + SoundManager(World* world, EventBroker* eventBroker); ~SoundManager(); // Update emitters / listener void Update(double dt); @@ -93,7 +93,6 @@ private: float m_BGMVolumeChannel = 1.0f; float m_SFXVolumeChannel = 1.0f; - bool m_EditorEnabled = false; EntityWrapper m_LocalPlayer = EntityWrapper(); // Events diff --git a/src/Engine/Sound/SoundManager.cpp b/src/Engine/Sound/SoundManager.cpp index 972a38bb..8ba6a502 100644 --- a/src/Engine/Sound/SoundManager.cpp +++ b/src/Engine/Sound/SoundManager.cpp @@ -1,11 +1,10 @@ #include "Sound/SoundManager.h" -SoundManager::SoundManager(World* world, EventBroker* eventBroker, bool editorMode) +SoundManager::SoundManager(World* world, EventBroker* eventBroker) { ConfigFile* config = ResourceManager::Load("Config.ini"); m_EventBroker = eventBroker; m_World = world; - m_EditorEnabled = editorMode; m_BGMVolumeChannel = config->Get("Sound.BGMVolume", 1.f); m_SFXVolumeChannel = config->Get("Sound.SFXVolume", 1.f); @@ -103,9 +102,9 @@ void SoundManager::updateEmitters(double dt) if (!m_World->ValidEntity(it->first)) { return; } - if (!m_World->HasComponent(it->first, "SoundEmitter")) + if (!m_World->HasComponent(it->first, "SoundEmitter")) return; - + glm::vec3 previousPos; alGetSource3f(it->second->ALsource, AL_POSITION, &previousPos.x, &previousPos.y, &previousPos.z); // Get next pos @@ -123,14 +122,11 @@ void SoundManager::updateEmitters(double dt) auto emitter = m_World->GetComponent(it->first, "SoundEmitter"); setSoundProperties(it->second, &emitter); - // To make an emitter play when spawned in editor mode - if (m_EditorEnabled) { - // Path changed - if (it->second->SoundResource->Path() != (std::string)emitter["FilePath"]) { - it->second->SoundResource = ResourceManager::Load((std::string)emitter["FilePath"]); - if (it->second->SoundResource->Buffer() != 0) { - playSound(it->second); - } + // Path changed + if (it->second->SoundResource->Path() != (std::string)emitter["FilePath"]) { + it->second->SoundResource = ResourceManager::Load((std::string)emitter["FilePath"]); + if (it->second->SoundResource->Buffer() != 0) { + playSound(it->second); } } } @@ -145,8 +141,7 @@ void SoundManager::updateListener(double dt) } for (auto it = listenerComponents->begin(); it != listenerComponents->end(); it++) { EntityWrapper listener(m_World, (*it).EntityID); - if (!listener.Valid()) - { + if (!listener.Valid()) { break; } if (listener.IsChildOf(m_LocalPlayer) || listener == m_LocalPlayer) { @@ -242,9 +237,8 @@ bool SoundManager::OnContinueSound(const Events::ContinueSound & e) bool SoundManager::OnPlayBackgroundMusic(const Events::PlayBackgroundMusic & e) { auto listenerComponents = m_World->GetComponents("Listener"); - LOG_INFO("SIZZE: %i", listenerComponents->size()); for (auto it = listenerComponents->begin(); it != listenerComponents->end(); it++) { - if((*it).EntityID != m_LocalPlayer.ID) { + if ((*it).EntityID != m_LocalPlayer.ID) { break; } auto emitterChild = m_World->CreateEntity((*it).EntityID); diff --git a/src/Game/Game.cpp b/src/Game/Game.cpp index 6c495272..37eb2ea6 100644 --- a/src/Game/Game.cpp +++ b/src/Game/Game.cpp @@ -74,7 +74,7 @@ Game::Game(int argc, char* argv[]) } // Create the sound manager - m_SoundManager = new SoundManager(m_World, m_EventBroker, true); + m_SoundManager = new SoundManager(m_World, m_EventBroker); // Create Octrees m_OctreeCollision = new Octree(AABB(glm::vec3(-100), glm::vec3(100)), 4);