Animation system now listens to pause events
This commit is contained in:
@@ -6,8 +6,17 @@ void dd::Systems::AnimationSystem::RegisterComponents(ComponentFactory* cf)
|
||||
cf->Register<Components::Animation>();
|
||||
}
|
||||
|
||||
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<Components::Animation>();
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user