Merge branch 'master' into Respawning

# Conflicts:
#	src/Game/Game.cpp
#	src/Game/Systems/PlayerSpawnSystem.cpp
#	src/Game/Systems/SoundSystem.cpp
This commit is contained in:
William Moberg
2016-02-11 16:15:47 +01:00
126 changed files with 2545 additions and 1062 deletions
+16 -29
View File
@@ -1,19 +1,15 @@
#include "Game/Systems/SoundSystem.h"
SoundSystem::SoundSystem(World* world, EventBroker* eventbroker)
: System(world, eventbroker)
SoundSystem::SoundSystem(SystemParams params)
: System(params)
, PureSystem("SoundEmitter")
//, ImpureSystem()
{
ConfigFile* config = ResourceManager::Load<ConfigFile>("Config.ini");
m_Announcer = ResourceManager::Load<ConfigFile>("Config.ini")->Get<std::string>("Sound.Announcer", "female");
m_World = world;
m_EventBroker = eventbroker;
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_EShoot, &SoundSystem::OnShoot);
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDamage, &SoundSystem::OnPlayerDamage);
EVENT_SUBSCRIBE_MEMBER(m_ECaptured, &SoundSystem::OnCaptured);
EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &SoundSystem::OnTriggerTouch);
@@ -34,9 +30,8 @@ bool SoundSystem::OnPlayerSpawned(const Events::PlayerSpawned &e)
{
if (e.PlayerID == -1) { // Local player
m_World->AttachComponent(e.Player.ID, "Listener");
m_LocalPlayer = e.Player;
Events::PlaySoundOnEntity go;
go.EmitterID = m_LocalPlayer.ID;
go.EmitterID = LocalPlayer.ID;
go.FilePath = "Audio/announcer/" + m_Announcer + "/go.wav";
m_EventBroker->Publish(go);
// TEMP: starts bgm
@@ -59,7 +54,7 @@ bool SoundSystem::OnInputCommand(const Events::InputCommand & e)
}
if (e.Command == "TakeDamage" && e.Value > 0 && m_LocalPlayer.Valid()) {
Events::PlayerDamage ev;
ev.Player = m_LocalPlayer;
ev.Player = LocalPlayer;
ev.Damage = e.Value;
m_EventBroker->Publish(ev);
}
@@ -69,13 +64,14 @@ bool SoundSystem::OnInputCommand(const Events::InputCommand & e)
void SoundSystem::playerJumps()
{
if (!m_LocalPlayer.Valid()) {
if (!LocalPlayer.Valid()) {
return;
}
bool grounded = (bool)m_World->GetComponent(m_LocalPlayer.ID, "Physics")["IsOnGround"];
bool grounded = (bool)m_World->GetComponent(LocalPlayer.ID, "Physics")["IsOnGround"];
if (grounded) {
Events::PlaySoundOnEntity e;
e.EmitterID = m_LocalPlayer.ID;
e.EmitterID = LocalPlayer.ID;
e.FilePath = "Audio/jump/jump1.wav";
m_EventBroker->Publish(e);
}
@@ -92,26 +88,17 @@ bool SoundSystem::drumTimer(double dt)
}
}
bool SoundSystem::OnShoot(const Events::Shoot & e)
{
Events::PlaySoundOnEntity ev;
ev.EmitterID = m_LocalPlayer.ID;
ev.FilePath = "Audio/laser/laser1.wav";
m_EventBroker->Publish(ev);
return true;
}
bool SoundSystem::OnCaptured(const Events::Captured & e)
{
int homeTeam = (int)m_World->GetComponent(e.CapturePointID, "Team")["Team"];
int team = (int)m_World->GetComponent(m_LocalPlayer.ID, "Team")["Team"];
int team = (int)m_World->GetComponent(LocalPlayer.ID, "Team")["Team"];
Events::PlaySoundOnEntity ev;
if (team == homeTeam) {
ev.FilePath = "Audio/announcer/" + m_Announcer + "/objective_achieved.wav";
} else {
ev.FilePath = "Audio/announcer/" + m_Announcer + "/objective_failed.wav"; // have not been tested
}
ev.EmitterID = m_LocalPlayer.ID;
ev.EmitterID = LocalPlayer.ID;
m_EventBroker->Publish(ev);
// Temp for play test.
m_DrumsIsPlaying = false;
@@ -133,7 +120,7 @@ bool SoundSystem::OnPlayerDamage(const Events::PlayerDamage & e)
// paths.push_back("Audio/exhausted/breath.wav");
// }
Events::PlayQueueOnEntity ev;
ev.Emitter = m_LocalPlayer;
ev.Emitter = LocalPlayer;
ev.FilePaths = paths;
m_EventBroker->Publish(ev);
return false;
@@ -142,7 +129,7 @@ bool SoundSystem::OnPlayerDamage(const Events::PlayerDamage & e)
bool SoundSystem::OnPlayerDeath(const Events::PlayerDeath & e)
{
Events::PlaySoundOnEntity ev;
ev.EmitterID = m_LocalPlayer.ID;
ev.EmitterID = LocalPlayer.ID;
ev.FilePath = "Audio/die/die2.wav";
m_EventBroker->Publish(ev);
return false;
@@ -151,7 +138,7 @@ bool SoundSystem::OnPlayerDeath(const Events::PlayerDeath & e)
bool SoundSystem::OnPlayerHealthPickup(const Events::PlayerHealthPickup & e)
{
Events::PlaySoundOnEntity ev;
ev.EmitterID = m_LocalPlayer.ID;
ev.EmitterID = LocalPlayer.ID;
ev.FilePath = "Audio/pickup/pickup2.wav";
m_EventBroker->Publish(ev);
return false;
@@ -165,7 +152,7 @@ bool SoundSystem::OnTriggerTouch(const Events::TriggerTouch & e)
}
if (m_World->HasComponent(e.Trigger.ID, "CapturePoint")) {
Events::PlaySoundOnEntity ev; // should be BGM
ev.EmitterID = m_LocalPlayer.ID;
ev.EmitterID = LocalPlayer.ID;
ev.FilePath = "Audio/bgm/drumstest.wav";
m_EventBroker->Publish(ev);
// Temp for play test.
@@ -177,7 +164,7 @@ bool SoundSystem::OnTriggerTouch(const Events::TriggerTouch & e)
bool SoundSystem::OnDoubleJump(const Events::DoubleJump & e)
{
Events::PlaySoundOnEntity ev;
ev.EmitterID = m_LocalPlayer.ID;
ev.EmitterID = LocalPlayer.ID;
ev.FilePath = "Audio/jump/jump2.wav";
m_EventBroker->Publish(ev);
return false;
@@ -186,7 +173,7 @@ bool SoundSystem::OnDoubleJump(const Events::DoubleJump & e)
bool SoundSystem::OnDashAbility(const Events::DashAbility &e)
{
Events::PlaySoundOnEntity ev;
ev.EmitterID = m_LocalPlayer.ID;
ev.EmitterID = LocalPlayer.ID;
ev.FilePath = "Audio/jump/dash1.wav";
m_EventBroker->Publish(ev);
return false;