SystemFactory for dynamic creation and fetching of systems in a world.

This commit is contained in:
2014-03-09 03:37:39 +01:00
parent f767cdbc9c
commit c952953787
15 changed files with 218 additions and 100 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
#include "CollisionSystem.h"
#include "World.h"
void Systems::Collision::Update(double dt, EntityID entity, EntityID parent)
void Systems::CollisionSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
{
if (parent != 0)
{
+4 -3
View File
@@ -9,12 +9,13 @@
namespace Systems
{
class Collision : public System
class CollisionSystem : public System
{
public:
Collision(World* world) : System(world) { }
CollisionSystem(World* world)
: System(world) { }
void Update(double dt, EntityID entity, EntityID parent) override;
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
};
}
+2 -2
View File
@@ -13,7 +13,7 @@ void Systems::InputSystem::Update(double dt)
// Mouse buttons
for (int i = 0; i <= GLFW_MOUSE_BUTTON_LAST; ++i) {
m_CurrentKeyState[i] = glfwGetMouseButton(m_Renderer->GetWindow(), i);
m_CurrentMouseState[i] = glfwGetMouseButton(m_Renderer->GetWindow(), i);
}
// Cursor position
@@ -25,7 +25,7 @@ void Systems::InputSystem::Update(double dt)
m_LastMouseY = ypos;
}
void Systems::InputSystem::Update(double dt, EntityID entity, EntityID parent)
void Systems::InputSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
{
auto input = m_World->GetComponent<Components::Input>(entity, "Input");
if (input == nullptr)
+7 -7
View File
@@ -13,19 +13,19 @@ namespace Systems
class InputSystem : public System
{
public:
InputSystem(World* world, Renderer* renderer)
InputSystem(World* world, std::shared_ptr<Renderer> renderer)
: System(world), m_Renderer(renderer) { }
void Update(double dt) override;
void Update(double dt, EntityID entity, EntityID parent) override;
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
private:
Renderer* m_Renderer;
std::shared_ptr<Renderer> m_Renderer;
std::array<int, GLFW_KEY_LAST> m_CurrentKeyState;
std::array<int, GLFW_KEY_LAST> m_LastKeyState;
std::array<int, GLFW_MOUSE_BUTTON_LAST> m_CurrentMouseState;
std::array<int, GLFW_MOUSE_BUTTON_LAST> m_LastMouseState;
std::array<int, GLFW_KEY_LAST+1> m_CurrentKeyState;
std::array<int, GLFW_KEY_LAST+1> m_LastKeyState;
std::array<int, GLFW_MOUSE_BUTTON_LAST+1> m_CurrentMouseState;
std::array<int, GLFW_MOUSE_BUTTON_LAST+1> m_LastMouseState;
float m_CurrentMouseDeltaX, m_CurrentMouseDeltaY;
float m_LastMouseX, m_LastMouseY;
};