Refactoring SoundSystem and its events, components

This commit is contained in:
Stiffly
2015-09-28 17:59:57 +02:00
parent 0e6fcfb2ba
commit f10749d220
9 changed files with 77 additions and 116 deletions
+20 -21
View File
@@ -1,61 +1,60 @@
#ifndef DAYDREAM_SOUND_H
#define DAYDREAM_SOUND_H
#ifndef SYSTEMS_SOUNDSYSTEM_H__
#define SYSTEMS_SOUNDSYSTEM_H__
#include "AL/al.h"
#include "AL/alc.h"
#include "Core/System.h"
#include "Core/World.h"
#include "Core/EventBroker.h"
#include "Core/ResourceManager.h"
#include "Sound.h"
#include "Sound/EPlaySound.h"
#include "Sound/EStopSound.h"
#include "Sound/EMasterVolume.h"
#include "Sound/CCollisionSound.h"
#include "Physics/EContact.h"
#include "Game/CBall.h"
#include "Game/CBrick.h"
#include "Game/CPad.h"
#include "Sound/CCollisionSound.h"
#include "Core/ResourceManager.h"
namespace dd
{
namespace Systems
{
class SoundSystem : public System {
public:
SoundSystem(World *world, std::shared_ptr<dd::EventBroker> eventBroker)
: System(world, eventBroker) { }
~SoundSystem();
void Initialize() override;
void Update(double dt) override;
private:
float m_BGMMasterVolume = 1.f;
float m_SFXMasterVolume = 1.f;
std::map<ALuint, Sound*> m_BGMSourcesToBuffers;
std::map<ALuint, Sound*> m_SFXSourcesToBuffers;
ALCdevice* m_Device = nullptr;
//Events
dd::EventRelay<SoundSystem, dd::Events::PlaySound> m_EPlaySFX;
dd::EventRelay<SoundSystem, dd::Events::Contact> m_EContact;
dd::EventRelay<SoundSystem, dd::Events::StopSound> m_EStopSound;
dd::EventRelay<SoundSystem, dd::Events::MasterVolume> m_EMasterVolume;
bool OnPlaySound(const dd::Events::PlaySound &event);
//On contact: play the sound given in the CCOllisionSound.
dd::EventRelay<SoundSystem, dd::Events::Contact> m_EContact;
bool OnContact(const dd::Events::Contact &event);
dd::EventRelay<SoundSystem, dd::Events::StopSound> m_EStopSound;
bool OnStopSound(const dd::Events::StopSound &event);
dd::EventRelay<SoundSystem, dd::Events::MasterVolume> m_EMasterVolume;
bool OnMasterVolume(const dd::Events::MasterVolume &event);
ALuint CreateSource();
std::map<ALuint, Sound*> m_BGMSourcesToBuffers;
std::map<ALuint, Sound*> m_SFXSourcesToBuffers;
ALCdevice* m_Device;
float m_BGMMasterVolume, m_SFXMasterVolume;
};
}
}
#endif //DAYDREAM_SOUND_H
#endif