Used config for soundsystem properties.
This commit is contained in:
+1
-1
Submodule assets updated: cfeeb1f880...88b1b9f047
@@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
#include "Core/World.h"
|
#include "Core/World.h"
|
||||||
#include "Core/EventBroker.h"
|
#include "Core/EventBroker.h"
|
||||||
|
#include "../Engine/Core/ResourceManager.h"
|
||||||
|
#include "../Engine/Core/ConfigFile.h"
|
||||||
#include "Core/Transform.h" // Absolute transform
|
#include "Core/Transform.h" // Absolute transform
|
||||||
#include "Sound/Sound.h"
|
#include "Sound/Sound.h"
|
||||||
#include "../Engine/Sound/EPlayQueueOnEntity.h"
|
#include "../Engine/Sound/EPlayQueueOnEntity.h"
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include "../Engine/Core/System.h"
|
#include "../Engine/Core/System.h"
|
||||||
#include "../Engine/Core/ResourceManager.h"
|
#include "../Engine/Core/ResourceManager.h"
|
||||||
|
#include "../Engine/Core/ConfigFile.h"
|
||||||
#include "../Engine/Sound/Sound.h"
|
#include "../Engine/Sound/Sound.h"
|
||||||
#include "../Engine/Sound/EPlayQueueOnEntity.h"
|
#include "../Engine/Sound/EPlayQueueOnEntity.h"
|
||||||
#include "../Engine/Core/EPlayerSpawned.h"
|
#include "../Engine/Core/EPlayerSpawned.h"
|
||||||
@@ -34,6 +35,7 @@ private:
|
|||||||
|
|
||||||
World* m_World = nullptr;
|
World* m_World = nullptr;
|
||||||
EventBroker* m_EventBroker = nullptr;
|
EventBroker* m_EventBroker = nullptr;
|
||||||
|
std::string m_Announcer = "";
|
||||||
|
|
||||||
// Logic for playing a sound when a player jumps
|
// Logic for playing a sound when a player jumps
|
||||||
void playerJumps();
|
void playerJumps();
|
||||||
|
|||||||
@@ -29,3 +29,8 @@ TimeoutMs=15000
|
|||||||
|
|
||||||
[Multithreading]
|
[Multithreading]
|
||||||
ResourceLoading=true
|
ResourceLoading=true
|
||||||
|
|
||||||
|
[Sound]
|
||||||
|
BGMVolume=1.0
|
||||||
|
SFXVolume=1.0
|
||||||
|
Announcer=female
|
||||||
@@ -2,12 +2,14 @@
|
|||||||
|
|
||||||
SoundManager::SoundManager(World* world, EventBroker* eventBroker, bool editorMode)
|
SoundManager::SoundManager(World* world, EventBroker* eventBroker, bool editorMode)
|
||||||
{
|
{
|
||||||
|
ConfigFile* config = ResourceManager::Load<ConfigFile>("Config.ini");
|
||||||
m_EventBroker = eventBroker;
|
m_EventBroker = eventBroker;
|
||||||
m_World = world;
|
m_World = world;
|
||||||
m_EditorEnabled = editorMode;
|
m_EditorEnabled = editorMode;
|
||||||
|
m_BGMVolumeChannel = config->Get<float>("Sound.BGMVolume", 1.f);
|
||||||
|
m_SFXVolumeChannel = config->Get<float>("Sound.SFXVolume", 1.f);
|
||||||
|
|
||||||
initOpenAL();
|
initOpenAL();
|
||||||
|
|
||||||
alSpeedOfSound(340.29f);
|
alSpeedOfSound(340.29f);
|
||||||
alDistanceModel(AL_LINEAR_DISTANCE);
|
alDistanceModel(AL_LINEAR_DISTANCE);
|
||||||
alDopplerFactor(1);
|
alDopplerFactor(1);
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ SoundSystem::SoundSystem(World* world, EventBroker* eventbroker)
|
|||||||
, PureSystem("SoundEmitter")
|
, PureSystem("SoundEmitter")
|
||||||
//, ImpureSystem()
|
//, 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_World = world;
|
||||||
m_EventBroker = eventbroker;
|
m_EventBroker = eventbroker;
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &SoundSystem::OnPlayerSpawned);
|
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &SoundSystem::OnPlayerSpawned);
|
||||||
@@ -30,7 +32,7 @@ bool SoundSystem::OnPlayerSpawned(const Events::PlayerSpawned &e)
|
|||||||
m_LocalPlayer = e.Player;
|
m_LocalPlayer = e.Player;
|
||||||
Events::PlaySoundOnEntity go;
|
Events::PlaySoundOnEntity go;
|
||||||
go.EmitterID = createChildEmitter(m_LocalPlayer);
|
go.EmitterID = createChildEmitter(m_LocalPlayer);
|
||||||
go.FilePath = "Audio/announcer/go.wav";
|
go.FilePath = "Audio/announcer/" + m_Announcer + "/go.wav";
|
||||||
m_EventBroker->Publish(go);
|
m_EventBroker->Publish(go);
|
||||||
// TEMP: starts bgm
|
// 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"];
|
int team = (int)m_World->GetComponent(m_LocalPlayer.ID, "Team")["Team"];
|
||||||
Events::PlaySoundOnEntity ev;
|
Events::PlaySoundOnEntity ev;
|
||||||
if (team == homeTeam) {
|
if (team == homeTeam) {
|
||||||
ev.FilePath = "Audio/announcer/objective_achieved.wav";
|
ev.FilePath = "Audio/announcer/" + m_Announcer + "/objective_achieved.wav";
|
||||||
} else {
|
} 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);
|
ev.EmitterID = createChildEmitter(m_LocalPlayer);
|
||||||
m_EventBroker->Publish(ev);
|
m_EventBroker->Publish(ev);
|
||||||
|
|||||||
Reference in New Issue
Block a user