mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-06-05 02:49:57 +00:00
Reworking drawable components
This commit is contained in:
@@ -4,37 +4,37 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Models/TypeHolder.hpp>
|
||||
#include "Component/Component.hpp"
|
||||
#include "Drawables/ADrawable3D.hpp"
|
||||
#include "Model/Model.hpp"
|
||||
|
||||
namespace BBM
|
||||
{
|
||||
template <class T>
|
||||
class Drawable3DComponent : public WAL::Component
|
||||
{
|
||||
public:
|
||||
//! @brief The type of the component
|
||||
T member;
|
||||
std::shared_ptr<RAY::Drawables::ADrawable3D> drawable;
|
||||
|
||||
//! @brief ctor
|
||||
Drawable3DComponent(WAL::Entity &entity, T member)
|
||||
Drawable3DComponent(WAL::Entity &entity, std::shared_ptr<RAY::Drawables::ADrawable3D> drawable)
|
||||
: WAL::Component(entity),
|
||||
member(std::move(member))
|
||||
drawable(std::move(drawable))
|
||||
{}
|
||||
|
||||
//! ctor
|
||||
template<typename ...Params>
|
||||
explicit Drawable3DComponent(WAL::Entity &entity, Params &&...params)
|
||||
template<typename T, typename ...Params>
|
||||
explicit Drawable3DComponent(WAL::Entity &entity, WAL::TypeHolder<T>, Params &&...params)
|
||||
: WAL::Component(entity),
|
||||
member(std::forward<Params>(params)...)
|
||||
drawable(new T(std::forward<Params>(params)...))
|
||||
{}
|
||||
|
||||
//! @brief Clone a component for another or the same entity.
|
||||
//! @param entity The entity that owns the ne component.
|
||||
WAL::Component *clone(WAL::Entity &entity) const override
|
||||
{
|
||||
return new Drawable3DComponent(entity, this->member);
|
||||
return new Drawable3DComponent(entity, this->drawable);
|
||||
}
|
||||
|
||||
//! @brief Default copy ctor
|
||||
|
||||
Reference in New Issue
Block a user