![]() |
R-Type
2
Doom but in better
|
Represents a texture component used in an entity component system. More...
#include <TextureComponent.hpp>
Public Member Functions | |
TextureComponent () | |
Default constructor. Initializes the component with default values. | |
TextureComponent (const TextureComponent &other) | |
Copy constructor. Creates a new TextureComponent based on another one. | |
TextureComponent (const std::any &texture, const GUI::ECS::Systems::Collision &collisionInfo) | |
Constructor that initializes the component with a texture and collision info. | |
TextureComponent (const std::string &filePath, const GUI::ECS::Systems::Collision &collisionInfo) | |
Constructor that initializes the component with a file path and collision info. | |
TextureComponent (const std::uint32_t entityId) | |
Constructor that initializes the component with an entity ID. | |
TextureComponent (const std::uint32_t entityId, const TextureComponent &other) | |
Copy constructor that initializes the component with an entity ID and another TextureComponent. | |
TextureComponent (const std::uint32_t entityId, const std::any &texture, const GUI::ECS::Systems::Collision &collisionInfo) | |
Constructor that initializes the component with an entity ID, texture, and collision info. | |
TextureComponent (const std::uint32_t entityId, const std::string &filePath, const GUI::ECS::Systems::Collision &collisionInfo) | |
Constructor that initializes the component with an entity ID, file path, and collision info. | |
~TextureComponent () | |
Destructor. Cleans up resources when the component is destroyed. | |
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 | 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. | |
void | setSize (const std::pair< float, float > &size) |
Sets the size of the texture. | |
void | update (const TextureComponent ©) |
Updates the texture component by copying data from another component. | |
const bool | getVisible () const |
Retrieves the visibility status of the texture. | |
const std::any | getTexture () const |
Retrieves the texture as a std::any object. | |
const GUI::ECS::Systems::Collision | getCollisionInfo () const |
Retrieves the collision information for the texture. | |
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 call. It will dump them for itself and any of it's underlying classes. | |
TextureComponent & | operator= (const GUI::ECS::Components::TextureComponent ©) |
Assignment operator for copying data from another TextureComponent. | |
![]() | |
EntityNode (const size_t entityId=0) | |
virtual | ~EntityNode ()=default |
virtual size_t | getEntityNodeId () const |
Additional Inherited Members | |
![]() | |
size_t | _entityID |
Represents a texture component used in an entity component system.
The TextureComponent manages the texture for a specific entity in the system. It allows setting, updating, and retrieving the texture, its visibility, and collision information associated with the texture. It also allows setting the texture's size and position.
Definition at line 47 of file TextureComponent.hpp.
GUI::ECS::Components::TextureComponent::TextureComponent | ( | ) |
Default constructor. Initializes the component with default values.
Definition at line 16 of file TextureComponent.cpp.
GUI::ECS::Components::TextureComponent::TextureComponent | ( | const TextureComponent & | other | ) |
Copy constructor. Creates a new TextureComponent based on another one.
other | The TextureComponent to copy. |
Definition at line 21 of file TextureComponent.cpp.
GUI::ECS::Components::TextureComponent::TextureComponent | ( | const std::any & | texture, |
const GUI::ECS::Systems::Collision & | collisionInfo ) |
Constructor that initializes the component with a texture and collision info.
texture | The texture to set. |
collisionInfo | The collision information to associate with the texture. |
Definition at line 34 of file TextureComponent.cpp.
GUI::ECS::Components::TextureComponent::TextureComponent | ( | const std::string & | filePath, |
const GUI::ECS::Systems::Collision & | collisionInfo ) |
Constructor that initializes the component with a file path and collision info.
filePath | The file path to load the texture from. |
collisionInfo | The collision information to associate with the texture. |
Definition at line 27 of file TextureComponent.cpp.
|
explicit |
Constructor that initializes the component with an entity ID.
entityId | The entity ID to associate with the component. |
Definition at line 41 of file TextureComponent.cpp.
|
explicit |
Copy constructor that initializes the component with an entity ID and another TextureComponent.
entityId | The entity ID to associate with the component. |
other | The TextureComponent to copy. |
Definition at line 46 of file TextureComponent.cpp.
|
explicit |
Constructor that initializes the component with an entity ID, texture, and collision info.
entityId | The entity ID to associate with the component. |
texture | The texture to set. |
collisionInfo | The collision information to associate with the texture. |
Definition at line 59 of file TextureComponent.cpp.
|
explicit |
Constructor that initializes the component with an entity ID, file path, and collision info.
entityId | The entity ID to associate with the component. |
filePath | The file path to load the texture from. |
collisionInfo | The collision information to associate with the texture. |
Definition at line 52 of file TextureComponent.cpp.
GUI::ECS::Components::TextureComponent::~TextureComponent | ( | ) |
Destructor. Cleans up resources when the component is destroyed.
Definition at line 66 of file TextureComponent.cpp.
const GUI::ECS::Systems::Collision GUI::ECS::Components::TextureComponent::getCollisionInfo | ( | ) | const |
Retrieves the collision information for the texture.
Definition at line 193 of file TextureComponent.cpp.
const std::string GUI::ECS::Components::TextureComponent::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 call. It will dump them for itself and any of it's underlying classes.
indent | The level to which the class should be indented in the dump. |
Definition at line 198 of file TextureComponent.cpp.
const std::any GUI::ECS::Components::TextureComponent::getTexture | ( | ) | const |
Retrieves the texture as a std::any object.
Throws an exception if the texture has not been set.
Definition at line 178 of file TextureComponent.cpp.
const bool GUI::ECS::Components::TextureComponent::getVisible | ( | ) | const |
Retrieves the visibility status of the texture.
Definition at line 188 of file TextureComponent.cpp.
GUI::ECS::Components::TextureComponent & GUI::ECS::Components::TextureComponent::operator= | ( | const GUI::ECS::Components::TextureComponent & | copy | ) |
Assignment operator for copying data from another TextureComponent.
copy | The TextureComponent to copy data from. |
Definition at line 211 of file TextureComponent.cpp.
void GUI::ECS::Components::TextureComponent::setCollisionInfo | ( | const GUI::ECS::Systems::Collision & | collisionInfo | ) |
Sets the collision information for the texture.
collisionInfo | The collision information to associate with the texture. |
Definition at line 127 of file TextureComponent.cpp.
void GUI::ECS::Components::TextureComponent::setFilePath | ( | const std::string & | filePath | ) |
Sets the file path for the texture.
filePath | The file path to load the texture from. |
This function will load the texture from the specified file path and update the collision information based on the texture size.
Definition at line 73 of file TextureComponent.cpp.
void GUI::ECS::Components::TextureComponent::setPosition | ( | const std::pair< int, int > & | position | ) |
Sets the position of the texture.
position | The position to set as a pair of integers. |
Definition at line 132 of file TextureComponent.cpp.
void GUI::ECS::Components::TextureComponent::setSize | ( | const std::pair< float, float > & | size | ) |
Sets the size of the texture.
size | The new size to set as a pair of floats. |
This function scales the texture according to the provided size while maintaining the aspect ratio.
Definition at line 137 of file TextureComponent.cpp.
void GUI::ECS::Components::TextureComponent::setTexture | ( | const std::any & | texture | ) |
Sets the texture using a std::any object.
texture | The texture to set, which can be of type std::shared_ptr<sf::Texture> or sf::Texture. |
This function checks the type of the provided texture and sets it accordingly, also updating the collision information based on the texture's dimensions.
Definition at line 88 of file TextureComponent.cpp.
void GUI::ECS::Components::TextureComponent::setVisible | ( | const bool | visible | ) |
Sets the visibility of the texture.
visible | Whether the texture should be visible or not. |
Definition at line 68 of file TextureComponent.cpp.
void GUI::ECS::Components::TextureComponent::update | ( | const TextureComponent & | copy | ) |
Updates the texture component by copying data from another component.
copy | The TextureComponent to copy data from. |
Definition at line 163 of file TextureComponent.cpp.