Added Stop Sound event.
This commit is contained in:
@@ -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__
|
||||||
@@ -555,29 +555,6 @@ void GameWorld::Initialize()
|
|||||||
}
|
}
|
||||||
CommitEntity(wheel);
|
CommitEntity(wheel);
|
||||||
|
|
||||||
auto entity = CreateEntity(tank);
|
|
||||||
auto transformComponent = AddComponent<Components::Transform>(entity);
|
|
||||||
transformComponent->Position = glm::vec3(2,-1.7,2.0);
|
|
||||||
transformComponent->Scale = glm::vec3(3,3,3);
|
|
||||||
transformComponent->Orientation = glm::angleAxis(glm::pi<float>()/2, glm::vec3(1,0,0));
|
|
||||||
auto emitterComponent = AddComponent<Components::ParticleEmitter>(entity);
|
|
||||||
emitterComponent->SpawnCount = 2;
|
|
||||||
emitterComponent->SpawnFrequency = 0.005;
|
|
||||||
emitterComponent->SpreadAngle = glm::pi<float>();
|
|
||||||
emitterComponent->UseGoalVelocity = false;
|
|
||||||
emitterComponent->LifeTime = 0.5;
|
|
||||||
//emitterComponent->AngularVelocitySpectrum.push_back(glm::pi<float>() / 100);
|
|
||||||
emitterComponent->ScaleSpectrum.push_back(glm::vec3(0.05));
|
|
||||||
CommitEntity(entity);
|
|
||||||
|
|
||||||
auto particleEntity = CreateEntity(entity);
|
|
||||||
auto TEMP = AddComponent<Components::Transform>(particleEntity);
|
|
||||||
TEMP->Scale = glm::vec3(0);
|
|
||||||
auto spriteComponent = AddComponent<Components::Sprite>(particleEntity);
|
|
||||||
spriteComponent->SpriteFile = "Models/Textures/Sprites/Dust.png";
|
|
||||||
emitterComponent->ParticleTemplate = particleEntity;
|
|
||||||
|
|
||||||
CommitEntity(particleEntity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -639,29 +616,7 @@ void GameWorld::Initialize()
|
|||||||
}
|
}
|
||||||
CommitEntity(wheel);
|
CommitEntity(wheel);
|
||||||
|
|
||||||
auto entity = CreateEntity(tank);
|
|
||||||
auto transformComponent = AddComponent<Components::Transform>(entity);
|
|
||||||
transformComponent->Position = glm::vec3(-2,-1.7,2.0);
|
|
||||||
transformComponent->Scale = glm::vec3(3,3,3);
|
|
||||||
transformComponent->Orientation = glm::angleAxis(glm::pi<float>()/2, glm::vec3(1,0,0));
|
|
||||||
auto emitterComponent = AddComponent<Components::ParticleEmitter>(entity);
|
|
||||||
emitterComponent->SpawnCount = 2;
|
|
||||||
emitterComponent->SpawnFrequency = 0.005;
|
|
||||||
emitterComponent->SpreadAngle = glm::pi<float>();
|
|
||||||
emitterComponent->UseGoalVelocity = false;
|
|
||||||
emitterComponent->LifeTime = 0.5;
|
|
||||||
//emitterComponent->AngularVelocitySpectrum.push_back(glm::pi<float>() / 100);
|
|
||||||
emitterComponent->ScaleSpectrum.push_back(glm::vec3(0.05));
|
|
||||||
CommitEntity(entity);
|
|
||||||
|
|
||||||
auto particleEntity = CreateEntity(entity);
|
|
||||||
auto TEMP = AddComponent<Components::Transform>(particleEntity);
|
|
||||||
TEMP->Scale = glm::vec3(0);
|
|
||||||
auto spriteComponent = AddComponent<Components::Sprite>(particleEntity);
|
|
||||||
spriteComponent->SpriteFile = "Models/Textures/Sprites/Dust.png";
|
|
||||||
emitterComponent->ParticleTemplate = particleEntity;
|
|
||||||
|
|
||||||
CommitEntity(particleEntity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -975,29 +930,7 @@ void GameWorld::Initialize()
|
|||||||
}
|
}
|
||||||
CommitEntity(wheel);
|
CommitEntity(wheel);
|
||||||
|
|
||||||
auto entity = CreateEntity(tank);
|
|
||||||
auto transformComponent = AddComponent<Components::Transform>(entity);
|
|
||||||
transformComponent->Position = glm::vec3(2,-1.7,2.0);
|
|
||||||
transformComponent->Scale = glm::vec3(3,3,3);
|
|
||||||
transformComponent->Orientation = glm::angleAxis(glm::pi<float>()/2, glm::vec3(1,0,0));
|
|
||||||
auto emitterComponent = AddComponent<Components::ParticleEmitter>(entity);
|
|
||||||
emitterComponent->SpawnCount = 2;
|
|
||||||
emitterComponent->SpawnFrequency = 0.005;
|
|
||||||
emitterComponent->SpreadAngle = glm::pi<float>();
|
|
||||||
emitterComponent->UseGoalVelocity = false;
|
|
||||||
emitterComponent->LifeTime = 0.5;
|
|
||||||
//emitterComponent->AngularVelocitySpectrum.push_back(glm::pi<float>() / 100);
|
|
||||||
emitterComponent->ScaleSpectrum.push_back(glm::vec3(0.05));
|
|
||||||
CommitEntity(entity);
|
|
||||||
|
|
||||||
auto particleEntity = CreateEntity(entity);
|
|
||||||
auto TEMP = AddComponent<Components::Transform>(particleEntity);
|
|
||||||
TEMP->Scale = glm::vec3(0);
|
|
||||||
auto spriteComponent = AddComponent<Components::Sprite>(particleEntity);
|
|
||||||
spriteComponent->SpriteFile = "Models/Textures/Sprites/Dust.png";
|
|
||||||
emitterComponent->ParticleTemplate = particleEntity;
|
|
||||||
|
|
||||||
CommitEntity(particleEntity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -1059,29 +992,6 @@ void GameWorld::Initialize()
|
|||||||
}
|
}
|
||||||
CommitEntity(wheel);
|
CommitEntity(wheel);
|
||||||
|
|
||||||
auto entity = CreateEntity(tank);
|
|
||||||
auto transformComponent = AddComponent<Components::Transform>(entity);
|
|
||||||
transformComponent->Position = glm::vec3(-2,-1.7,2.0);
|
|
||||||
transformComponent->Scale = glm::vec3(3,3,3);
|
|
||||||
transformComponent->Orientation = glm::angleAxis(glm::pi<float>()/2, glm::vec3(1,0,0));
|
|
||||||
auto emitterComponent = AddComponent<Components::ParticleEmitter>(entity);
|
|
||||||
emitterComponent->SpawnCount = 2;
|
|
||||||
emitterComponent->SpawnFrequency = 0.005;
|
|
||||||
emitterComponent->SpreadAngle = glm::pi<float>();
|
|
||||||
emitterComponent->UseGoalVelocity = false;
|
|
||||||
emitterComponent->LifeTime = 0.5;
|
|
||||||
//emitterComponent->AngularVelocitySpectrum.push_back(glm::pi<float>() / 100);
|
|
||||||
emitterComponent->ScaleSpectrum.push_back(glm::vec3(0.05));
|
|
||||||
CommitEntity(entity);
|
|
||||||
|
|
||||||
auto particleEntity = CreateEntity(entity);
|
|
||||||
auto TEMP = AddComponent<Components::Transform>(particleEntity);
|
|
||||||
TEMP->Scale = glm::vec3(0);
|
|
||||||
auto spriteComponent = AddComponent<Components::Sprite>(particleEntity);
|
|
||||||
spriteComponent->SpriteFile = "Models/Textures/Sprites/Dust.png";
|
|
||||||
emitterComponent->ParticleTemplate = particleEntity;
|
|
||||||
|
|
||||||
CommitEntity(particleEntity);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,14 @@ void InputManager::Update(double dt)
|
|||||||
e.Loop = true;
|
e.Loop = true;
|
||||||
EventBroker->Publish(e);
|
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
|
// Mouse buttons
|
||||||
for (int i = 0; i <= GLFW_MOUSE_BUTTON_LAST; ++i)
|
for (int i = 0; i <= GLFW_MOUSE_BUTTON_LAST; ++i)
|
||||||
|
|||||||
+3
-2
@@ -12,8 +12,9 @@
|
|||||||
#include "Events/LockMouse.h"
|
#include "Events/LockMouse.h"
|
||||||
#include "Events/GamepadAxis.h"
|
#include "Events/GamepadAxis.h"
|
||||||
#include "Events/GamepadButton.h"
|
#include "Events/GamepadButton.h"
|
||||||
#include "Events/PLaySFX.h" //Temp
|
#include "Events/PlaySFX.h" //Temp
|
||||||
#include "Events/PLayBGM.h" //Temp
|
#include "Events/PlayBGM.h" //Temp
|
||||||
|
#include "Events/StopSound.h" //Temp
|
||||||
|
|
||||||
class InputManager
|
class InputManager
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ void Systems::SoundSystem::Initialize()
|
|||||||
EVENT_SUBSCRIBE_MEMBER(m_EComponentCreated, &SoundSystem::OnComponentCreated);
|
EVENT_SUBSCRIBE_MEMBER(m_EComponentCreated, &SoundSystem::OnComponentCreated);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EPlaySFX, &SoundSystem::PlaySFX);
|
EVENT_SUBSCRIBE_MEMBER(m_EPlaySFX, &SoundSystem::PlaySFX);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayBGM, &SoundSystem::PlayBGM);
|
EVENT_SUBSCRIBE_MEMBER(m_EPlayBGM, &SoundSystem::PlayBGM);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EStopSound, &SoundSystem::StopSound);
|
||||||
|
|
||||||
m_TransformSystem = m_World->GetSystem<Systems::TransformSystem>();
|
m_TransformSystem = m_World->GetSystem<Systems::TransformSystem>();
|
||||||
FMOD_System_Create(&m_System);
|
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);
|
PlaySound(&m_Channels[event.Emitter], m_Sounds[event.Emitter], 1.0, event.Loop);
|
||||||
FMOD_System_Update(m_System);
|
FMOD_System_Update(m_System);
|
||||||
FMOD_BOOL* isPlaying = false;
|
FMOD_BOOL isPlaying = false;
|
||||||
if(!FMOD_Channel_IsPlaying(m_Channels[event.Emitter], isPlaying))
|
FMOD_Channel_IsPlaying(m_Channels[event.Emitter], &isPlaying);
|
||||||
|
if(!isPlaying)
|
||||||
LOG_ERROR("FMOD: File %s is not playing", event.Resource.c_str());
|
LOG_ERROR("FMOD: File %s is not playing", event.Resource.c_str());
|
||||||
else
|
else
|
||||||
{
|
|
||||||
LOG_INFO("Now playing sound %s", event.Resource.c_str());
|
LOG_INFO("Now playing sound %s", event.Resource.c_str());
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Systems::SoundSystem::PlayBGM(const Events::PlayBGM &event)
|
bool Systems::SoundSystem::PlayBGM(const Events::PlayBGM &event)
|
||||||
{
|
{
|
||||||
auto emitter = m_World->CreateEntity();
|
auto emitter = m_World->CreateEntity();
|
||||||
|
std::cout<<"ASSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS: "<<emitter<<std::endl;
|
||||||
auto eTransform = m_World->AddComponent<Components::Transform>(emitter);
|
auto eTransform = m_World->AddComponent<Components::Transform>(emitter);
|
||||||
|
|
||||||
auto eComponent = m_World->AddComponent<Components::SoundEmitter>(emitter);
|
auto eComponent = m_World->AddComponent<Components::SoundEmitter>(emitter);
|
||||||
@@ -175,6 +176,12 @@ bool Systems::SoundSystem::PlayBGM(const Events::PlayBGM &event)
|
|||||||
return true;
|
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)
|
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);
|
FMOD_RESULT result = FMOD_System_CreateSound(m_System, filePath.c_str(), FMOD_3D | FMOD_HARDWARE , 0, &sound);
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include "Events/ComponentCreated.h"
|
#include "Events/ComponentCreated.h"
|
||||||
#include "Events/PlaySFX.h"
|
#include "Events/PlaySFX.h"
|
||||||
#include "Events/PlayBGM.h"
|
#include "Events/PlayBGM.h"
|
||||||
|
#include "Events/StopSound.h"
|
||||||
#include "Sound.h"
|
#include "Sound.h"
|
||||||
|
|
||||||
namespace Systems
|
namespace Systems
|
||||||
@@ -38,6 +39,8 @@ private:
|
|||||||
bool PlaySFX(const Events::PlaySFX &event);
|
bool PlaySFX(const Events::PlaySFX &event);
|
||||||
EventRelay<SoundSystem, Events::PlayBGM> m_EPlayBGM;
|
EventRelay<SoundSystem, Events::PlayBGM> m_EPlayBGM;
|
||||||
bool PlayBGM(const Events::PlayBGM &event);
|
bool PlayBGM(const Events::PlayBGM &event);
|
||||||
|
EventRelay<SoundSystem, Events::StopSound> m_EStopSound;
|
||||||
|
bool StopSound(const Events::StopSound &event);
|
||||||
|
|
||||||
void LoadSound(FMOD_SOUND*&, std::string, float, float);
|
void LoadSound(FMOD_SOUND*&, std::string, float, float);
|
||||||
void PlaySound(FMOD_CHANNEL**, FMOD_SOUND*, float volume, bool loop);
|
void PlaySound(FMOD_CHANNEL**, FMOD_SOUND*, float volume, bool loop);
|
||||||
|
|||||||
@@ -177,6 +177,7 @@
|
|||||||
<ClInclude Include="..\..\src\Events\PlayBGM.h" />
|
<ClInclude Include="..\..\src\Events\PlayBGM.h" />
|
||||||
<ClInclude Include="..\..\src\Events\PlaySFX.h" />
|
<ClInclude Include="..\..\src\Events\PlaySFX.h" />
|
||||||
<ClInclude Include="..\..\src\Events\SetVelocity.h" />
|
<ClInclude Include="..\..\src\Events\SetVelocity.h" />
|
||||||
|
<ClInclude Include="..\..\src\Events\StopSound.h" />
|
||||||
<ClInclude Include="..\..\src\Events\TankSteer.h" />
|
<ClInclude Include="..\..\src\Events\TankSteer.h" />
|
||||||
<ClInclude Include="..\..\src\Factory.h" />
|
<ClInclude Include="..\..\src\Factory.h" />
|
||||||
<ClInclude Include="..\..\src\GameWorld.h" />
|
<ClInclude Include="..\..\src\GameWorld.h" />
|
||||||
|
|||||||
@@ -411,6 +411,9 @@
|
|||||||
<ClInclude Include="..\..\src\Events\PlaySFX.h">
|
<ClInclude Include="..\..\src\Events\PlaySFX.h">
|
||||||
<Filter>Audio\Events</Filter>
|
<Filter>Audio\Events</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\Events\StopSound.h">
|
||||||
|
<Filter>Audio\Events</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="..\..\src\Shaders\Fragment2.glsl">
|
<None Include="..\..\src\Shaders\Fragment2.glsl">
|
||||||
|
|||||||
Reference in New Issue
Block a user