Merge pull request #221 from teamfisk/PerfectSoundForRelease
Perfect sound for release
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
#include "Network/ESearchForServers.h"
|
||||
#include "Network/EInterpolate.h"
|
||||
#include "Network/SnapshotFilter.h"
|
||||
#include "Core/EWin.h"
|
||||
|
||||
class Client : public Network
|
||||
{
|
||||
@@ -107,6 +108,7 @@ private:
|
||||
void parseAmmoPickup(Packet& packet);
|
||||
void parseRemoveWorld(Packet& packet);
|
||||
void parseKDEvent(Packet& packet);
|
||||
void parseWin(Packet& packet);
|
||||
void InterpolateFields(Packet& packet, const ComponentInfo & componentInfo, const EntityID & entityID, const std::string & componentType);
|
||||
void parseSnapshot(Packet& packet);
|
||||
void identifyPacketLoss();
|
||||
|
||||
@@ -25,6 +25,7 @@ enum class MessageType
|
||||
AmmoPickup,
|
||||
RemoveWorld,
|
||||
KD,
|
||||
Win,
|
||||
Invalid
|
||||
};
|
||||
|
||||
|
||||
@@ -81,6 +81,7 @@ private:
|
||||
void setSoundProperties(Source* source, ComponentWrapper* soundComponent);
|
||||
float getDurationSeconds(Source* source);
|
||||
float getTimeOffsetSeconds(Source* source);
|
||||
void setTimeOffsetSeconds(Source* source, float timeOffset);
|
||||
|
||||
// Specific logic
|
||||
void playSound(Source* source);
|
||||
|
||||
@@ -176,6 +176,9 @@ void Client::parseMessageType(Packet& packet)
|
||||
case MessageType::KD:
|
||||
parseKDEvent(packet);
|
||||
break;
|
||||
case MessageType::Win:
|
||||
parseWin(packet);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -376,6 +379,13 @@ void Client::parseKDEvent(Packet & packet)
|
||||
m_EventBroker->Publish(e);
|
||||
}
|
||||
|
||||
void Client::parseWin(Packet& packet)
|
||||
{
|
||||
Events::Win e;
|
||||
e.TeamThatWon = packet.ReadPrimitive<int>();
|
||||
m_EventBroker->Publish(e);
|
||||
}
|
||||
|
||||
void Client::updateFields(Packet& packet, const ComponentInfo& componentInfo, const EntityID& entityID)
|
||||
{
|
||||
for (auto field : componentInfo.FieldsInOrder) {
|
||||
|
||||
@@ -609,6 +609,9 @@ bool Server::OnWin(const Events::Win & e)
|
||||
{
|
||||
// Postpone the gameover reset
|
||||
m_GameIsOver = true;
|
||||
Packet winPacket = Packet(MessageType::Win);
|
||||
winPacket.WritePrimitive(e.TeamThatWon);
|
||||
reliableBroadcast(winPacket);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -417,6 +417,14 @@ bool SoundManager::OnSetCamera(const Events::SetCamera& e)
|
||||
alSourcei(m_CurrentBGMCombo->ALsource, AL_LOOPING, 1);
|
||||
setGain(m_CurrentBGMCombo, 0);
|
||||
playSound(m_CurrentBGMCombo);
|
||||
} else if (m_World->HasComponent(e.CameraEntity.ID, "EndScreen")) {
|
||||
float timeOffset = getTimeOffsetSeconds(m_CurrentBGM);
|
||||
stopSound(m_CurrentBGM);
|
||||
m_CurrentBGM = createSource("Audio/BGM/Layer3.wav");
|
||||
m_CurrentBGM->Type = SoundType::BGM;
|
||||
alSourcei(m_CurrentBGM->ALsource, AL_LOOPING, 1);
|
||||
playSound(m_CurrentBGM);
|
||||
setTimeOffsetSeconds(m_CurrentBGM, timeOffset);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -477,6 +485,11 @@ float SoundManager::getTimeOffsetSeconds(Source* source)
|
||||
return time;
|
||||
}
|
||||
|
||||
void SoundManager::setTimeOffsetSeconds(Source * source, float timeOffset)
|
||||
{
|
||||
alSourcef(source->ALsource, AL_SEC_OFFSET, timeOffset);
|
||||
}
|
||||
|
||||
void SoundManager::initOpenAL()
|
||||
{
|
||||
// Initialize OpenAL
|
||||
|
||||
@@ -87,6 +87,9 @@ bool SoundSystem::OnPlayerDamage(const Events::PlayerDamage & e)
|
||||
if (!e.Victim.Valid() || !e.Inflictor.Valid()) {
|
||||
return false;
|
||||
}
|
||||
if (e.Victim.ID != LocalPlayer.ID) {
|
||||
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"]) {
|
||||
|
||||
Reference in New Issue
Block a user