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;
|
||||
|
||||
|
||||
@@ -133,6 +133,7 @@
|
||||
<ClInclude Include="..\..\src\Components\FreeSteering.h" />
|
||||
<ClInclude Include="..\..\src\Components\HingeConstraint.h" />
|
||||
<ClInclude Include="..\..\src\Components\Input.h" />
|
||||
<ClInclude Include="..\..\src\Components\Listener.h" />
|
||||
<ClInclude Include="..\..\src\Components\MeshShape.h" />
|
||||
<ClInclude Include="..\..\src\Components\Model.h" />
|
||||
<ClInclude Include="..\..\src\Components\Particle.h" />
|
||||
|
||||
@@ -356,6 +356,9 @@
|
||||
<ClInclude Include="..\..\src\Events\LockMouse.h">
|
||||
<Filter>Input\Events</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\Components\Listener.h">
|
||||
<Filter>Audio\Components</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\src\Shaders\Fragment2.glsl">
|
||||
|
||||
Reference in New Issue
Block a user