diff --git a/src/Events/StopSound.h b/src/Events/StopSound.h new file mode 100644 index 0000000..a832d4f --- /dev/null +++ b/src/Events/StopSound.h @@ -0,0 +1,17 @@ +#ifndef Event_StopSound_h__ +#define Event_StopSound_h__ + +#include "EventBroker.h" +#include "Entity.h" + +namespace Events +{ + + struct StopSound : Event + { + EntityID Emitter; + }; + +} + +#endif // Event_StopSound_h__ diff --git a/src/GameWorld.cpp b/src/GameWorld.cpp index 85be0a4..38d7410 100755 --- a/src/GameWorld.cpp +++ b/src/GameWorld.cpp @@ -555,29 +555,6 @@ void GameWorld::Initialize() } CommitEntity(wheel); - auto entity = CreateEntity(tank); - auto transformComponent = AddComponent(entity); - transformComponent->Position = glm::vec3(2,-1.7,2.0); - transformComponent->Scale = glm::vec3(3,3,3); - transformComponent->Orientation = glm::angleAxis(glm::pi()/2, glm::vec3(1,0,0)); - auto emitterComponent = AddComponent(entity); - emitterComponent->SpawnCount = 2; - emitterComponent->SpawnFrequency = 0.005; - emitterComponent->SpreadAngle = glm::pi(); - emitterComponent->UseGoalVelocity = false; - emitterComponent->LifeTime = 0.5; - //emitterComponent->AngularVelocitySpectrum.push_back(glm::pi() / 100); - emitterComponent->ScaleSpectrum.push_back(glm::vec3(0.05)); - CommitEntity(entity); - - auto particleEntity = CreateEntity(entity); - auto TEMP = AddComponent(particleEntity); - TEMP->Scale = glm::vec3(0); - auto spriteComponent = AddComponent(particleEntity); - spriteComponent->SpriteFile = "Models/Textures/Sprites/Dust.png"; - emitterComponent->ParticleTemplate = particleEntity; - - CommitEntity(particleEntity); } { @@ -639,29 +616,7 @@ void GameWorld::Initialize() } CommitEntity(wheel); - auto entity = CreateEntity(tank); - auto transformComponent = AddComponent(entity); - transformComponent->Position = glm::vec3(-2,-1.7,2.0); - transformComponent->Scale = glm::vec3(3,3,3); - transformComponent->Orientation = glm::angleAxis(glm::pi()/2, glm::vec3(1,0,0)); - auto emitterComponent = AddComponent(entity); - emitterComponent->SpawnCount = 2; - emitterComponent->SpawnFrequency = 0.005; - emitterComponent->SpreadAngle = glm::pi(); - emitterComponent->UseGoalVelocity = false; - emitterComponent->LifeTime = 0.5; - //emitterComponent->AngularVelocitySpectrum.push_back(glm::pi() / 100); - emitterComponent->ScaleSpectrum.push_back(glm::vec3(0.05)); - CommitEntity(entity); - auto particleEntity = CreateEntity(entity); - auto TEMP = AddComponent(particleEntity); - TEMP->Scale = glm::vec3(0); - auto spriteComponent = AddComponent(particleEntity); - spriteComponent->SpriteFile = "Models/Textures/Sprites/Dust.png"; - emitterComponent->ParticleTemplate = particleEntity; - - CommitEntity(particleEntity); } @@ -975,29 +930,7 @@ void GameWorld::Initialize() } CommitEntity(wheel); - auto entity = CreateEntity(tank); - auto transformComponent = AddComponent(entity); - transformComponent->Position = glm::vec3(2,-1.7,2.0); - transformComponent->Scale = glm::vec3(3,3,3); - transformComponent->Orientation = glm::angleAxis(glm::pi()/2, glm::vec3(1,0,0)); - auto emitterComponent = AddComponent(entity); - emitterComponent->SpawnCount = 2; - emitterComponent->SpawnFrequency = 0.005; - emitterComponent->SpreadAngle = glm::pi(); - emitterComponent->UseGoalVelocity = false; - emitterComponent->LifeTime = 0.5; - //emitterComponent->AngularVelocitySpectrum.push_back(glm::pi() / 100); - emitterComponent->ScaleSpectrum.push_back(glm::vec3(0.05)); - CommitEntity(entity); - auto particleEntity = CreateEntity(entity); - auto TEMP = AddComponent(particleEntity); - TEMP->Scale = glm::vec3(0); - auto spriteComponent = AddComponent(particleEntity); - spriteComponent->SpriteFile = "Models/Textures/Sprites/Dust.png"; - emitterComponent->ParticleTemplate = particleEntity; - - CommitEntity(particleEntity); } { @@ -1059,29 +992,6 @@ void GameWorld::Initialize() } CommitEntity(wheel); - auto entity = CreateEntity(tank); - auto transformComponent = AddComponent(entity); - transformComponent->Position = glm::vec3(-2,-1.7,2.0); - transformComponent->Scale = glm::vec3(3,3,3); - transformComponent->Orientation = glm::angleAxis(glm::pi()/2, glm::vec3(1,0,0)); - auto emitterComponent = AddComponent(entity); - emitterComponent->SpawnCount = 2; - emitterComponent->SpawnFrequency = 0.005; - emitterComponent->SpreadAngle = glm::pi(); - emitterComponent->UseGoalVelocity = false; - emitterComponent->LifeTime = 0.5; - //emitterComponent->AngularVelocitySpectrum.push_back(glm::pi() / 100); - emitterComponent->ScaleSpectrum.push_back(glm::vec3(0.05)); - CommitEntity(entity); - - auto particleEntity = CreateEntity(entity); - auto TEMP = AddComponent(particleEntity); - TEMP->Scale = glm::vec3(0); - auto spriteComponent = AddComponent(particleEntity); - spriteComponent->SpriteFile = "Models/Textures/Sprites/Dust.png"; - emitterComponent->ParticleTemplate = particleEntity; - - CommitEntity(particleEntity); } diff --git a/src/InputManager.cpp b/src/InputManager.cpp index 6de554b..a275e69 100644 --- a/src/InputManager.cpp +++ b/src/InputManager.cpp @@ -49,6 +49,14 @@ void InputManager::Update(double dt) e.Loop = true; EventBroker->Publish(e); } + if(m_CurrentKeyState[GLFW_KEY_P]) //TEMP + { + Events::StopSound e; + e.Emitter = 59; + EventBroker->Publish(e); + e.Emitter = 62; + EventBroker->Publish(e); + } // Mouse buttons for (int i = 0; i <= GLFW_MOUSE_BUTTON_LAST; ++i) diff --git a/src/InputManager.h b/src/InputManager.h index 61227ee..fe77181 100644 --- a/src/InputManager.h +++ b/src/InputManager.h @@ -12,8 +12,9 @@ #include "Events/LockMouse.h" #include "Events/GamepadAxis.h" #include "Events/GamepadButton.h" -#include "Events/PLaySFX.h" //Temp -#include "Events/PLayBGM.h" //Temp +#include "Events/PlaySFX.h" //Temp +#include "Events/PlayBGM.h" //Temp +#include "Events/StopSound.h" //Temp class InputManager { diff --git a/src/Systems/SoundSystem.cpp b/src/Systems/SoundSystem.cpp index 8c0ea2a..ebfa8ab 100755 --- a/src/Systems/SoundSystem.cpp +++ b/src/Systems/SoundSystem.cpp @@ -7,6 +7,7 @@ void Systems::SoundSystem::Initialize() EVENT_SUBSCRIBE_MEMBER(m_EComponentCreated, &SoundSystem::OnComponentCreated); EVENT_SUBSCRIBE_MEMBER(m_EPlaySFX, &SoundSystem::PlaySFX); EVENT_SUBSCRIBE_MEMBER(m_EPlayBGM, &SoundSystem::PlayBGM); + EVENT_SUBSCRIBE_MEMBER(m_EStopSound, &SoundSystem::StopSound); m_TransformSystem = m_World->GetSystem(); FMOD_System_Create(&m_System); @@ -150,19 +151,19 @@ bool Systems::SoundSystem::PlaySFX(const Events::PlaySFX &event) PlaySound(&m_Channels[event.Emitter], m_Sounds[event.Emitter], 1.0, event.Loop); FMOD_System_Update(m_System); - FMOD_BOOL* isPlaying = false; - if(!FMOD_Channel_IsPlaying(m_Channels[event.Emitter], isPlaying)) + FMOD_BOOL isPlaying = false; + FMOD_Channel_IsPlaying(m_Channels[event.Emitter], &isPlaying); + if(!isPlaying) LOG_ERROR("FMOD: File %s is not playing", event.Resource.c_str()); else - { LOG_INFO("Now playing sound %s", event.Resource.c_str()); - } return true; } bool Systems::SoundSystem::PlayBGM(const Events::PlayBGM &event) { auto emitter = m_World->CreateEntity(); + std::cout<<"ASSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS: "<AddComponent(emitter); auto eComponent = m_World->AddComponent(emitter); @@ -175,6 +176,12 @@ bool Systems::SoundSystem::PlayBGM(const Events::PlayBGM &event) return true; } +bool Systems::SoundSystem::StopSound(const Events::StopSound &event) +{ + FMOD_Channel_Stop(m_Channels[event.Emitter]); + return true; +} + void Systems::SoundSystem::LoadSound(FMOD_SOUND* &sound, std::string filePath, float maxDist, float minDist) { FMOD_RESULT result = FMOD_System_CreateSound(m_System, filePath.c_str(), FMOD_3D | FMOD_HARDWARE , 0, &sound); diff --git a/src/Systems/SoundSystem.h b/src/Systems/SoundSystem.h index 77e385c..fb5bbd6 100755 --- a/src/Systems/SoundSystem.h +++ b/src/Systems/SoundSystem.h @@ -12,6 +12,7 @@ #include "Events/ComponentCreated.h" #include "Events/PlaySFX.h" #include "Events/PlayBGM.h" +#include "Events/StopSound.h" #include "Sound.h" namespace Systems @@ -38,6 +39,8 @@ private: bool PlaySFX(const Events::PlaySFX &event); EventRelay m_EPlayBGM; bool PlayBGM(const Events::PlayBGM &event); + EventRelay m_EStopSound; + bool StopSound(const Events::StopSound &event); void LoadSound(FMOD_SOUND*&, std::string, float, float); void PlaySound(FMOD_CHANNEL**, FMOD_SOUND*, float volume, bool loop); diff --git a/vs11/Returngeance/Returngeance.vcxproj b/vs11/Returngeance/Returngeance.vcxproj index 8123839..c6bb1c4 100755 --- a/vs11/Returngeance/Returngeance.vcxproj +++ b/vs11/Returngeance/Returngeance.vcxproj @@ -177,6 +177,7 @@ + diff --git a/vs11/Returngeance/Returngeance.vcxproj.filters b/vs11/Returngeance/Returngeance.vcxproj.filters index 6836160..cd29646 100755 --- a/vs11/Returngeance/Returngeance.vcxproj.filters +++ b/vs11/Returngeance/Returngeance.vcxproj.filters @@ -411,6 +411,9 @@ Audio\Events + + Audio\Events +