Added a very basic PlayerSystem, and a PlayerComponent.

This commit is contained in:
stiffly
2015-12-11 13:45:19 +01:00
parent 6326a60a79
commit 80f028edf2
10 changed files with 121 additions and 7 deletions
+4 -3
View File
@@ -10,16 +10,17 @@ class System
friend class SystemPipeline;
public:
System(const EventBroker* eventBroker, std::string componentType)
System(EventBroker* eventBroker, std::string componentType)
: m_EventBroker(eventBroker)
, m_ComponentType(componentType)
{ }
virtual void Initialize();
virtual void Update(World* world, ComponentWrapper& component, double dt) = 0;
private:
const EventBroker* m_EventBroker;
std::string m_ComponentType;
EventBroker* m_EventBroker;
};
#endif
+2 -2
View File
@@ -9,7 +9,7 @@
class SystemPipeline
{
public:
SystemPipeline(const EventBroker* eventBroker)
SystemPipeline(EventBroker* eventBroker)
: m_EventBroker(eventBroker)
{ }
~SystemPipeline()
@@ -51,7 +51,7 @@ public:
}
private:
const EventBroker* m_EventBroker;
EventBroker* m_EventBroker;
std::unordered_map<std::string, std::vector<System*>> m_Systems;
};
+1
View File
@@ -13,6 +13,7 @@
#include "Core/EntityXMLFile.h"
#include "Core/SystemPipeline.h"
#include "RaptorCopterSystem.h"
#include "PlayerSystem.h"
class Game
{
+34
View File
@@ -0,0 +1,34 @@
#ifndef PlayerSystem_h__
#define PlayerSystem_h__
#include <GLFW/glfw3.h>
#include <glm/common.hpp>
#include "Common.h"
#include "Core/System.h"
#include "Core/EventBroker.h"
#include "Core/EKeyDown.h"
#include "Core/EKeyUp.h"
class PlayerSystem : public System
{
public:
PlayerSystem(EventBroker* eventBroker)
: System(eventBroker, "Player")
{ }
void Initialize();
virtual void Update(World* world, ComponentWrapper& player, double dt) override;
private:
float m_Speed;
glm::vec3 m_Direction;
EventBroker* m_EventBroker;
EventRelay<PlayerSystem, Events::KeyDown> m_EKeyDown;
bool OnKeyDown(const Events::KeyDown &event);
EventRelay<PlayerSystem, Events::KeyUp> m_EKeyUp;
bool OnKeyUp(const Events::KeyUp &event);
};
#endif
+1 -1
View File
@@ -4,7 +4,7 @@
class RaptorCopterSystem : public System
{
public:
RaptorCopterSystem(const EventBroker* eventBroker)
RaptorCopterSystem(EventBroker* eventBroker)
: System(eventBroker, "RaptorCopter")
{ }