R-Type  2
Doom but in better
Loading...
Searching...
No Matches
TextureComponent.hpp
Go to the documentation of this file.
1/*
2** EPITECH PROJECT, 2024
3** rtype (Workspace)
4** File description:
5** TextureComponent.hpp
6*/
7
17#pragma once
18
19#include <any>
20#include <utility>
21#include <optional>
22#include <SFML/Graphics/Texture.hpp>
23
24#include "Log.hpp"
25#include "LogMacros.hpp"
26#include "Utilities.hpp"
27#include "CustomExceptions.hpp"
31
32namespace GUI
33{
34 namespace ECS
35 {
36 namespace Components
37 {
48 public:
65 TextureComponent(const std::any &texture, const GUI::ECS::Systems::Collision &collisionInfo);
72 TextureComponent(const std::string &filePath, const GUI::ECS::Systems::Collision &collisionInfo);
73
79 explicit TextureComponent(const std::uint32_t entityId);
86 explicit TextureComponent(const std::uint32_t entityId, const TextureComponent &other);
94 explicit TextureComponent(const std::uint32_t entityId, const std::any &texture, const GUI::ECS::Systems::Collision &collisionInfo);
102 explicit TextureComponent(const std::uint32_t entityId, const std::string &filePath, const GUI::ECS::Systems::Collision &collisionInfo);
103
108
114 void setVisible(const bool visible);
123 void setFilePath(const std::string &filePath);
132 void setTexture(const std::any &texture);
138 void setCollisionInfo(const GUI::ECS::Systems::Collision &collisionInfo);
144 void setPosition(const std::pair<int, int> &position);
152 void setSize(const std::pair<float, float> &size);
153
159 void update(const TextureComponent &copy);
160
166 const bool getVisible() const;
174 const std::any getTexture() const;
190 const std::string getInfo(const unsigned int indent = 0) const;
191
200
201 private:
202 bool _visible = true;
203 bool _textureSet = false;
204 std::shared_ptr<sf::Texture> _texture;
205 GUI::ECS::Systems::Collision _collisionInfo;
206 };
207
216 std::ostream &operator<<(std::ostream &os, const TextureComponent &item);
217 }
218 }
219}
220
File in charge of containing the custom errors that are going to be used for custom description error...
This is the file that links the EntityNode children.
Macro definitions for logging messages with varying levels of detail and formatting.
This is the file in charge of containing the Log class (the one in charge of outputing info only when...
This is the header file containing the class for the mouse information.
Represents a texture component used in an entity component system.
const std::string getInfo(const unsigned int indent=0) const
This is a function meant for debugging purposes It will dump the current state of the variables upon ...
TextureComponent & operator=(const GUI::ECS::Components::TextureComponent &copy)
Assignment operator for copying data from another TextureComponent.
~TextureComponent()
Destructor. Cleans up resources when the component is destroyed.
void setTexture(const std::any &texture)
Sets the texture using a std::any object.
void setCollisionInfo(const GUI::ECS::Systems::Collision &collisionInfo)
Sets the collision information for the texture.
void setPosition(const std::pair< int, int > &position)
Sets the position of the texture.
const std::any getTexture() const
Retrieves the texture as a std::any object.
const bool getVisible() const
Retrieves the visibility status of the texture.
TextureComponent()
Default constructor. Initializes the component with default values.
void update(const TextureComponent &copy)
Updates the texture component by copying data from another component.
void setVisible(const bool visible)
Sets the visibility of the texture.
void setFilePath(const std::string &filePath)
Sets the file path for the texture.
void setSize(const std::pair< float, float > &size)
Sets the size of the texture.
const GUI::ECS::Systems::Collision getCollisionInfo() const
Retrieves the collision information for the texture.
Represents a rectangular component that can detect collisions and mouse interactions,...
Definition Collision.hpp:39
std::ostream & operator<<(std::ostream &os, const AnimationComponent &item)
Outputs the animation's info to a stream.