diff --git a/assets b/assets index 33455a9d..bc6e7df0 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 33455a9d10979b3041d7b8c026be4ac40b2ebad0 +Subproject commit bc6e7df04c09d8db2d889ef60cbc510060a469ed diff --git a/include/Engine/Sound/SoundManager.h b/include/Engine/Sound/SoundManager.h index 3452917c..ff9f440a 100644 --- a/include/Engine/Sound/SoundManager.h +++ b/include/Engine/Sound/SoundManager.h @@ -89,9 +89,9 @@ private: Source* createSource(std::string filePath); std::unordered_map m_Sources; void matchBGMLoop(); - Source* m_CurrentBGM; - Source* m_CurrentBGMCombo; - bool m_TempPleaseDeleteMeASAP = false; + Source* m_CurrentBGM = nullptr; + Source* m_CurrentBGMCombo = nullptr; + bool m_DrumLoopHasBeenStarted = false; // Logic World* m_World = nullptr; diff --git a/include/Game/Systems/SoundSystem.h b/include/Game/Systems/SoundSystem.h index fca242db..4852f01a 100644 --- a/include/Game/Systems/SoundSystem.h +++ b/include/Game/Systems/SoundSystem.h @@ -24,7 +24,7 @@ #include "../Engine/Sound/EPlayAnnouncerVoice.h" #include "../Game/Events/EDoubleJump.h" #include "../Game/Events/EDashAbility.h" - +#include "../Engine/Sound/EChangeBGM.h" class SoundSystem : public PureSystem, ImpureSystem { diff --git a/src/Engine/Sound/SoundManager.cpp b/src/Engine/Sound/SoundManager.cpp index f5403740..2cc5fafa 100644 --- a/src/Engine/Sound/SoundManager.cpp +++ b/src/Engine/Sound/SoundManager.cpp @@ -30,6 +30,10 @@ SoundManager::SoundManager(World* world, EventBroker* eventBroker) EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &SoundManager::OnPlayerSpawned); EVENT_SUBSCRIBE_MEMBER(m_EPlayQueueOnEntity, &SoundManager::OnPlayQueueOnEntity); EVENT_SUBSCRIBE_MEMBER(m_EChangeBGM, &SoundManager::OnChangeBGM); + + Events::ChangeBGM e; + e.FilePath = "Audio/bgm/MenuMusic.wav"; + m_EventBroker->Publish(e); } SoundManager::~SoundManager() @@ -63,7 +67,7 @@ void SoundManager::Update(double dt) deleteInactiveEmitters(); updateEmitters(dt); updateListener(dt); - if (m_TempPleaseDeleteMeASAP) + if (m_DrumLoopHasBeenStarted) matchBGMLoop(); } @@ -359,7 +363,7 @@ bool SoundManager::OnPlayerSpawned(const Events::PlayerSpawned &e) { if (e.PlayerID == -1) { // Local player m_LocalPlayer = e.Player; - if (m_TempPleaseDeleteMeASAP) { + if (m_DrumLoopHasBeenStarted) { return true; } m_CurrentBGMCombo = createSource("Audio/BGM/Layer2.wav"); @@ -367,7 +371,7 @@ bool SoundManager::OnPlayerSpawned(const Events::PlayerSpawned &e) alSourcei(m_CurrentBGMCombo->ALsource, AL_LOOPING, 1); setGain(m_CurrentBGMCombo, 0); playSound(m_CurrentBGMCombo); - m_TempPleaseDeleteMeASAP = true; + m_DrumLoopHasBeenStarted = true; return true; } return false; @@ -390,10 +394,9 @@ bool SoundManager::OnPlayQueueOnEntity(const Events::PlayQueueOnEntity &e) bool SoundManager::OnChangeBGM(const Events::ChangeBGM &e) { - if (m_CurrentBGM == nullptr) { - return false; + if (m_CurrentBGM != nullptr) { + stopSound(m_CurrentBGM); } - stopSound(m_CurrentBGM); m_CurrentBGM = createSource(e.FilePath); playSound(m_CurrentBGM); return true; diff --git a/src/Game/Systems/SoundSystem.cpp b/src/Game/Systems/SoundSystem.cpp index 66d740c8..095c9b85 100644 --- a/src/Game/Systems/SoundSystem.cpp +++ b/src/Game/Systems/SoundSystem.cpp @@ -30,9 +30,8 @@ bool SoundSystem::OnPlayerSpawned(const Events::PlayerSpawned &e) Events::PlayAnonuncerVoice go; go.FilePath = "Audio/Announcer/" + m_Announcer + "/Go.wav"; m_EventBroker->Publish(go); - // TEMP: starts bgm { - Events::PlayBackgroundMusic ev; + Events::ChangeBGM ev; ev.FilePath = "Audio/BGM/Layer1.wav"; m_EventBroker->Publish(ev); }