Added Listener component
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
#ifndef Components_Listener_h__
|
||||
#define Components_Listener_h__
|
||||
|
||||
#include <string>
|
||||
#include <glm/common.hpp>
|
||||
#include "Component.h"
|
||||
|
||||
namespace Components
|
||||
{
|
||||
|
||||
struct Listener : Component
|
||||
{
|
||||
Listener() {}
|
||||
|
||||
virtual Listener* Clone() const override { return new Listener(*this); }
|
||||
};
|
||||
|
||||
}
|
||||
#endif // !Components_Listener_h__
|
||||
@@ -6,12 +6,15 @@ void Systems::SoundSystem::Initialize()
|
||||
{
|
||||
FMOD_RESULT result;
|
||||
result = FMOD::System_Create(&m_FmodSystem);
|
||||
|
||||
result = m_FmodSystem->init(32, FMOD_INIT_NORMAL, 0);
|
||||
|
||||
|
||||
FMOD::Sound *sound;
|
||||
FMOD::Channel *channel;
|
||||
|
||||
FMOD_VECTOR pos;
|
||||
pos.x = 0.f;
|
||||
pos.y = 0.f;
|
||||
pos.z = 0.f;
|
||||
m_FmodSystem->createSound("Sounds/WUB.mp3", FMOD_HARDWARE, 0, &sound);
|
||||
m_FmodSystem->playSound(FMOD_CHANNEL_FREE, sound, false, 0);
|
||||
}
|
||||
@@ -19,6 +22,7 @@ void Systems::SoundSystem::Initialize()
|
||||
void Systems::SoundSystem::RegisterComponents(ComponentFactory* cf)
|
||||
{
|
||||
cf->Register<Components::SoundEmitter>([]() { return new Components::SoundEmitter(); });
|
||||
cf->Register<Components::Listener>([]() { return new Components::Listener(); });
|
||||
}
|
||||
|
||||
void Systems::SoundSystem::RegisterResourceTypes(ResourceManager* rm)
|
||||
@@ -30,3 +34,12 @@ void Systems::SoundSystem::Update(double dt)
|
||||
{
|
||||
m_FmodSystem->update();
|
||||
}
|
||||
|
||||
void Systems::SoundSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
||||
{
|
||||
auto listener = m_World->GetComponent<Components::Listener>(entity);
|
||||
if(listener)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "System.h"
|
||||
#include "Components/Transform.h"
|
||||
#include "Components/SoundEmitter.h"
|
||||
#include "Components/Listener.h"
|
||||
#include "Events/PlaySound.h"
|
||||
#include "Sound.h"
|
||||
|
||||
@@ -23,6 +24,8 @@ public:
|
||||
void RegisterResourceTypes(ResourceManager* rm) override;
|
||||
void Initialize() override;
|
||||
void Update(double dt) override;
|
||||
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
|
||||
//void OnComponentCreated(std::string type, std::shared_ptr<Component> component) override;
|
||||
|
||||
FMOD::System *m_FmodSystem;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user