trying inheriting from class T

This commit is contained in:
Clément Le Bihan
2021-05-25 12:39:25 +02:00
parent e8aec2b7ef
commit 95b1b2ebb7
4 changed files with 7 additions and 5 deletions
@@ -10,10 +10,9 @@
namespace BBM
{
template <class T>
class Drawable2DComponent : public WAL::Component
class Drawable2DComponent : public WAL::Component, public T
{
public:
T member;
explicit Drawable2DComponent(WAL::Entity &entity)
: WAL::Component(entity)
@@ -24,5 +23,7 @@ namespace BBM
{
return new Drawable2DComponent(entity);
}
};
}
+2 -2
View File
@@ -32,10 +32,10 @@ namespace BBM
auto &pos = entity.getComponent<PositionComponent>();
comp.setPosition({pos.getX(), pos.getY()});
comp.member.drawOn(this->_window);
comp.drawOn(this->_window);
}
Renderer2DSystem(const Renderer3DSystem &) = default;
Renderer2DSystem(const Renderer2DSystem &) = default;
~Renderer2DSystem() override = default;
Renderer2DSystem &operator=(const Renderer2DSystem &) = delete;
};
+1 -1
View File
@@ -31,7 +31,7 @@ namespace BBM
auto &comp = entity.getComponent<Drawable3DComponent<T>>();
auto &pos = entity.getComponent<PositionComponent>();
comp.setPosition(pos);
comp.member.setPosition(pos);
comp.member.drawOn(this->_window);
}
+1
View File
@@ -12,6 +12,7 @@
#include "Drawables/2D/Text.hpp"
#include "Drawables/3D/Grid.hpp"
#include "Drawables/Texture.hpp"
#include "Drawables/2D/Circle.hpp"
#include "Model/Model.hpp"
#include "Model/ModelAnimations.hpp"
#include "System/Renderer/Renderer2DSystem.hpp"