R-Type  2
Doom but in better
Loading...
Searching...
No Matches
GUI::ECS::Components::TextureComponent Class Reference

Represents a texture component used in an entity component system. More...

#include <TextureComponent.hpp>

Inheritance diagram for GUI::ECS::Components::TextureComponent:
Inheritance graph
Collaboration diagram for GUI::ECS::Components::TextureComponent:
Collaboration graph

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 &copy)
 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.
 
TextureComponentoperator= (const GUI::ECS::Components::TextureComponent &copy)
 Assignment operator for copying data from another TextureComponent.
 
- Public Member Functions inherited from GUI::ECS::EntityNode
 EntityNode (const size_t entityId=0)
 
virtual ~EntityNode ()=default
 
virtual size_t getEntityNodeId () const
 

Additional Inherited Members

- Protected Attributes inherited from GUI::ECS::EntityNode
size_t _entityID
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ TextureComponent() [1/8]

GUI::ECS::Components::TextureComponent::TextureComponent ( )

Default constructor. Initializes the component with default values.

Definition at line 16 of file TextureComponent.cpp.

◆ TextureComponent() [2/8]

GUI::ECS::Components::TextureComponent::TextureComponent ( const TextureComponent & other)

Copy constructor. Creates a new TextureComponent based on another one.

Parameters
otherThe TextureComponent to copy.

Definition at line 21 of file TextureComponent.cpp.

◆ TextureComponent() [3/8]

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.

Parameters
textureThe texture to set.
collisionInfoThe collision information to associate with the texture.

Definition at line 34 of file TextureComponent.cpp.

◆ TextureComponent() [4/8]

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.

Parameters
filePathThe file path to load the texture from.
collisionInfoThe collision information to associate with the texture.

Definition at line 27 of file TextureComponent.cpp.

◆ TextureComponent() [5/8]

GUI::ECS::Components::TextureComponent::TextureComponent ( const std::uint32_t entityId)
explicit

Constructor that initializes the component with an entity ID.

Parameters
entityIdThe entity ID to associate with the component.

Definition at line 41 of file TextureComponent.cpp.

◆ TextureComponent() [6/8]

GUI::ECS::Components::TextureComponent::TextureComponent ( const std::uint32_t entityId,
const TextureComponent & other )
explicit

Copy constructor that initializes the component with an entity ID and another TextureComponent.

Parameters
entityIdThe entity ID to associate with the component.
otherThe TextureComponent to copy.

Definition at line 46 of file TextureComponent.cpp.

◆ TextureComponent() [7/8]

GUI::ECS::Components::TextureComponent::TextureComponent ( const std::uint32_t entityId,
const std::any & texture,
const GUI::ECS::Systems::Collision & collisionInfo )
explicit

Constructor that initializes the component with an entity ID, texture, and collision info.

Parameters
entityIdThe entity ID to associate with the component.
textureThe texture to set.
collisionInfoThe collision information to associate with the texture.

Definition at line 59 of file TextureComponent.cpp.

◆ TextureComponent() [8/8]

GUI::ECS::Components::TextureComponent::TextureComponent ( const std::uint32_t entityId,
const std::string & filePath,
const GUI::ECS::Systems::Collision & collisionInfo )
explicit

Constructor that initializes the component with an entity ID, file path, and collision info.

Parameters
entityIdThe entity ID to associate with the component.
filePathThe file path to load the texture from.
collisionInfoThe collision information to associate with the texture.

Definition at line 52 of file TextureComponent.cpp.

◆ ~TextureComponent()

GUI::ECS::Components::TextureComponent::~TextureComponent ( )

Destructor. Cleans up resources when the component is destroyed.

Definition at line 66 of file TextureComponent.cpp.

Member Function Documentation

◆ getCollisionInfo()

const GUI::ECS::Systems::Collision GUI::ECS::Components::TextureComponent::getCollisionInfo ( ) const

Retrieves the collision information for the texture.

Returns
The collision information associated with the texture.

Definition at line 193 of file TextureComponent.cpp.

◆ getInfo()

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.

Parameters
indentThe level to which the class should be indented in the dump.
Returns
const std::string The formatted output.

Definition at line 198 of file TextureComponent.cpp.

◆ getTexture()

const std::any GUI::ECS::Components::TextureComponent::getTexture ( ) const

Retrieves the texture as a std::any object.

Returns
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.

◆ getVisible()

const bool GUI::ECS::Components::TextureComponent::getVisible ( ) const

Retrieves the visibility status of the texture.

Returns
True if the texture is visible, false otherwise.

Definition at line 188 of file TextureComponent.cpp.

◆ operator=()

GUI::ECS::Components::TextureComponent & GUI::ECS::Components::TextureComponent::operator= ( const GUI::ECS::Components::TextureComponent & copy)

Assignment operator for copying data from another TextureComponent.

Parameters
copyThe TextureComponent to copy data from.
Returns
A reference to this TextureComponent.

Definition at line 211 of file TextureComponent.cpp.

◆ setCollisionInfo()

void GUI::ECS::Components::TextureComponent::setCollisionInfo ( const GUI::ECS::Systems::Collision & collisionInfo)

Sets the collision information for the texture.

Parameters
collisionInfoThe collision information to associate with the texture.

Definition at line 127 of file TextureComponent.cpp.

◆ setFilePath()

void GUI::ECS::Components::TextureComponent::setFilePath ( const std::string & filePath)

Sets the file path for the texture.

Parameters
filePathThe 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.

◆ setPosition()

void GUI::ECS::Components::TextureComponent::setPosition ( const std::pair< int, int > & position)

Sets the position of the texture.

Parameters
positionThe position to set as a pair of integers.

Definition at line 132 of file TextureComponent.cpp.

◆ setSize()

void GUI::ECS::Components::TextureComponent::setSize ( const std::pair< float, float > & size)

Sets the size of the texture.

Parameters
sizeThe 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.

◆ setTexture()

void GUI::ECS::Components::TextureComponent::setTexture ( const std::any & texture)

Sets the texture using a std::any object.

Parameters
textureThe 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.

◆ setVisible()

void GUI::ECS::Components::TextureComponent::setVisible ( const bool visible)

Sets the visibility of the texture.

Parameters
visibleWhether the texture should be visible or not.

Definition at line 68 of file TextureComponent.cpp.

◆ update()

void GUI::ECS::Components::TextureComponent::update ( const TextureComponent & copy)

Updates the texture component by copying data from another component.

Parameters
copyThe TextureComponent to copy data from.

Definition at line 163 of file TextureComponent.cpp.


The documentation for this class was generated from the following files: