Bomberman
Drawable2DComponent.hpp
Go to the documentation of this file.
1 //
2 // Created by cbihan on 24/05/2021.
3 //
4 
5 #pragma once
6 
7 #include <Models/TypeHolder.hpp>
10 #include "Model/Model.hpp"
11 
12 namespace BBM
13 {
15  {
16  public:
18  bool drawBefore3D = false;
19 
21  std::shared_ptr<RAY::Drawables::ADrawable2D> drawable;
22 
24  Drawable2DComponent(WAL::Entity &entity, std::shared_ptr<RAY::Drawables::ADrawable2D> drawable2D, bool drawBehind3D = false)
25  : WAL::Component(entity),
26  drawBefore3D(drawBehind3D),
27  drawable(std::move(drawable2D))
28  {}
29 
31  template<typename T, typename ...Params>
32  explicit Drawable2DComponent(WAL::Entity &entity, WAL::TypeHolder<T>, Params &&...params)
33  : WAL::Component(entity),
34  drawBefore3D(false),
35  drawable(new T(std::forward<Params>(params)...))
36  {}
37 
39  template<typename T, typename ...Params>
40  explicit Drawable2DComponent(WAL::Entity &entity, WAL::TypeHolder<T>, bool drawBehind3D, Params &&...params)
41  : WAL::Component(entity),
42  drawBefore3D(drawBehind3D),
43  drawable(new T(std::forward<Params>(params)...))
44  {}
45 
48  WAL::Component *clone(WAL::Entity &entity) const override
49  {
50  return new Drawable2DComponent(entity, this->drawable, this->drawBefore3D);
51  }
52 
54  Drawable2DComponent(const Drawable2DComponent &) = default;
56  ~Drawable2DComponent() override = default;
59  };
60 }
BBM::Drawable2DComponent::Drawable2DComponent
Drawable2DComponent(WAL::Entity &entity, WAL::TypeHolder< T >, Params &&...params)
ctor
Definition: Drawable2DComponent.hpp:32
BBM::Drawable2DComponent
Definition: Drawable2DComponent.hpp:14
BBM::Drawable2DComponent::drawBefore3D
bool drawBefore3D
Tells the renderer to draw in a particular order.
Definition: Drawable2DComponent.hpp:18
WAL
Definition: Component.cpp:7
BBM::Drawable2DComponent::drawable
std::shared_ptr< RAY::Drawables::ADrawable2D > drawable
The type of the component.
Definition: Drawable2DComponent.hpp:21
WAL::Component
Represent a single component of WAL.
Definition: Component.hpp:17
BBM
Definition: AnimationsComponent.cpp:9
WAL::Entity
An entity of the WAL's ECS.
Definition: Entity.hpp:20
Component.hpp
WAL::Component::Component
Component(Entity &entity)
A component can't be instantiated, it should be derived.
Definition: Component.cpp:9
WAL::TypeHolder
A class only used to specify template arguments.
Definition: TypeHolder.hpp:12
Model.hpp
BBM::Drawable2DComponent::~Drawable2DComponent
~Drawable2DComponent() override=default
Default dtor.
BBM::Drawable2DComponent::Drawable2DComponent
Drawable2DComponent(WAL::Entity &entity, std::shared_ptr< RAY::Drawables::ADrawable2D > drawable2D, bool drawBehind3D=false)
ctor
Definition: Drawable2DComponent.hpp:24
BBM::Drawable2DComponent::operator=
Drawable2DComponent & operator=(const Drawable2DComponent &)=delete
Default assignment operator.
std
Definition: View.hpp:210
BBM::Drawable2DComponent::clone
WAL::Component * clone(WAL::Entity &entity) const override
Clone a component for another or the same entity.
Definition: Drawable2DComponent.hpp:48
TypeHolder.hpp
BBM::Drawable2DComponent::Drawable2DComponent
Drawable2DComponent(WAL::Entity &entity, WAL::TypeHolder< T >, bool drawBehind3D, Params &&...params)
ctor
Definition: Drawable2DComponent.hpp:40
ADrawable2D.hpp