Merge remote-tracking branch 'origin/master' into Physics
This commit is contained in:
+13
-1
@@ -18,6 +18,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <Sound/CCollisionSound.h>
|
||||
|
||||
#include "ResourceManager.h"
|
||||
#include "OBJ.h"
|
||||
@@ -36,6 +37,8 @@
|
||||
#include "CTemplate.h"
|
||||
#include "Rendering/CPointLight.h"
|
||||
#include "Transform/TransformSystem.h"
|
||||
#include "Sound/SoundSystem.h"
|
||||
#include "Sound/CCollisionSound.h"
|
||||
#include "Game/LevelSystem.h"
|
||||
#include "Game/PadSystem.h"
|
||||
#include "Game/CBall.h"
|
||||
@@ -65,13 +68,21 @@ public:
|
||||
|
||||
m_InputManager = std::make_shared<InputManager>(m_Renderer->Window(), m_EventBroker);
|
||||
|
||||
m_World = std::make_shared<World>(m_EventBroker);
|
||||
m_World = std::make_shared<World>(m_EventBroker);
|
||||
|
||||
|
||||
|
||||
//TODO: Move this out of engine.h
|
||||
m_World->ComponentFactory.Register<Components::Transform>();
|
||||
m_World->SystemFactory.Register<Systems::TransformSystem>(
|
||||
[this]() { return new Systems::TransformSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::TransformSystem>();
|
||||
m_World->ComponentFactory.Register<Components::Model>();
|
||||
m_World->ComponentFactory.Register<Components::Template>();
|
||||
|
||||
m_World->ComponentFactory.Register<Components::CollisionSound>();
|
||||
m_World->SystemFactory.Register<Systems::SoundSystem>([this]() { return new Systems::SoundSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::SoundSystem>();
|
||||
|
||||
m_World->ComponentFactory.Register<Components::Sprite>();
|
||||
|
||||
@@ -410,6 +421,7 @@ private:
|
||||
std::shared_ptr<InputManager> m_InputManager;
|
||||
std::shared_ptr<World> m_World;
|
||||
|
||||
|
||||
double m_LastTime;
|
||||
};
|
||||
|
||||
|
||||
@@ -248,7 +248,6 @@ protected:
|
||||
EntityID GenerateEntityID();
|
||||
|
||||
void RecycleEntityID(EntityID id);
|
||||
|
||||
};
|
||||
|
||||
template <class T>
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "Physics/CCircleShape.h"
|
||||
#include "Physics/ESetImpulse.h"
|
||||
#include "Physics/EContact.h"
|
||||
#include "Sound/CCollisionSound.h"
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <intrin.h>
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// Created by Adam on 2015-09-17.
|
||||
//
|
||||
|
||||
#ifndef COMPONENTS_CCOLLISIONSOUND_H__
|
||||
#define COMPONENTS_CCOLLISIONSOUND_H__
|
||||
|
||||
#include "Core/Component.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Components
|
||||
{
|
||||
|
||||
struct CollisionSound : public Component
|
||||
{
|
||||
std::string filePath;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
This file is part of Daydream Engine.
|
||||
Copyright 2014 Adam Byléhn, Tobias Dahl, Simon Holmberg, Viktor Ljung
|
||||
|
||||
Daydream Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Daydream Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Daydream Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef Events_PlaySFX_h__
|
||||
#define Events_PlaySFX_h__
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct PlaySFX : Event
|
||||
{
|
||||
std::string path;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // Events_PlaySFX_h__
|
||||
@@ -0,0 +1,36 @@
|
||||
#ifndef SOUND_H__
|
||||
#define SOUND_H__
|
||||
|
||||
#include "AL/al.h"
|
||||
#include "AL/alc.h"
|
||||
|
||||
#include "Core/ResourceManager.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
class Sound : public Resource
|
||||
{
|
||||
friend class ResourceManager;
|
||||
public:
|
||||
ALuint Buffer() { return m_Buffer; };
|
||||
private:
|
||||
Sound(std::string path);
|
||||
|
||||
//File-info
|
||||
char m_Type[4];
|
||||
unsigned long m_Size, m_ChunkSize;
|
||||
short m_FormatType, m_Channels;
|
||||
unsigned long m_SampleRate, m_AvgBytesPerSec;
|
||||
short m_BytesPerSample, m_BitsPerSample;
|
||||
unsigned long m_DataSize;
|
||||
std::map<std::string, ALuint> m_BufferCache;
|
||||
ALuint LoadFile(std::string path);
|
||||
|
||||
ALuint m_Buffer;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,53 @@
|
||||
#ifndef DAYDREAM_SOUND_H
|
||||
#define DAYDREAM_SOUND_H
|
||||
|
||||
|
||||
#include "AL/al.h"
|
||||
#include "AL/alc.h"
|
||||
#include "Core/System.h"
|
||||
#include "Core/World.h"
|
||||
#include "Sound.h"
|
||||
#include "Sound/EPlaySFX.h"
|
||||
#include "Physics/EContact.h"
|
||||
#include "Core/EventBroker.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:
|
||||
//Events
|
||||
dd::EventRelay<SoundSystem, dd::Events::PlaySFX> m_EPlaySFX;
|
||||
dd::EventRelay<SoundSystem, dd::Events::Contact> m_EContact;
|
||||
bool OnPlaySFX(const dd::Events::PlaySFX &event);
|
||||
bool OnContact(const dd::Events::Contact &event);
|
||||
ALuint CreateSource();
|
||||
|
||||
std::map<Component*, ALuint> m_Sources;
|
||||
|
||||
//std::list<ALuint>
|
||||
//Temp
|
||||
ALuint m_Source;
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_SOUND_H
|
||||
Reference in New Issue
Block a user