Added comments and cleaned up in Game.cpp/h

This commit is contained in:
stiffly
2016-01-14 15:32:53 +01:00
parent c916185a7c
commit b80ecc29d8
3 changed files with 9 additions and 15 deletions
+2 -6
View File
@@ -29,10 +29,6 @@
// Sound // Sound
#include "Sound/SoundSystem.h" #include "Sound/SoundSystem.h"
//#include "Sound/EPlaySound.h"
//#include "Sound/EPlaySoundOnEntity.h"
//#include "Sound/EPlaySoundOnPosition.h"
class Game class Game
{ {
@@ -65,8 +61,8 @@ private:
// Sound // Sound
SoundSystem* m_SoundSystem; SoundSystem* m_SoundSystem;
EventRelay<Game, Events::InputCommand> m_EInputCommand; //EventRelay<Game, Events::InputCommand> m_EInputCommand;
bool debugOnInputCommand(const Events::InputCommand& e); //bool debugOnInputCommand(const Events::InputCommand& e);
void debugInitialize(); void debugInitialize();
void debugTick(double dt); void debugTick(double dt);
+4 -2
View File
@@ -49,6 +49,7 @@ void SoundSystem::stopEmitters()
void SoundSystem::Update() void SoundSystem::Update()
{ {
m_EventBroker->Process<SoundSystem>();
addNewEmitters(); // can be optimized with "EEntityCreated" addNewEmitters(); // can be optimized with "EEntityCreated"
deleteInactiveEmitters(); // can be optimized with "EEntityDeleted" deleteInactiveEmitters(); // can be optimized with "EEntityDeleted"
updateEmitters(); updateEmitters();
@@ -66,14 +67,14 @@ void SoundSystem::deleteInactiveEmitters()
it++; it++;
continue; continue;
} else { } else {
// Sound has been stopped / finished playing. And has correct component. // Sound has been stopped / finished playing.
alDeleteBuffers(1, &it->second->ALsource); alDeleteBuffers(1, &it->second->ALsource);
alDeleteSources(1, &it->second->ALsource); alDeleteSources(1, &it->second->ALsource);
m_World->DeleteEntity(it->first); m_World->DeleteEntity(it->first);
it = m_Sources.erase(it); it = m_Sources.erase(it);
} }
} else { } else {
// Entity has been removed // Entity / Component has been removed
stopSound((*it).second); stopSound((*it).second);
alDeleteBuffers(1, &it->second->ALsource); alDeleteBuffers(1, &it->second->ALsource);
alDeleteSources(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) void SoundSystem::setListenerOri(glm::vec3 ori)
{ {
// Calculate forward and up vector.
glm::vec3 forward = glm::vec3(0.0, 0.0, -1.0); glm::vec3 forward = glm::vec3(0.0, 0.0, -1.0);
forward = glm::rotateX(forward, ori.x); forward = glm::rotateX(forward, ori.x);
forward = glm::rotateY(forward, ori.y); forward = glm::rotateY(forward, ori.y);
+3 -7
View File
@@ -77,7 +77,8 @@ Game::Game(int argc, char* argv[])
//boost::thread workerThread(&Game::networkFunction, this); //boost::thread workerThread(&Game::networkFunction, this);
networkFunction(); networkFunction();
} }
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &Game::debugOnInputCommand);
// Invoke sound system
m_SoundSystem = new SoundSystem(m_World, m_EventBroker, m_Config->Get<bool>("Debug.EditorEnabled", false)); m_SoundSystem = new SoundSystem(m_World, m_EventBroker, m_Config->Get<bool>("Debug.EditorEnabled", false));
m_LastTime = glfwGetTime(); m_LastTime = glfwGetTime();
@@ -86,6 +87,7 @@ Game::Game(int argc, char* argv[])
Game::~Game() Game::~Game()
{ {
delete m_SystemPipeline; delete m_SystemPipeline;
delete m_SoundSystem;
delete m_World; delete m_World;
delete m_FrameStack; delete m_FrameStack;
delete m_InputProxy; delete m_InputProxy;
@@ -122,7 +124,6 @@ void Game::Tick()
debugTick(dt); debugTick(dt);
m_Renderer->Update(dt); m_Renderer->Update(dt);
m_EventBroker->Process<Client>(); m_EventBroker->Process<Client>();
m_EventBroker->Process<SoundSystem>();
m_SoundSystem->Update(); m_SoundSystem->Update();
m_RenderQueueFactory->Update(m_World); m_RenderQueueFactory->Update(m_World);
GLERROR("Game::Tick m_RenderQueueFactory->Update"); GLERROR("Game::Tick m_RenderQueueFactory->Update");
@@ -132,11 +133,6 @@ void Game::Tick()
m_EventBroker->Clear(); m_EventBroker->Clear();
} }
bool Game::debugOnInputCommand(const Events::InputCommand & e)
{
return true;
}
void Game::debugTick(double dt) void Game::debugTick(double dt)
{ {
m_EventBroker->Process<Game>(); m_EventBroker->Process<Game>();