diff --git a/include/Engine/Core/System.h b/include/Engine/Core/System.h index a79e025f..c4a33d94 100644 --- a/include/Engine/Core/System.h +++ b/include/Engine/Core/System.h @@ -15,10 +15,10 @@ public: , m_ComponentType(componentType) { } - virtual void Initialize(); + virtual void Initialize() { } virtual void Update(World* world, ComponentWrapper& component, double dt) = 0; -private: +protected: std::string m_ComponentType; EventBroker* m_EventBroker; }; diff --git a/include/Engine/Core/SystemPipeline.h b/include/Engine/Core/SystemPipeline.h index e4b8bb1f..a3dc4f36 100644 --- a/include/Engine/Core/SystemPipeline.h +++ b/include/Engine/Core/SystemPipeline.h @@ -21,6 +21,16 @@ public: } } + void Initialize() + { + for (auto& pair : m_Systems) { + auto& systems = pair.second; + for (auto& system : systems) { + system->Initialize(); + } + } + } + template void AddSystem(Arguments... args) { diff --git a/include/Game/PlayerSystem.h b/include/Game/PlayerSystem.h index c6a9f04b..92e8a7cc 100644 --- a/include/Game/PlayerSystem.h +++ b/include/Game/PlayerSystem.h @@ -17,13 +17,12 @@ public: : System(eventBroker, "Player") { } - void Initialize(); + virtual void Initialize(); virtual void Update(World* world, ComponentWrapper& player, double dt) override; private: float m_Speed; glm::vec3 m_Direction; - EventBroker* m_EventBroker; EventRelay m_EKeyDown; bool OnKeyDown(const Events::KeyDown &event); diff --git a/include/Game/RaptorCopterSystem.h b/include/Game/RaptorCopterSystem.h index a25ca3df..cdd6dd90 100644 --- a/include/Game/RaptorCopterSystem.h +++ b/include/Game/RaptorCopterSystem.h @@ -8,6 +8,8 @@ public: : System(eventBroker, "RaptorCopter") { } + virtual void Initialize() { } + virtual void Update(World* world, ComponentWrapper& raptorCopter, double dt) override { ComponentWrapper& transform = world->GetComponent(raptorCopter.EntityID, "Transform"); diff --git a/src/Game/Game.cpp b/src/Game/Game.cpp index 0fc913de..21f93e41 100644 --- a/src/Game/Game.cpp +++ b/src/Game/Game.cpp @@ -47,9 +47,13 @@ Game::Game(int argc, char* argv[]) m_SystemPipeline->AddSystem(); m_SystemPipeline->AddSystem(); + + m_LastTime = glfwGetTime(); testIntialize(); + + m_SystemPipeline->Initialize(); } Game::~Game() diff --git a/src/Game/PlayerSystem.cpp b/src/Game/PlayerSystem.cpp index b8dadaee..024204b5 100644 --- a/src/Game/PlayerSystem.cpp +++ b/src/Game/PlayerSystem.cpp @@ -16,7 +16,7 @@ void PlayerSystem::Update(World * world, ComponentWrapper & player, double dt) bool PlayerSystem::OnKeyDown(const Events::KeyDown & event) { - if (event.KeyCode == GLFW_KEY_P) { + if (event.KeyCode == GLFW_KEY_UP) { m_Direction.z == -1; } if (event.KeyCode == GLFW_KEY_LEFT) {