adding AnimationsSystem.cpp

This commit is contained in:
Clément Le Bihan
2021-06-01 17:26:01 +02:00
parent e298ce03eb
commit b4d783d6c2
9 changed files with 149 additions and 53 deletions
@@ -0,0 +1,43 @@
//
// Created by cbihan on 01/06/2021.
//
#include "AnimationsComponent.hpp"
#include "Entity/Entity.hpp"
#include "Model/ModelAnimations.hpp"
namespace BBM
{
AnimationsComponent::AnimationsComponent(WAL::Entity &entity, RAY::ModelAnimations &modelAnimation)
: WAL::Component(entity),
_modelAnimation(modelAnimation),
_animFrameCounter(0)
{
}
WAL::Component *AnimationsComponent::clone(WAL::Entity &entity) const
{
return new AnimationsComponent(entity, this->_modelAnimation);
}
size_t AnimationsComponent::getAnimFrameCounter() const
{
return this->_animFrameCounter;
}
RAY::ModelAnimation AnimationsComponent::getCurrentModelAnim() const
{
return this->_modelAnimation[static_cast<int>(this->_animFrameCounter)];
}
void AnimationsComponent::setAnimFrameCounter(size_t animFrameCounter)
{
this->_animFrameCounter = animFrameCounter;
this->_animFrameCounter %= this->_modelAnimation.getAnimationsCount();
}
void AnimationsComponent::resetAnimFrameCounter()
{
this->_animFrameCounter = 0;
}
}