r-type  0.0.0
R-Type main
Loading...
Searching...
No Matches
Pixel.hpp
Go to the documentation of this file.
1///
2/// @file Systems.hpp
3/// @brief This file contains the system definitions
4/// @namespace cli
5///
6
7#pragma once
8
9#include "ECS/Component.hpp"
10#include "ECS/Registry.hpp"
12
13namespace cli
14{
15
16 class PixelSystem final : public eng::ASystem
17 {
18 public:
19 explicit PixelSystem(eng::IRenderer &renderer) : m_renderer(renderer) {}
20 ~PixelSystem() override = default;
21
22 explicit PixelSystem(const PixelSystem &) = delete;
23 PixelSystem &operator=(const PixelSystem &) = delete;
24 explicit PixelSystem(PixelSystem &&) = delete;
26
27 void update(ecs::Registry &registry, float /* dt */) override
28 {
29 for (auto &[entity, pixel] : registry.getAll<ecs::Pixel>())
30 {
31 const auto *color = registry.getComponent<ecs::Color>(entity);
32 const auto *transform = registry.getComponent<ecs::Transform>(entity);
33 m_renderer.drawPoint(transform->x, transform->y,
34 {.r = color->r, .g = color->g, .b = color->b, .a = color->a});
35 }
36 }
37
38 private:
40 }; // class PixelSystem
41
42} // namespace cli
This file contains the component definitions.
This file contains the IRenderer class declaration.
This file contains the Registry class declaration.
void update(ecs::Registry &registry, float) override
Definition Pixel.hpp:27
eng::IRenderer & m_renderer
Definition Pixel.hpp:39
PixelSystem(PixelSystem &&)=delete
PixelSystem & operator=(const PixelSystem &)=delete
~PixelSystem() override=default
PixelSystem & operator=(PixelSystem &&)=delete
PixelSystem(const PixelSystem &)=delete
PixelSystem(eng::IRenderer &renderer)
Definition Pixel.hpp:19
Class for managing entities and their components.
Definition Registry.hpp:25
std::unordered_map< Entity, T > & getAll()
Definition Registry.hpp:77
T * getComponent(Entity e)
Definition Registry.hpp:71
Interface for the renderer.
virtual void drawPoint(float x, float y, Color color)=0
unsigned char r
Definition Component.hpp:26