Bomberman
RenderSystem.hpp
Go to the documentation of this file.
1 //
2 // Created by cbihan on 26/05/2021.
3 //
4 
5 #pragma once
6 
11 #include "System/System.hpp"
12 #include "Camera/Camera2D.hpp"
13 #include "Window.hpp"
14 #include "Wal.hpp"
15 #include "Models/Vector2.hpp"
16 
17 namespace BBM
18 {
19  class RenderSystem : public WAL::System<CameraComponent, PositionComponent>
20  {
21 
24 
27 
29  bool _debugMode;
30 
32  static constexpr short FPS = 60;
33 
37  void drawRescaledDrawable(RAY::Drawables::ADrawable2D &drawable, const Vector2f &newDims);
38 
42  Vector2f getRescaledPosition(Vector3f &position, const Vector2f &newWinDims);
43 
44  void resizeWindow(Vector2f &newDims);
45 
46  public:
49  void onSelfUpdate(std::chrono::nanoseconds dtime) override;
50 
52  void onUpdate(WAL::ViewEntity<CameraComponent, PositionComponent> &entity, std::chrono::nanoseconds dtime) override;
53 
55  void setDebug(bool debug);
56 
58  void drawBoundingBox(const WAL::Entity &entity, const PositionComponent &posComponent, const Drawable3DComponent &drawable) const;
59 
61  RenderSystem(WAL::Wal &wal, RAY::Window &window, bool debugMode = false);
63  RenderSystem(const RenderSystem &) = default;
65  ~RenderSystem() override = default;
67  RenderSystem &operator=(const RenderSystem &) = delete;
68  };
69 }
BBM::RenderSystem::_camera
RAY::Camera::Camera3D _camera
The camera used to render.
Definition: RenderSystem.hpp:26
BBM::RenderSystem::setDebug
void setDebug(bool debug)
Definition: RenderSystem.cpp:175
BBM::Vector2< float >
WAL::ViewEntity
Definition: View.hpp:19
System.hpp
RAY::Window
Definition: Window.hpp:32
BBM::RenderSystem::_debugMode
bool _debugMode
Defines if the debug informations must be displayed or not.
Definition: RenderSystem.hpp:29
BBM::RenderSystem::operator=
RenderSystem & operator=(const RenderSystem &)=delete
A render screen system can't be assigned.
Vector2.hpp
BBM
Definition: AnimationsComponent.cpp:9
PositionComponent.hpp
WAL::Wal
The main WAL class, it is used to setup and run the ECS.
Definition: Wal.hpp:27
WAL::Entity
An entity of the WAL's ECS.
Definition: Entity.hpp:20
Window.hpp
MovableComponent.hpp
BBM::Vector3< float >
BBM::Drawable3DComponent
Definition: Drawable3DComponent.hpp:14
BBM::RenderSystem::RenderSystem
RenderSystem(WAL::Wal &wal, RAY::Window &window, bool debugMode=false)
ctor
Definition: RenderSystem.cpp:26
BBM::PositionComponent
A basic position component.
Definition: PositionComponent.hpp:13
CameraComponent.hpp
BBM::RenderSystem::getRescaledPosition
Vector2f getRescaledPosition(Vector3f &position, const Vector2f &newWinDims)
rescale the drawables position according to new window dimensions
Definition: RenderSystem.cpp:49
BBM::RenderSystem::onSelfUpdate
void onSelfUpdate(std::chrono::nanoseconds dtime) override
A method called after all entities that this system manage has been updated.
Definition: RenderSystem.cpp:105
BBM::RenderSystem::~RenderSystem
~RenderSystem() override=default
Default dtor.
BBM::RenderSystem::resizeWindow
void resizeWindow(Vector2f &newDims)
Definition: RenderSystem.cpp:95
BBM::RenderSystem
Definition: RenderSystem.hpp:19
WAL::System
A base system of WAL.
Definition: System.hpp:22
BBM::RenderSystem::drawRescaledDrawable
void drawRescaledDrawable(RAY::Drawables::ADrawable2D &drawable, const Vector2f &newDims)
rescale the drawables dimensions according to new window dimensions
Definition: RenderSystem.cpp:57
Wal.hpp
Camera2D.hpp
BBM::RenderSystem::FPS
static constexpr short FPS
Window framerate limit.
Definition: RenderSystem.hpp:32
BBM::RenderSystem::_window
RAY::Window & _window
The window to render on.
Definition: RenderSystem.hpp:23
RAY::Camera::Camera3D
Entity representing a Camera in 3D space.
Definition: Camera3D.hpp:20
RAY::Drawables::ADrawable2D
Abstraction of any two-dimensionnal drawable.
Definition: ADrawable2D.hpp:21
Drawable3DComponent.hpp
BBM::RenderSystem::onUpdate
void onUpdate(WAL::ViewEntity< CameraComponent, PositionComponent > &entity, std::chrono::nanoseconds dtime) override
Definition: RenderSystem.cpp:165
BBM::RenderSystem::drawBoundingBox
void drawBoundingBox(const WAL::Entity &entity, const PositionComponent &posComponent, const Drawable3DComponent &drawable) const
Definition: RenderSystem.cpp:35