diff --git a/include/Rendering/AnimationSystem.h b/include/Rendering/AnimationSystem.h index f549332..bbf0d23 100644 --- a/include/Rendering/AnimationSystem.h +++ b/include/Rendering/AnimationSystem.h @@ -4,6 +4,7 @@ #include "Core/System.h" #include "Core/World.h" #include "Rendering/CAnimation.h" +#include "Game/EPause.h" namespace dd { @@ -17,7 +18,14 @@ public: : System(world, eventBroker) { } void RegisterComponents(ComponentFactory* cf) override; + void Initialize() override; void Update(double dt) override; + +private: + bool m_Paused = false; + + EventRelay m_EPause; + bool OnPause(const Events::Pause& e); }; } diff --git a/src/game/Rendering/AnimationSystem.cpp b/src/game/Rendering/AnimationSystem.cpp index 8c858da..9887e70 100644 --- a/src/game/Rendering/AnimationSystem.cpp +++ b/src/game/Rendering/AnimationSystem.cpp @@ -6,8 +6,17 @@ void dd::Systems::AnimationSystem::RegisterComponents(ComponentFactory* cf) cf->Register(); } +void dd::Systems::AnimationSystem::Initialize() +{ + EVENT_SUBSCRIBE_MEMBER(m_EPause, &AnimationSystem::OnPause); +} + void dd::Systems::AnimationSystem::Update(double dt) { + if (m_Paused) { + return; + } + auto animations = m_World->GetComponentsOfType(); if (animations == nullptr) { return; @@ -18,3 +27,9 @@ void dd::Systems::AnimationSystem::Update(double dt) animation->Time += animation->Speed * dt; } } + +bool dd::Systems::AnimationSystem::OnPause(const Events::Pause& e) +{ + m_Paused = !m_Paused; + return true; +}