Used config for soundsystem properties.

This commit is contained in:
stiffly
2016-02-08 16:40:13 +01:00
parent 7752832ce5
commit aa5878d6df
6 changed files with 18 additions and 5 deletions
+1 -1
Submodule assets updated: cfeeb1f880...88b1b9f047
+2
View File
@@ -13,6 +13,8 @@
#include "Core/World.h"
#include "Core/EventBroker.h"
#include "../Engine/Core/ResourceManager.h"
#include "../Engine/Core/ConfigFile.h"
#include "Core/Transform.h" // Absolute transform
#include "Sound/Sound.h"
#include "../Engine/Sound/EPlayQueueOnEntity.h"
+2
View File
@@ -5,6 +5,7 @@
#include "../Engine/Core/System.h"
#include "../Engine/Core/ResourceManager.h"
#include "../Engine/Core/ConfigFile.h"
#include "../Engine/Sound/Sound.h"
#include "../Engine/Sound/EPlayQueueOnEntity.h"
#include "../Engine/Core/EPlayerSpawned.h"
@@ -34,6 +35,7 @@ private:
World* m_World = nullptr;
EventBroker* m_EventBroker = nullptr;
std::string m_Announcer = "";
// Logic for playing a sound when a player jumps
void playerJumps();
+5
View File
@@ -29,3 +29,8 @@ TimeoutMs=15000
[Multithreading]
ResourceLoading=true
[Sound]
BGMVolume=1.0
SFXVolume=1.0
Announcer=female
+3 -1
View File
@@ -2,12 +2,14 @@
SoundManager::SoundManager(World* world, EventBroker* eventBroker, bool editorMode)
{
ConfigFile* config = ResourceManager::Load<ConfigFile>("Config.ini");
m_EventBroker = eventBroker;
m_World = world;
m_EditorEnabled = editorMode;
m_BGMVolumeChannel = config->Get<float>("Sound.BGMVolume", 1.f);
m_SFXVolumeChannel = config->Get<float>("Sound.SFXVolume", 1.f);
initOpenAL();
alSpeedOfSound(340.29f);
alDistanceModel(AL_LINEAR_DISTANCE);
alDopplerFactor(1);
+5 -3
View File
@@ -5,6 +5,8 @@ SoundSystem::SoundSystem(World* world, EventBroker* eventbroker)
, 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);
@@ -30,7 +32,7 @@ bool SoundSystem::OnPlayerSpawned(const Events::PlayerSpawned &e)
m_LocalPlayer = e.Player;
Events::PlaySoundOnEntity go;
go.EmitterID = createChildEmitter(m_LocalPlayer);
go.FilePath = "Audio/announcer/go.wav";
go.FilePath = "Audio/announcer/" + m_Announcer + "/go.wav";
m_EventBroker->Publish(go);
// TEMP: starts bgm
{
@@ -86,9 +88,9 @@ bool SoundSystem::OnCaptured(const Events::Captured & e)
int team = (int)m_World->GetComponent(m_LocalPlayer.ID, "Team")["Team"];
Events::PlaySoundOnEntity ev;
if (team == homeTeam) {
ev.FilePath = "Audio/announcer/objective_achieved.wav";
ev.FilePath = "Audio/announcer/" + m_Announcer + "/objective_achieved.wav";
} else {
ev.FilePath = "Audio/announcer/objective_failed.wav"; // have not been tested
ev.FilePath = "Audio/announcer/" + m_Announcer + "/objective_failed.wav"; // have not been tested
}
ev.EmitterID = createChildEmitter(m_LocalPlayer);
m_EventBroker->Publish(ev);