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

The EnemyBrain class represents the logic and behavior of an enemy entity. More...

#include <EnemyBrain.hpp>

Inheritance diagram for GUI::ECS::Demo::EnemyBrain:
Inheritance graph
Collaboration diagram for GUI::ECS::Demo::EnemyBrain:
Collaboration graph

Public Member Functions

 EnemyBrain (const std::uint32_t entityId=0)
 Default constructor.
 
 EnemyBrain (const GUI::ECS::Demo::EnemyBrain &copy)
 Copy constructor.
 
 EnemyBrain (const std::uint32_t entityId, const GUI::ECS::Demo::EnemyBrain &copy)
 Parameterized constructor that initializes with another EnemyBrain.
 
 ~EnemyBrain ()=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 components for the enemy and its bullet.
 
void setPosition (const std::pair< float, float > &pos)
 Sets the position of the enemy.
 
void setDimension (const std::pair< float, float > &size)
 Sets the dimensions of the enemy.
 
void setHealth (const long int health)
 Sets the health of the enemy.
 
void setVisible (const bool visible)
 Sets the visibility of the enemy.
 
void setBulletSize (const std::pair< float, float > &size)
 Sets the size of the bullet.
 
const bool isColliding (const GUI::ECS::Systems::Collision &second) const
 Checks if the enemy is colliding with another entity.
 
const bool isVisible () const
 Checks if the enemy is visible.
 
const std::optional< GUI::ECS::Demo::Bullettick ()
 Updates the enemy's state and determines if it should fire a bullet.
 
const GUI::ECS::Components::SpriteComponent render ()
 Renders the enemy's sprite.
 
void update (const GUI::ECS::Demo::EnemyBrain &copy)
 Updates the sprite by copying another EnemyBrain.
 
EnemyBrainoperator= (const GUI::ECS::Demo::EnemyBrain &copy)
 Overloads the assignment operator to copy from another EnemyBrain.
 
const bool getVisible () const
 Gets the visibility status of the enemy.
 
const long int getHealth () const
 Gets the health of the enemy.
 
const GUI::ECS::Demo::Bullet getBullet () const
 Gets the bullet data for the enemy.
 
const GUI::ECS::Components::SpriteComponent getSprite () const
 Gets the sprite data for the enemy.
 
const GUI::ECS::Systems::Collision getCollision () const
 Gets the collision data for the enemy.
 
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

The EnemyBrain class represents the logic and behavior of an enemy entity.

This class inherits from EntityNode and manages various aspects of an enemy's behavior, such as its sprite, position, health, and visibility.

Definition at line 40 of file EnemyBrain.hpp.

Constructor & Destructor Documentation

◆ EnemyBrain() [1/3]

GUI::ECS::Demo::EnemyBrain::EnemyBrain ( const std::uint32_t entityId = 0)

Default constructor.

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

Definition at line 16 of file EnemyBrain.cpp.

◆ EnemyBrain() [2/3]

GUI::ECS::Demo::EnemyBrain::EnemyBrain ( const GUI::ECS::Demo::EnemyBrain & copy)

Copy constructor.

Parameters
copyThe EnemyBrain instance to copy.

Definition at line 22 of file EnemyBrain.cpp.

◆ EnemyBrain() [3/3]

GUI::ECS::Demo::EnemyBrain::EnemyBrain ( const std::uint32_t entityId,
const GUI::ECS::Demo::EnemyBrain & copy )

Parameterized constructor that initializes with another EnemyBrain.

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

Definition at line 27 of file EnemyBrain.cpp.

◆ ~EnemyBrain()

GUI::ECS::Demo::EnemyBrain::~EnemyBrain ( )
default

Destructor.

Member Function Documentation

◆ getBullet()

const GUI::ECS::Demo::Bullet GUI::ECS::Demo::EnemyBrain::getBullet ( ) const

Gets the bullet data for the enemy.

Returns
The Bullet instance.

Definition at line 189 of file EnemyBrain.cpp.

◆ getCollision()

const GUI::ECS::Systems::Collision GUI::ECS::Demo::EnemyBrain::getCollision ( ) const

Gets the collision data for the enemy.

Returns
The Collision instance.

Definition at line 199 of file EnemyBrain.cpp.

◆ getHealth()

const long int GUI::ECS::Demo::EnemyBrain::getHealth ( ) const

Gets the health of the enemy.

Returns
The current health value.

Definition at line 184 of file EnemyBrain.cpp.

◆ getInfo()

const std::string GUI::ECS::Demo::EnemyBrain::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 214 of file EnemyBrain.cpp.

◆ getSprite()

const GUI::ECS::Components::SpriteComponent GUI::ECS::Demo::EnemyBrain::getSprite ( ) const

Gets the sprite data for the enemy.

Returns
The SpriteComponent instance.

Definition at line 194 of file EnemyBrain.cpp.

◆ getVisible()

const bool GUI::ECS::Demo::EnemyBrain::getVisible ( ) const

Gets the visibility status of the enemy.

Returns
True if visible, false otherwise.

Definition at line 179 of file EnemyBrain.cpp.

◆ isColliding()

const bool GUI::ECS::Demo::EnemyBrain::isColliding ( const GUI::ECS::Systems::Collision & second) const

Checks if the enemy is colliding with another entity.

Parameters
secondThe collision data of the other entity.
Returns
True if colliding, false otherwise.

Definition at line 90 of file EnemyBrain.cpp.

◆ isVisible()

const bool GUI::ECS::Demo::EnemyBrain::isVisible ( ) const

Checks if the enemy is visible.

Returns
True if visible, false otherwise.

Definition at line 122 of file EnemyBrain.cpp.

◆ operator=()

GUI::ECS::Demo::EnemyBrain & GUI::ECS::Demo::EnemyBrain::operator= ( const GUI::ECS::Demo::EnemyBrain & copy)

Overloads the assignment operator to copy from another EnemyBrain.

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

Definition at line 173 of file EnemyBrain.cpp.

◆ render()

const GUI::ECS::Components::SpriteComponent GUI::ECS::Demo::EnemyBrain::render ( )

Renders the enemy's sprite.

Returns
The SpriteComponent of the enemy.

Definition at line 147 of file EnemyBrain.cpp.

◆ setBulletSize()

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

Sets the size of the bullet.

Parameters
sizeThe size as a pair of (width, height).

Definition at line 85 of file EnemyBrain.cpp.

◆ setDimension()

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

Sets the dimensions of the enemy.

Parameters
sizeThe dimensions as a pair of (width, height).

Definition at line 65 of file EnemyBrain.cpp.

◆ setHealth()

void GUI::ECS::Demo::EnemyBrain::setHealth ( const long int health)

Sets the health of the enemy.

Parameters
healthThe health value.

Definition at line 71 of file EnemyBrain.cpp.

◆ setPosition()

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

Sets the position of the enemy.

Parameters
posThe position as a pair of (x, y) coordinates.

Definition at line 56 of file EnemyBrain.cpp.

◆ setSprite()

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

Sets the sprite components for the enemy and its bullet.

Parameters
spriteThe sprite for the enemy.
bulletThe sprite for the bullet.

Definition at line 33 of file EnemyBrain.cpp.

◆ setVisible()

void GUI::ECS::Demo::EnemyBrain::setVisible ( const bool visible)

Sets the visibility of the enemy.

Parameters
visibleTrue if visible, false otherwise.

Definition at line 79 of file EnemyBrain.cpp.

◆ tick()

const std::optional< GUI::ECS::Demo::Bullet > GUI::ECS::Demo::EnemyBrain::tick ( )

Updates the enemy's state and determines if it should fire a bullet.

Returns
An optional Bullet instance if a bullet is fired, or std::nullopt if not.

Definition at line 127 of file EnemyBrain.cpp.

◆ update()

void GUI::ECS::Demo::EnemyBrain::update ( const GUI::ECS::Demo::EnemyBrain & copy)

Updates the sprite by copying another EnemyBrain.

Parameters
copyThe EnemyBrain to copy data from.

Definition at line 157 of file EnemyBrain.cpp.


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