WIP
This commit is contained in:
@@ -24,6 +24,9 @@
|
|||||||
#include "Core/EPlayerSpawned.h"
|
#include "Core/EPlayerSpawned.h"
|
||||||
#include "Input/EInputCommand.h"
|
#include "Input/EInputCommand.h"
|
||||||
#include "Core/ECaptured.h"
|
#include "Core/ECaptured.h"
|
||||||
|
#include "Core/EPlayerDamage.h"
|
||||||
|
#include "Core/EPlayerDeath.h"
|
||||||
|
#include "Core/EPlayerHealthPickup.h"
|
||||||
|
|
||||||
enum class SoundType {
|
enum class SoundType {
|
||||||
SFX,
|
SFX,
|
||||||
@@ -120,6 +123,14 @@ private:
|
|||||||
bool OnInputCommand(const Events::InputCommand &e);
|
bool OnInputCommand(const Events::InputCommand &e);
|
||||||
EventRelay<SoundSystem, Events::Captured> m_ECaptured;
|
EventRelay<SoundSystem, Events::Captured> m_ECaptured;
|
||||||
bool OnCaptured(const Events::Captured &e);
|
bool OnCaptured(const Events::Captured &e);
|
||||||
|
EventRelay<SoundSystem, Events::PlayerDamage> m_EPlayerDamage;
|
||||||
|
bool OnPlayerDamage(const Events::PlayerDamage &e);
|
||||||
|
EventRelay<SoundSystem, Events::PlayerDeath> m_EPlayerDeath;
|
||||||
|
bool OnPlayerDeath(const Events::PlayerDeath &e);
|
||||||
|
EventRelay<SoundSystem, Events::PlayerHealthPickup> m_EPlayerHealthPickup;
|
||||||
|
bool OnPlayerHealthPickup(const Events::PlayerHealthPickup &e);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -122,6 +122,7 @@ void SoundSystem::updateEmitters(double dt)
|
|||||||
setSourceVel(it->second->ALsource, velocity);
|
setSourceVel(it->second->ALsource, velocity);
|
||||||
float gain;
|
float gain;
|
||||||
(bool)(it->second->Type) ? gain = m_SFXVolumeChannel : gain = m_BGMVolumeChannel;
|
(bool)(it->second->Type) ? gain = m_SFXVolumeChannel : gain = m_BGMVolumeChannel;
|
||||||
|
|
||||||
auto emitter = m_World->GetComponent(it->first, "SoundEmitter");
|
auto emitter = m_World->GetComponent(it->first, "SoundEmitter");
|
||||||
setSoundProperties(it->second->ALsource, &emitter);
|
setSoundProperties(it->second->ALsource, &emitter);
|
||||||
|
|
||||||
@@ -372,6 +373,48 @@ bool SoundSystem::OnCaptured(const Events::Captured & e)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SoundSystem::OnPlayerDamage(const Events::PlayerDamage & e)
|
||||||
|
{
|
||||||
|
if (e.Player.ID == m_LocalPlayer) {
|
||||||
|
Events::PlaySoundOnEntity ev;
|
||||||
|
EntityID child = m_World->CreateEntity(m_LocalPlayer);
|
||||||
|
m_World->AttachComponent(child, "Transform");
|
||||||
|
m_World->AttachComponent(child, "SoundEmitter");
|
||||||
|
ev.EmitterID = child;
|
||||||
|
ev.FilePath = "Audio/hurt/hurt3.wav"; // random between a bunch
|
||||||
|
m_EventBroker->Publish(ev);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SoundSystem::OnPlayerDeath(const Events::PlayerDeath & e)
|
||||||
|
{
|
||||||
|
if (e.PlayerID == m_LocalPlayer) {
|
||||||
|
Events::PlaySoundOnEntity ev;
|
||||||
|
EntityID child = m_World->CreateEntity(m_LocalPlayer);
|
||||||
|
m_World->AttachComponent(child, "Transform");
|
||||||
|
m_World->AttachComponent(child, "SoundEmitter");
|
||||||
|
ev.EmitterID = child;
|
||||||
|
ev.FilePath = "Audio/die/die2.wav"; // random between a bunch
|
||||||
|
m_EventBroker->Publish(ev);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SoundSystem::OnPlayerHealthPickup(const Events::PlayerHealthPickup & e)
|
||||||
|
{
|
||||||
|
if (e.PlayerHealedID == m_LocalPlayer) {
|
||||||
|
Events::PlaySoundOnEntity ev;
|
||||||
|
EntityID child = m_World->CreateEntity(m_LocalPlayer);
|
||||||
|
m_World->AttachComponent(child, "Transform");
|
||||||
|
m_World->AttachComponent(child, "SoundEmitter");
|
||||||
|
ev.EmitterID = child;
|
||||||
|
ev.FilePath = "Audio/pickup/pickup2.wav";
|
||||||
|
m_EventBroker->Publish(ev);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void SoundSystem::setListenerOri(glm::vec3 ori)
|
void SoundSystem::setListenerOri(glm::vec3 ori)
|
||||||
{
|
{
|
||||||
// Calculate forward and up vector.
|
// Calculate forward and up vector.
|
||||||
|
|||||||
Reference in New Issue
Block a user