Sets velocity to 0, does not make use of doppler effect atm

This commit is contained in:
stiffly
2016-03-01 14:47:57 +01:00
parent 2c56b03b2b
commit d3ffb9768b
5 changed files with 34 additions and 42 deletions
-4
View File
@@ -44,10 +44,6 @@ private:
bool OnInputCommand(const Events::InputCommand &e);
EventRelay<SoundSystem, Events::DoubleJump> m_EDoubleJump;
bool OnDoubleJump(const Events::DoubleJump &e);
EventRelay<SoundSystem, Events::DashAbility> m_EDashAbility;
bool OnDashAbility(const Events::DashAbility &e);
EventRelay<SoundSystem, Events::TriggerTouch> m_ETriggerTouch;
bool OnTriggerTouch(const Events::TriggerTouch &e);
EventRelay<SoundSystem, Events::Captured> m_ECaptured;
bool OnCaptured(const Events::Captured &e);
EventRelay<SoundSystem, Events::PlayerDamage> m_EPlayerDamage;
@@ -2,6 +2,7 @@
#include "Collision/Collision.h"
#include "Core/EPlayerDamage.h"
#include "Rendering/ESetCamera.h"
#include "Sound/EPlaySoundOnEntity.h"
class DefenderWeaponBehaviour : public WeaponBehaviour<DefenderWeaponBehaviour>
{
+1 -1
View File
@@ -122,7 +122,7 @@ void SoundManager::updateEmitters(double dt)
// Calculate velocity
glm::vec3 velocity = glm::vec3(nextPos - previousPos) / (float)dt;
setSourcePos(it->second->ALsource, nextPos);
setSourceVel(it->second->ALsource, velocity);
setSourceVel(it->second->ALsource, glm::vec3(0));
auto emitter = m_World->GetComponent(it->first, "SoundEmitter");
setSoundProperties(it->second, &emitter);
+28 -37
View File
@@ -6,16 +6,14 @@ SoundSystem::SoundSystem(SystemParams params)
{
ConfigFile* config = ResourceManager::Load<ConfigFile>("Config.ini");
m_Announcer = ResourceManager::Load<ConfigFile>("Config.ini")->Get<std::string>("Sound.Announcer", "female");
if (IsClient) {
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &SoundSystem::OnPlayerSpawned);
EVENT_SUBSCRIBE_MEMBER(m_InputCommand, &SoundSystem::OnInputCommand);
EVENT_SUBSCRIBE_MEMBER(m_EDoubleJump, &SoundSystem::OnDoubleJump);
EVENT_SUBSCRIBE_MEMBER(m_EDashAbility, &SoundSystem::OnDashAbility);
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDamage, &SoundSystem::OnPlayerDamage);
EVENT_SUBSCRIBE_MEMBER(m_ECaptured, &SoundSystem::OnCaptured);
EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &SoundSystem::OnTriggerTouch);
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDeath, &SoundSystem::OnPlayerDeath);
}
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &SoundSystem::OnPlayerSpawned);
EVENT_SUBSCRIBE_MEMBER(m_InputCommand, &SoundSystem::OnInputCommand);
EVENT_SUBSCRIBE_MEMBER(m_EDoubleJump, &SoundSystem::OnDoubleJump);
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDamage, &SoundSystem::OnPlayerDamage);
EVENT_SUBSCRIBE_MEMBER(m_ECaptured, &SoundSystem::OnCaptured);
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDeath, &SoundSystem::OnPlayerDeath);
}
void SoundSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& cComponent, double dt)
@@ -52,6 +50,19 @@ bool SoundSystem::OnInputCommand(const Events::InputCommand & e)
playerJumps();
return true;
}
}
if (e.Command == "SoundTemp" && e.Value > 0) {
EntityWrapper entity(m_World, m_World->CreateEntity());
auto transform = m_World->AttachComponent(entity.ID, "Transform");
(glm::vec3&)transform["Position"] = glm::vec3(0, 10, 0);
(glm::vec3&)transform["Scale"] = glm::vec3(10, 10, 10);
auto emitter = m_World->AttachComponent(entity.ID, "SoundEmitter");
auto model = m_World->AttachComponent(entity.ID, "Model");
(std::string&)model["Resource"] = "Models/Core/UnitCube.mesh";
Events::PlaySoundOnEntity ev;
ev.EmitterID = entity.ID;
ev.FilePath = "Audio/crosscounter.wav";
m_EventBroker->Publish(ev);
}
return false;
@@ -136,37 +147,17 @@ bool SoundSystem::OnPlayerHealthPickup(const Events::PlayerHealthPickup & e)
return false;
}
bool SoundSystem::OnTriggerTouch(const Events::TriggerTouch & e)
{
//// Temp for play test.
//if (m_DrumsIsPlaying) {
// return false;
//}
//if (m_World->HasComponent(e.Trigger.ID, "CapturePoint")) {
// Events::PlaySoundOnEntity ev; // should be BGM
// ev.EmitterID = LocalPlayer.ID;
// ev.FilePath = "Audio/bgm/drumstest.wav";
// m_EventBroker->Publish(ev);
// // Temp for play test.
// m_DrumsIsPlaying = true;
//}
return false;
}
bool SoundSystem::OnDoubleJump(const Events::DoubleJump & e)
{
if (!m_World->ValidEntity(e.entityID)) {
return false;
}
if (!IsClient) {
return false;
}
Events::PlaySoundOnEntity ev;
ev.EmitterID = LocalPlayer.ID;
ev.EmitterID = e.entityID;
ev.FilePath = "Audio/jump/jump2.wav";
m_EventBroker->Publish(ev);
return false;
}
bool SoundSystem::OnDashAbility(const Events::DashAbility &e)
{
Events::PlaySoundOnEntity ev;
ev.EmitterID = LocalPlayer.ID;
ev.FilePath = "Audio/jump/dash1.wav";
m_EventBroker->Publish(ev);
return false;
}
@@ -86,6 +86,10 @@ void DefenderWeaponBehaviour::fireShell(WeaponInfo& wi)
}
if (weaponModelEntity.Valid()) {
EntityWrapper spawner = weaponModelEntity.FirstChildByName("WeaponMuzzle");
Events::PlaySoundOnEntity e;
e.EmitterID = weaponModelEntity.ID;
e.FilePath = "Audio/laser/laser1.wav";
m_EventBroker->Publish(e);
for (auto& angles : pelletAngles) {
glm::vec3 direction = Transform::AbsoluteOrientation(spawner) * glm::quat(glm::vec3(angles, 0.f)) * glm::vec3(0, 0, -1);
float distance = traceRayDistance(Transform::AbsolutePosition(spawner), direction);