diff --git a/include/Game/Systems/SoundSystem.h b/include/Game/Systems/SoundSystem.h index 3826b62a..003c6f66 100644 --- a/include/Game/Systems/SoundSystem.h +++ b/include/Game/Systems/SoundSystem.h @@ -44,10 +44,6 @@ private: bool OnInputCommand(const Events::InputCommand &e); EventRelay m_EDoubleJump; bool OnDoubleJump(const Events::DoubleJump &e); - EventRelay m_EDashAbility; - bool OnDashAbility(const Events::DashAbility &e); - EventRelay m_ETriggerTouch; - bool OnTriggerTouch(const Events::TriggerTouch &e); EventRelay m_ECaptured; bool OnCaptured(const Events::Captured &e); EventRelay m_EPlayerDamage; diff --git a/include/Game/Systems/Weapon/DefenderWeaponBehaviour.h b/include/Game/Systems/Weapon/DefenderWeaponBehaviour.h index 5ca13d3e..c4b814a1 100644 --- a/include/Game/Systems/Weapon/DefenderWeaponBehaviour.h +++ b/include/Game/Systems/Weapon/DefenderWeaponBehaviour.h @@ -2,6 +2,7 @@ #include "Collision/Collision.h" #include "Core/EPlayerDamage.h" #include "Rendering/ESetCamera.h" +#include "Sound/EPlaySoundOnEntity.h" class DefenderWeaponBehaviour : public WeaponBehaviour { diff --git a/src/Engine/Sound/SoundManager.cpp b/src/Engine/Sound/SoundManager.cpp index 272cb89e..d271e260 100644 --- a/src/Engine/Sound/SoundManager.cpp +++ b/src/Engine/Sound/SoundManager.cpp @@ -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); diff --git a/src/Game/Systems/SoundSystem.cpp b/src/Game/Systems/SoundSystem.cpp index a79711ae..c446ee3c 100644 --- a/src/Game/Systems/SoundSystem.cpp +++ b/src/Game/Systems/SoundSystem.cpp @@ -6,16 +6,14 @@ SoundSystem::SoundSystem(SystemParams params) { ConfigFile* config = ResourceManager::Load("Config.ini"); m_Announcer = ResourceManager::Load("Config.ini")->Get("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; } \ No newline at end of file diff --git a/src/Game/Systems/Weapon/DefenderWeaponBehaviour.cpp b/src/Game/Systems/Weapon/DefenderWeaponBehaviour.cpp index 028bd10c..fbc6e37c 100644 --- a/src/Game/Systems/Weapon/DefenderWeaponBehaviour.cpp +++ b/src/Game/Systems/Weapon/DefenderWeaponBehaviour.cpp @@ -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);