Stops bgm when the game is reset.
This commit is contained in:
@@ -31,6 +31,7 @@
|
|||||||
#include "../Engine/Core/EComponentAttached.h"
|
#include "../Engine/Core/EComponentAttached.h"
|
||||||
#include "../Core/EPlayerSpawned.h"
|
#include "../Core/EPlayerSpawned.h"
|
||||||
#include "../Engine/Network/EPlayerDisconnected.h"
|
#include "../Engine/Network/EPlayerDisconnected.h"
|
||||||
|
#include "../Game/Events/EReset.h"
|
||||||
|
|
||||||
|
|
||||||
typedef std::pair<ALuint, std::vector<ALuint>> QueuedBuffers;
|
typedef std::pair<ALuint, std::vector<ALuint>> QueuedBuffers;
|
||||||
@@ -142,6 +143,8 @@ private:
|
|||||||
bool OnChangeBGM(const Events::ChangeBGM &e);
|
bool OnChangeBGM(const Events::ChangeBGM &e);
|
||||||
EventRelay<SoundManager, Events::PlayerDisconnected> m_EplayerDisconnected;
|
EventRelay<SoundManager, Events::PlayerDisconnected> m_EplayerDisconnected;
|
||||||
bool OnPlayerDisconnected(const Events::PlayerDisconnected& e);
|
bool OnPlayerDisconnected(const Events::PlayerDisconnected& e);
|
||||||
|
EventRelay<SoundManager, Events::Reset> m_EReset;
|
||||||
|
bool OnReset(const Events::Reset& e);
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ SoundManager::SoundManager(World* world, EventBroker* eventBroker)
|
|||||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayQueueOnEntity, &SoundManager::OnPlayQueueOnEntity);
|
EVENT_SUBSCRIBE_MEMBER(m_EPlayQueueOnEntity, &SoundManager::OnPlayQueueOnEntity);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EChangeBGM, &SoundManager::OnChangeBGM);
|
EVENT_SUBSCRIBE_MEMBER(m_EChangeBGM, &SoundManager::OnChangeBGM);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EplayerDisconnected, &SoundManager::OnPlayerDisconnected);
|
EVENT_SUBSCRIBE_MEMBER(m_EplayerDisconnected, &SoundManager::OnPlayerDisconnected);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EReset, &SoundManager::OnReset);
|
||||||
|
|
||||||
Events::ChangeBGM e;
|
Events::ChangeBGM e;
|
||||||
e.FilePath = "Audio/bgm/MenuMusic.wav";
|
e.FilePath = "Audio/bgm/MenuMusic.wav";
|
||||||
@@ -422,6 +423,23 @@ bool SoundManager::OnPlayerDisconnected(const Events::PlayerDisconnected& e)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool SoundManager::OnReset(const Events::Reset& e)
|
||||||
|
{
|
||||||
|
// The game was reset, stop playing the background music (drums)
|
||||||
|
if (m_CurrentBGMCombo != nullptr) {
|
||||||
|
if (getSourceState(m_CurrentBGMCombo->ALsource) == AL_PLAYING) {
|
||||||
|
stopSound(m_CurrentBGMCombo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (m_CurrentBGM != nullptr) {
|
||||||
|
if (getSourceState(m_CurrentBGM->ALsource) == AL_PLAYING) {
|
||||||
|
stopSound(m_CurrentBGM);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
ALenum SoundManager::getSourceState(ALuint source)
|
ALenum SoundManager::getSourceState(ALuint source)
|
||||||
{
|
{
|
||||||
ALenum state;
|
ALenum state;
|
||||||
|
|||||||
Reference in New Issue
Block a user