mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-05-28 16:43:29 +00:00
Merging with develop and reworking all systems
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// Created by cbihan on 01/06/2021.
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
#include "AnimationsSystem.hpp"
|
||||
#include "Component/Animation/AnimationsComponent.hpp"
|
||||
#include "Model/Model.hpp"
|
||||
#include "Component/Renderer/Drawable3DComponent.hpp"
|
||||
|
||||
namespace BBM
|
||||
{
|
||||
|
||||
AnimationsSystem::AnimationsSystem(WAL::Wal &wal)
|
||||
: System(wal)
|
||||
{}
|
||||
|
||||
void AnimationsSystem::onUpdate(WAL::Entity &entity, std::chrono::nanoseconds)
|
||||
{
|
||||
auto &model = entity.getComponent<Drawable3DComponent>();
|
||||
auto &anim = entity.getComponent<AnimationsComponent>();
|
||||
|
||||
if (anim.isDisabled())
|
||||
return;
|
||||
auto modelPtr = std::dynamic_pointer_cast<RAY::Drawables::Drawables3D::Model>(model.drawable);
|
||||
if (modelPtr) {
|
||||
modelPtr->setAnimation(anim.getCurrentModelAnim());
|
||||
anim.incCurrentAnimFrameCounter();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// Created by cbihan on 01/06/2021.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <System/System.hpp>
|
||||
#include "Component/Renderer/Drawable3DComponent.hpp"
|
||||
#include "Component/Animation/AnimationsComponent.hpp"
|
||||
|
||||
namespace BBM
|
||||
{
|
||||
class AnimationsSystem : public WAL::System<Drawable3DComponent, AnimationsComponent>
|
||||
{
|
||||
public:
|
||||
//! @inherit
|
||||
void onUpdate(WAL::Entity &entity, std::chrono::nanoseconds) override;
|
||||
|
||||
//! @brief A default constructor
|
||||
explicit AnimationsSystem(WAL::Wal &wal);
|
||||
//! @brief A Controllable system is copy constructable
|
||||
AnimationsSystem(const AnimationsSystem &) = default;
|
||||
//! @brief A default destructor
|
||||
~AnimationsSystem() override = default;
|
||||
//! @brief A system is not assignable.
|
||||
AnimationsSystem &operator=(const AnimationsSystem &) = delete;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user