No longer using a variable to see if we're in editor mode.
This commit is contained in:
@@ -49,7 +49,7 @@ class SoundManager
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SoundManager() { }
|
SoundManager() { }
|
||||||
SoundManager(World* world, EventBroker* eventBroker, bool editorMode);
|
SoundManager(World* world, EventBroker* eventBroker);
|
||||||
~SoundManager();
|
~SoundManager();
|
||||||
// Update emitters / listener
|
// Update emitters / listener
|
||||||
void Update(double dt);
|
void Update(double dt);
|
||||||
@@ -93,7 +93,6 @@ private:
|
|||||||
|
|
||||||
float m_BGMVolumeChannel = 1.0f;
|
float m_BGMVolumeChannel = 1.0f;
|
||||||
float m_SFXVolumeChannel = 1.0f;
|
float m_SFXVolumeChannel = 1.0f;
|
||||||
bool m_EditorEnabled = false;
|
|
||||||
EntityWrapper m_LocalPlayer = EntityWrapper();
|
EntityWrapper m_LocalPlayer = EntityWrapper();
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
#include "Sound/SoundManager.h"
|
#include "Sound/SoundManager.h"
|
||||||
|
|
||||||
SoundManager::SoundManager(World* world, EventBroker* eventBroker, bool editorMode)
|
SoundManager::SoundManager(World* world, EventBroker* eventBroker)
|
||||||
{
|
{
|
||||||
ConfigFile* config = ResourceManager::Load<ConfigFile>("Config.ini");
|
ConfigFile* config = ResourceManager::Load<ConfigFile>("Config.ini");
|
||||||
m_EventBroker = eventBroker;
|
m_EventBroker = eventBroker;
|
||||||
m_World = world;
|
m_World = world;
|
||||||
m_EditorEnabled = editorMode;
|
|
||||||
m_BGMVolumeChannel = config->Get<float>("Sound.BGMVolume", 1.f);
|
m_BGMVolumeChannel = config->Get<float>("Sound.BGMVolume", 1.f);
|
||||||
m_SFXVolumeChannel = config->Get<float>("Sound.SFXVolume", 1.f);
|
m_SFXVolumeChannel = config->Get<float>("Sound.SFXVolume", 1.f);
|
||||||
|
|
||||||
@@ -103,9 +102,9 @@ void SoundManager::updateEmitters(double dt)
|
|||||||
if (!m_World->ValidEntity(it->first)) {
|
if (!m_World->ValidEntity(it->first)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!m_World->HasComponent(it->first, "SoundEmitter"))
|
if (!m_World->HasComponent(it->first, "SoundEmitter"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
glm::vec3 previousPos;
|
glm::vec3 previousPos;
|
||||||
alGetSource3f(it->second->ALsource, AL_POSITION, &previousPos.x, &previousPos.y, &previousPos.z);
|
alGetSource3f(it->second->ALsource, AL_POSITION, &previousPos.x, &previousPos.y, &previousPos.z);
|
||||||
// Get next pos
|
// Get next pos
|
||||||
@@ -123,14 +122,11 @@ void SoundManager::updateEmitters(double dt)
|
|||||||
auto emitter = m_World->GetComponent(it->first, "SoundEmitter");
|
auto emitter = m_World->GetComponent(it->first, "SoundEmitter");
|
||||||
setSoundProperties(it->second, &emitter);
|
setSoundProperties(it->second, &emitter);
|
||||||
|
|
||||||
// To make an emitter play when spawned in editor mode
|
// Path changed
|
||||||
if (m_EditorEnabled) {
|
if (it->second->SoundResource->Path() != (std::string)emitter["FilePath"]) {
|
||||||
// Path changed
|
it->second->SoundResource = ResourceManager::Load<Sound>((std::string)emitter["FilePath"]);
|
||||||
if (it->second->SoundResource->Path() != (std::string)emitter["FilePath"]) {
|
if (it->second->SoundResource->Buffer() != 0) {
|
||||||
it->second->SoundResource = ResourceManager::Load<Sound>((std::string)emitter["FilePath"]);
|
playSound(it->second);
|
||||||
if (it->second->SoundResource->Buffer() != 0) {
|
|
||||||
playSound(it->second);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -145,8 +141,7 @@ void SoundManager::updateListener(double dt)
|
|||||||
}
|
}
|
||||||
for (auto it = listenerComponents->begin(); it != listenerComponents->end(); it++) {
|
for (auto it = listenerComponents->begin(); it != listenerComponents->end(); it++) {
|
||||||
EntityWrapper listener(m_World, (*it).EntityID);
|
EntityWrapper listener(m_World, (*it).EntityID);
|
||||||
if (!listener.Valid())
|
if (!listener.Valid()) {
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (listener.IsChildOf(m_LocalPlayer) || listener == m_LocalPlayer) {
|
if (listener.IsChildOf(m_LocalPlayer) || listener == m_LocalPlayer) {
|
||||||
@@ -242,9 +237,8 @@ bool SoundManager::OnContinueSound(const Events::ContinueSound & e)
|
|||||||
bool SoundManager::OnPlayBackgroundMusic(const Events::PlayBackgroundMusic & e)
|
bool SoundManager::OnPlayBackgroundMusic(const Events::PlayBackgroundMusic & e)
|
||||||
{
|
{
|
||||||
auto listenerComponents = m_World->GetComponents("Listener");
|
auto listenerComponents = m_World->GetComponents("Listener");
|
||||||
LOG_INFO("SIZZE: %i", listenerComponents->size());
|
|
||||||
for (auto it = listenerComponents->begin(); it != listenerComponents->end(); it++) {
|
for (auto it = listenerComponents->begin(); it != listenerComponents->end(); it++) {
|
||||||
if((*it).EntityID != m_LocalPlayer.ID) {
|
if ((*it).EntityID != m_LocalPlayer.ID) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
auto emitterChild = m_World->CreateEntity((*it).EntityID);
|
auto emitterChild = m_World->CreateEntity((*it).EntityID);
|
||||||
|
|||||||
+1
-1
@@ -74,7 +74,7 @@ Game::Game(int argc, char* argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create the sound manager
|
// Create the sound manager
|
||||||
m_SoundManager = new SoundManager(m_World, m_EventBroker, true);
|
m_SoundManager = new SoundManager(m_World, m_EventBroker);
|
||||||
|
|
||||||
// Create Octrees
|
// Create Octrees
|
||||||
m_OctreeCollision = new Octree<EntityAABB>(AABB(glm::vec3(-100), glm::vec3(100)), 4);
|
m_OctreeCollision = new Octree<EntityAABB>(AABB(glm::vec3(-100), glm::vec3(100)), 4);
|
||||||
|
|||||||
Reference in New Issue
Block a user