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

Forward declaration of the Bullet class. More...

#include <PlayerBrain.hpp>

Inheritance diagram for GUI::ECS::Online::PlayerBrain:
Inheritance graph
Collaboration diagram for GUI::ECS::Online::PlayerBrain:
Collaboration graph

Public Member Functions

 PlayerBrain (const std::uint32_t entityId=0)
 Default constructor.
 
 PlayerBrain (const GUI::ECS::Online::PlayerBrain &copy)
 Copy constructor.
 
 PlayerBrain (const std::uint32_t entityId, const GUI::ECS::Online::PlayerBrain &copy)
 Construct a new PlayerBrain object with an entity ID and a copy of another instance.
 
 ~PlayerBrain ()=default
 Destructor.
 
void setSprite (const std::shared_ptr< GUI::ECS::Components::SpriteComponent > &sprite, const std::shared_ptr< GUI::ECS::Components::SpriteComponent > &bullet)
 Sets the sprite and bullet sprite components for the player.
 
void setPosition (const std::pair< float, float > &pos)
 Sets the player's position.
 
void setDimension (const std::pair< float, float > &size)
 Sets the player's dimensions.
 
void setHealth (const long int health)
 Sets the player's health.
 
void setVisible (const bool visible)
 Sets the player's visibility state.
 
void setBulletSize (const std::pair< float, float > &size)
 Sets the bullet dimensions.
 
const bool isColliding (const GUI::ECS::Systems::Collision &second) const
 Checks if the player is colliding with another entity.
 
const bool isVisible () const
 Checks if the player is currently visible.
 
void tick ()
 Updates the player's state for the current frame.
 
const GUI::ECS::Online::Bullet shoot (const std::uint32_t id) const
 Simulates the player shooting a bullet.
 
const GUI::ECS::Components::SpriteComponent render ()
 Renders the player's sprite to the screen.
 
void update (const GUI::ECS::Online::PlayerBrain &copy)
 Updates the player's state by copying another PlayerBrain.
 
PlayerBrainoperator= (const GUI::ECS::Online::PlayerBrain &copy)
 Overloads the assignment operator to copy from another PlayerBrain.
 
const bool getVisible () const
 Gets the player's visibility state.
 
const long int getHealth () const
 Gets the player's health value.
 
const GUI::ECS::Online::Bullet getBullet () const
 Gets the player's bullet instance.
 
const GUI::ECS::Components::SpriteComponent getSprite () const
 Gets the player's sprite component.
 
const GUI::ECS::Systems::Collision getCollision () const
 Gets the player's collision component.
 
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.
 
- 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

Forward declaration of the Bullet class.

The PlayerBrain class manages the player's logic, interactions, and rendering.

This class is responsible for handling player-related behaviors, including shooting, collision detection, visibility, and rendering.

Definition at line 40 of file PlayerBrain.hpp.

Constructor & Destructor Documentation

◆ PlayerBrain() [1/3]

GUI::ECS::Online::PlayerBrain::PlayerBrain ( const std::uint32_t entityId = 0)

Default constructor.

Parameters
entityIdThe unique ID of the entity. Default is 0.

Definition at line 16 of file PlayerBrain.cpp.

◆ PlayerBrain() [2/3]

GUI::ECS::Online::PlayerBrain::PlayerBrain ( const GUI::ECS::Online::PlayerBrain & copy)

Copy constructor.

Parameters
copyThe PlayerBrain instance to copy from.

Definition at line 22 of file PlayerBrain.cpp.

◆ PlayerBrain() [3/3]

GUI::ECS::Online::PlayerBrain::PlayerBrain ( const std::uint32_t entityId,
const GUI::ECS::Online::PlayerBrain & copy )

Construct a new PlayerBrain object with an entity ID and a copy of another instance.

Parameters
entityIdThe unique ID of the entity.
copyThe PlayerBrain instance to copy from.

Definition at line 27 of file PlayerBrain.cpp.

◆ ~PlayerBrain()

GUI::ECS::Online::PlayerBrain::~PlayerBrain ( )
default

Destructor.

Member Function Documentation

◆ getBullet()

const GUI::ECS::Online::Bullet GUI::ECS::Online::PlayerBrain::getBullet ( ) const

Gets the player's bullet instance.

Returns
The Bullet instance for the player.

Definition at line 188 of file PlayerBrain.cpp.

◆ getCollision()

const GUI::ECS::Systems::Collision GUI::ECS::Online::PlayerBrain::getCollision ( ) const

Gets the player's collision component.

Returns
The Collision component for the player.

Definition at line 198 of file PlayerBrain.cpp.

◆ getHealth()

const long int GUI::ECS::Online::PlayerBrain::getHealth ( ) const

Gets the player's health value.

Returns
The player's current health.

Definition at line 183 of file PlayerBrain.cpp.

◆ getInfo()

const std::string GUI::ECS::Online::PlayerBrain::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 203 of file PlayerBrain.cpp.

◆ getSprite()

const GUI::ECS::Components::SpriteComponent GUI::ECS::Online::PlayerBrain::getSprite ( ) const

Gets the player's sprite component.

Returns
The SpriteComponent representing the player's sprite.

Definition at line 193 of file PlayerBrain.cpp.

◆ getVisible()

const bool GUI::ECS::Online::PlayerBrain::getVisible ( ) const

Gets the player's visibility state.

Returns
True if the player is visible, false otherwise.

Definition at line 178 of file PlayerBrain.cpp.

◆ isColliding()

const bool GUI::ECS::Online::PlayerBrain::isColliding ( const GUI::ECS::Systems::Collision & second) const

Checks if the player is colliding with another entity.

Parameters
secondThe collision system to check against.
Returns
True if a collision is detected, false otherwise.

Definition at line 91 of file PlayerBrain.cpp.

◆ isVisible()

const bool GUI::ECS::Online::PlayerBrain::isVisible ( ) const

Checks if the player is currently visible.

Returns
True if the player is visible, false otherwise.

Definition at line 123 of file PlayerBrain.cpp.

◆ operator=()

GUI::ECS::Online::PlayerBrain & GUI::ECS::Online::PlayerBrain::operator= ( const GUI::ECS::Online::PlayerBrain & copy)

Overloads the assignment operator to copy from another PlayerBrain.

Parameters
copyThe PlayerBrain to copy data from.
Returns
A reference to the updated instance.

Definition at line 172 of file PlayerBrain.cpp.

◆ render()

const GUI::ECS::Components::SpriteComponent GUI::ECS::Online::PlayerBrain::render ( )

Renders the player's sprite to the screen.

Returns
The SpriteComponent representing the player's sprite.

Definition at line 146 of file PlayerBrain.cpp.

◆ setBulletSize()

void GUI::ECS::Online::PlayerBrain::setBulletSize ( const std::pair< float, float > & size)

Sets the bullet dimensions.

Parameters
sizeA pair of (width, height) dimensions for the bullet.

Definition at line 86 of file PlayerBrain.cpp.

◆ setDimension()

void GUI::ECS::Online::PlayerBrain::setDimension ( const std::pair< float, float > & size)

Sets the player's dimensions.

Parameters
sizeA pair of (width, height) dimensions.

Definition at line 66 of file PlayerBrain.cpp.

◆ setHealth()

void GUI::ECS::Online::PlayerBrain::setHealth ( const long int health)

Sets the player's health.

Parameters
healthThe health value to set.

Definition at line 72 of file PlayerBrain.cpp.

◆ setPosition()

void GUI::ECS::Online::PlayerBrain::setPosition ( const std::pair< float, float > & pos)

Sets the player's position.

Parameters
posA pair of (x, y) coordinates representing the position.

Definition at line 57 of file PlayerBrain.cpp.

◆ setSprite()

void GUI::ECS::Online::PlayerBrain::setSprite ( const std::shared_ptr< GUI::ECS::Components::SpriteComponent > & sprite,
const std::shared_ptr< GUI::ECS::Components::SpriteComponent > & bullet )

Sets the sprite and bullet sprite components for the player.

Parameters
spriteThe player's sprite component.
bulletThe player's bullet sprite component.

Definition at line 34 of file PlayerBrain.cpp.

◆ setVisible()

void GUI::ECS::Online::PlayerBrain::setVisible ( const bool visible)

Sets the player's visibility state.

Parameters
visibleTrue if the player should be visible, false otherwise.

Definition at line 80 of file PlayerBrain.cpp.

◆ shoot()

const GUI::ECS::Online::Bullet GUI::ECS::Online::PlayerBrain::shoot ( const std::uint32_t id) const

Simulates the player shooting a bullet.

Returns
A Bullet instance representing the player's shot.

Definition at line 135 of file PlayerBrain.cpp.

◆ tick()

void GUI::ECS::Online::PlayerBrain::tick ( )

Updates the player's state for the current frame.

Definition at line 129 of file PlayerBrain.cpp.

◆ update()

void GUI::ECS::Online::PlayerBrain::update ( const GUI::ECS::Online::PlayerBrain & copy)

Updates the player's state by copying another PlayerBrain.

Updates the sprite by copying another PlayerBrain.

Parameters
copyThe PlayerBrain instance to copy data from.
copyThe PlayerBrain to copy data from.

Definition at line 156 of file PlayerBrain.cpp.


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