![]() |
R-Type
2
Doom but in better
|
Represents a rectangular component that can detect collisions and mouse interactions, such as hovering and clicking. More...
#include <Collision.hpp>
Public Member Functions | |
Collision (const std::uint32_t entityId=0, const float width=0, const float height=0, const float positionX=0, const float positionY=0) | |
Constructs a Collision with the specified dimensions and position. | |
~Collision () | |
Default destructor. | |
void | setWidth (const float &width) |
Sets the width of the component and updates collision data. | |
void | setHeight (const float &height) |
Sets the height of the component and updates collision data. | |
void | setPositionX (const float &posX) |
Sets the X-coordinate of the component's position and updates collision data. | |
void | setPositionY (const float &posY) |
Sets the Y-coordinate of the component's position and updates collision data. | |
void | setPosition (const std::pair< float, float > &position) |
Set the position of the object. | |
void | setDimension (const std::pair< float, float > &dimension) |
Set the dimension of the object. | |
void | setGeometry (const Recoded::FloatRect &rect) |
Set the dimensions of the object using the FloatRect recode. | |
void | setMousePosition (const std::pair< int, int > &position) |
Updates the mouse position for collision checks. | |
void | update (const std::pair< int, int > &mousePosition) |
Update the mouse info object used for mouse tracking. | |
void | update (const GUI::ECS::Systems::MouseInfo &mouse) |
Update the mouse info object used for mouse tracking. | |
void | update (const GUI::ECS::Systems::Collision ©) |
Update the info object used in the Collision class. | |
void | updateMouseInfo (const GUI::ECS::Systems::MouseInfo &mouse) |
Updates the mouse info object used for collision checks. | |
const bool | isClicked () const |
Checks if the component is clicked by the mouse. | |
const bool | isHovered () const |
Checks if the component is currently hovered by the mouse. | |
const bool | isColliding (const Collision &itemTwo) const |
Checks if this component is colliding with another Collision. | |
const float | getWidth () const |
Gets the width of the component. | |
const float | getHeight () const |
Gets the height of the component. | |
const float | getPositionX () const |
Gets the X-coordinate of the component's position. | |
const float | getPositionY () const |
Gets the Y-coordinate of the component's position. | |
const Recoded::FloatRect | getGeometry () const |
This is the function in charge of returning the coordinates in the form of an sf::FloatRect. | |
const std::pair< float, float > | getPosition () const |
Get the position of the item in the form of an sf::Vector2i. | |
const std::pair< float, float > | getDimension () const |
Get the dimension of the item in the form of an sf::Vector2i. | |
const GUI::ECS::Systems::MouseInfo | getMouseInfo () const |
This is the function in charge of returning the MouseInfo class instance. | |
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. | |
Collision & | operator= (const GUI::ECS::Systems::Collision ©) |
This is the overload in charge of allowing the user to update their variables using the = sign. | |
![]() | |
EntityNode (const size_t entityId=0) | |
virtual | ~EntityNode ()=default |
virtual size_t | getEntityNodeId () const |
Protected Member Functions | |
void | _updateMouseCollisionData () |
Updates the mouse collision data, setting hover and click states. | |
Protected Attributes | |
bool | _isHovered = false |
bool | _isClicked = false |
Recoded::FloatRect | _rect = { {0,0}, {0,0} } |
GUI::ECS::Systems::MouseInfo | _mouse |
![]() | |
size_t | _entityID |
Represents a rectangular component that can detect collisions and mouse interactions, such as hovering and clicking.
Definition at line 39 of file Collision.hpp.
GUI::ECS::Systems::Collision::Collision | ( | const std::uint32_t | entityId = 0, |
const float | width = 0, | ||
const float | height = 0, | ||
const float | positionX = 0, | ||
const float | positionY = 0 ) |
Constructs a Collision with the specified dimensions and position.
width | Width of the component. |
height | Height of the component. |
positionX | X-coordinate of the component's position. |
positionY | Y-coordinate of the component's position. |
Definition at line 24 of file Collision.cpp.
GUI::ECS::Systems::Collision::~Collision | ( | ) |
Default destructor.
Definition at line 33 of file Collision.cpp.
|
protected |
Updates the mouse collision data, setting hover and click states.
Definition at line 329 of file Collision.cpp.
const std::pair< float, float > GUI::ECS::Systems::Collision::getDimension | ( | ) | const |
Get the dimension of the item in the form of an sf::Vector2i.
Definition at line 255 of file Collision.cpp.
const Recoded::FloatRect GUI::ECS::Systems::Collision::getGeometry | ( | ) | const |
This is the function in charge of returning the coordinates in the form of an sf::FloatRect.
Definition at line 235 of file Collision.cpp.
const float GUI::ECS::Systems::Collision::getHeight | ( | ) | const |
Gets the height of the component.
Definition at line 205 of file Collision.cpp.
const std::string GUI::ECS::Systems::Collision::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 290 of file Collision.cpp.
const GUI::ECS::Systems::MouseInfo GUI::ECS::Systems::Collision::getMouseInfo | ( | ) | const |
This is the function in charge of returning the MouseInfo class instance.
Definition at line 265 of file Collision.cpp.
const std::pair< float, float > GUI::ECS::Systems::Collision::getPosition | ( | ) | const |
Get the position of the item in the form of an sf::Vector2i.
Definition at line 245 of file Collision.cpp.
const float GUI::ECS::Systems::Collision::getPositionX | ( | ) | const |
Gets the X-coordinate of the component's position.
Definition at line 215 of file Collision.cpp.
const float GUI::ECS::Systems::Collision::getPositionY | ( | ) | const |
Gets the Y-coordinate of the component's position.
Definition at line 225 of file Collision.cpp.
const float GUI::ECS::Systems::Collision::getWidth | ( | ) | const |
Gets the width of the component.
Definition at line 195 of file Collision.cpp.
const bool GUI::ECS::Systems::Collision::isClicked | ( | ) | const |
Checks if the component is clicked by the mouse.
true
if the component is clicked; otherwise, false
. Definition at line 175 of file Collision.cpp.
const bool GUI::ECS::Systems::Collision::isColliding | ( | const Collision & | itemTwo | ) | const |
Checks if this component is colliding with another Collision.
itemTwo | The other Collision to check against. |
true
if the components are colliding; otherwise, false
. Definition at line 276 of file Collision.cpp.
const bool GUI::ECS::Systems::Collision::isHovered | ( | ) | const |
Checks if the component is currently hovered by the mouse.
true
if the component is hovered; otherwise, false
. Definition at line 185 of file Collision.cpp.
GUI::ECS::Systems::Collision & GUI::ECS::Systems::Collision::operator= | ( | const GUI::ECS::Systems::Collision & | copy | ) |
This is the overload in charge of allowing the user to update their variables using the = sign.
copy |
Definition at line 318 of file Collision.cpp.
void GUI::ECS::Systems::Collision::setDimension | ( | const std::pair< float, float > & | dimension | ) |
Set the dimension of the object.
dimension | an std::pair<float, float> of the of the object's dimension. |
Definition at line 95 of file Collision.cpp.
void GUI::ECS::Systems::Collision::setGeometry | ( | const Recoded::FloatRect & | rect | ) |
Set the dimensions of the object using the FloatRect recode.
rect | a Recoded::FloatRect rectangle instance of the object's dimension and position. |
Definition at line 106 of file Collision.cpp.
void GUI::ECS::Systems::Collision::setHeight | ( | const float & | height | ) |
Sets the height of the component and updates collision data.
height | New height of the component. |
Definition at line 51 of file Collision.cpp.
void GUI::ECS::Systems::Collision::setMousePosition | ( | const std::pair< int, int > & | mousePosition | ) |
Updates the mouse position for collision checks.
mousePosition | New mouse position as an std::pair<int, int> vector. |
Definition at line 117 of file Collision.cpp.
void GUI::ECS::Systems::Collision::setPosition | ( | const std::pair< float, float > & | position | ) |
Set the position of the object.
position | an std::pair<float, float> of the object's position. |
Definition at line 84 of file Collision.cpp.
void GUI::ECS::Systems::Collision::setPositionX | ( | const float & | posX | ) |
Sets the X-coordinate of the component's position and updates collision data.
posX | New X-coordinate of the component's position. |
Definition at line 62 of file Collision.cpp.
void GUI::ECS::Systems::Collision::setPositionY | ( | const float & | posY | ) |
Sets the Y-coordinate of the component's position and updates collision data.
posY | New Y-coordinate of the component's position. |
Definition at line 73 of file Collision.cpp.
void GUI::ECS::Systems::Collision::setWidth | ( | const float & | width | ) |
Sets the width of the component and updates collision data.
width | New width of the component. |
Definition at line 40 of file Collision.cpp.
void GUI::ECS::Systems::Collision::update | ( | const GUI::ECS::Systems::Collision & | copy | ) |
Update the info object used in the Collision class.
copy |
Definition at line 139 of file Collision.cpp.
void GUI::ECS::Systems::Collision::update | ( | const GUI::ECS::Systems::MouseInfo & | mouse | ) |
Update the mouse info object used for mouse tracking.
copy |
Definition at line 152 of file Collision.cpp.
void GUI::ECS::Systems::Collision::update | ( | const std::pair< int, int > & | mouse | ) |
Update the mouse info object used for mouse tracking.
copy |
Definition at line 129 of file Collision.cpp.
void GUI::ECS::Systems::Collision::updateMouseInfo | ( | const GUI::ECS::Systems::MouseInfo & | mouse | ) |
Updates the mouse info object used for collision checks.
mouse | Mouse information object. |
Definition at line 164 of file Collision.cpp.
|
protected |
Definition at line 96 of file Collision.hpp.
|
protected |
Definition at line 95 of file Collision.hpp.
|
protected |
Definition at line 98 of file Collision.hpp.
|
protected |
Definition at line 97 of file Collision.hpp.