diff --git a/include/Game/Game.h b/include/Game/Game.h index eb854350..c8d48ed8 100644 --- a/include/Game/Game.h +++ b/include/Game/Game.h @@ -29,10 +29,6 @@ // Sound #include "Sound/SoundSystem.h" -//#include "Sound/EPlaySound.h" -//#include "Sound/EPlaySoundOnEntity.h" -//#include "Sound/EPlaySoundOnPosition.h" - class Game { @@ -65,8 +61,8 @@ private: // Sound SoundSystem* m_SoundSystem; - EventRelay m_EInputCommand; - bool debugOnInputCommand(const Events::InputCommand& e); + //EventRelay m_EInputCommand; + //bool debugOnInputCommand(const Events::InputCommand& e); void debugInitialize(); void debugTick(double dt); diff --git a/src/Engine/Sound/SoundSystem.cpp b/src/Engine/Sound/SoundSystem.cpp index 3c37d2b2..1b7c5268 100644 --- a/src/Engine/Sound/SoundSystem.cpp +++ b/src/Engine/Sound/SoundSystem.cpp @@ -49,6 +49,7 @@ void SoundSystem::stopEmitters() void SoundSystem::Update() { + m_EventBroker->Process(); addNewEmitters(); // can be optimized with "EEntityCreated" deleteInactiveEmitters(); // can be optimized with "EEntityDeleted" updateEmitters(); @@ -66,14 +67,14 @@ void SoundSystem::deleteInactiveEmitters() it++; continue; } else { - // Sound has been stopped / finished playing. And has correct component. + // Sound has been stopped / finished playing. alDeleteBuffers(1, &it->second->ALsource); alDeleteSources(1, &it->second->ALsource); m_World->DeleteEntity(it->first); it = m_Sources.erase(it); } } else { - // Entity has been removed + // Entity / Component has been removed stopSound((*it).second); alDeleteBuffers(1, &it->second->ALsource); alDeleteSources(1, &it->second->ALsource); @@ -251,6 +252,7 @@ bool SoundSystem::OnSetSFXGain(const Events::SetSFXGain & e) void SoundSystem::setListenerOri(glm::vec3 ori) { + // Calculate forward and up vector. glm::vec3 forward = glm::vec3(0.0, 0.0, -1.0); forward = glm::rotateX(forward, ori.x); forward = glm::rotateY(forward, ori.y); diff --git a/src/Game/Game.cpp b/src/Game/Game.cpp index c5af30a9..97c23862 100644 --- a/src/Game/Game.cpp +++ b/src/Game/Game.cpp @@ -77,7 +77,8 @@ Game::Game(int argc, char* argv[]) //boost::thread workerThread(&Game::networkFunction, this); networkFunction(); } - EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &Game::debugOnInputCommand); + + // Invoke sound system m_SoundSystem = new SoundSystem(m_World, m_EventBroker, m_Config->Get("Debug.EditorEnabled", false)); m_LastTime = glfwGetTime(); @@ -86,6 +87,7 @@ Game::Game(int argc, char* argv[]) Game::~Game() { delete m_SystemPipeline; + delete m_SoundSystem; delete m_World; delete m_FrameStack; delete m_InputProxy; @@ -122,7 +124,6 @@ void Game::Tick() debugTick(dt); m_Renderer->Update(dt); m_EventBroker->Process(); - m_EventBroker->Process(); m_SoundSystem->Update(); m_RenderQueueFactory->Update(m_World); GLERROR("Game::Tick m_RenderQueueFactory->Update"); @@ -132,11 +133,6 @@ void Game::Tick() m_EventBroker->Clear(); } -bool Game::debugOnInputCommand(const Events::InputCommand & e) -{ - return true; -} - void Game::debugTick(double dt) { m_EventBroker->Process();