diff --git a/src/Engine/Network/Server.cpp b/src/Engine/Network/Server.cpp index 39b9260e..1f94a137 100644 --- a/src/Engine/Network/Server.cpp +++ b/src/Engine/Network/Server.cpp @@ -592,7 +592,7 @@ void Server::parseOnInputCommand(Packet& packet) e.Player = EntityWrapper(m_World, m_ConnectedPlayers.at(player).EntityID); e.Value = packet.ReadPrimitive(); m_EventBroker->Publish(e); - if (e.Command == "PrimaryFire" || e.Command == "Reload" || e.Command == "Jump") { + if (e.Command == "PrimaryFire" || e.Command == "Reload") { m_InputCommandsToBroadcast.push_back(e); } //LOG_INFO("Server::parseOnInputCommand: Command is %s. Value is %f. PlayerID is %i.", e.Command.c_str(), e.Value, e.PlayerID); diff --git a/src/Game/Game.cpp b/src/Game/Game.cpp index 7b80727e..372a8c84 100644 --- a/src/Game/Game.cpp +++ b/src/Game/Game.cpp @@ -223,7 +223,9 @@ void Game::Tick() m_EventBroker->Swap(); PerformanceTimer::StartTimerAndStopPrevious("SoundManager"); - m_SoundManager->Update(dt); + if (m_IsClient) { + m_SoundManager->Update(dt); + } // Update network PerformanceTimer::StartTimerAndStopPrevious("Network"); diff --git a/src/Game/Systems/SoundSystem.cpp b/src/Game/Systems/SoundSystem.cpp index 095c9b85..ef61b070 100644 --- a/src/Game/Systems/SoundSystem.cpp +++ b/src/Game/Systems/SoundSystem.cpp @@ -86,16 +86,20 @@ bool SoundSystem::OnCaptured(const Events::Captured & e) return false; } -// Testing purposes atm... bool SoundSystem::OnPlayerDamage(const Events::PlayerDamage & e) { if (!IsClient) { // Only play for clients return false; } - if (!e.Victim.Valid()) { + if (!e.Victim.Valid() || !e.Inflictor.Valid()) { + return false; + } + auto victimTeam = m_World->GetComponent(e.Victim.ID, "Team"); + auto inflictorTeam = m_World->GetComponent(e.Inflictor.ID, "Team"); + if ((int)victimTeam["Team"] == (int)inflictorTeam["Team"]) { + // Victim and inflictor are the same team, should not play "hurt" sound. return false; } - std::vector paths; paths.push_back("Audio/Hurt/Hurt" + std::to_string(m_RandIntDistribution(m_RandomGenerator)) + ".wav"); @@ -141,9 +145,9 @@ bool SoundSystem::OnDoubleJump(const Events::DoubleJump & e) if (!IsClient) { return false; } - Events::PlaySoundOnEntity ev; - ev.Emitter = EntityWrapper(m_World, e.entityID); - ev.FilePath = "Audio/Jump/Jump2.wav"; - m_EventBroker->Publish(ev); + //Events::PlaySoundOnEntity ev; + //ev.Emitter = EntityWrapper(m_World, e.entityID); + //ev.FilePath = "Audio/Jump/Jump2.wav"; + //m_EventBroker->Publish(ev); return false; } \ No newline at end of file