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

Represents a bullet entity in the game. More...

#include <Bullet.hpp>

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

Public Member Functions

 Bullet (const std::uint32_t EntityId=0)
 Default constructor for the Bullet class.
 
 Bullet (const GUI::ECS::Components::SpriteComponent &sprite, const bool fromEnemy, const std::pair< int, int > &positionInitial, const unsigned int speed, const std::pair< int, int > &direction={ 0, -1 }, const int damage=10)
 Parameterized constructor for initializing a Bullet object.
 
 Bullet (const GUI::ECS::Online::Bullet &bullet)
 Copy constructor for Bullet.
 
 Bullet (const std::uint32_t EntityId, const GUI::ECS::Components::SpriteComponent &sprite, const bool fromEnemy, const std::pair< int, int > &positionInitial, const unsigned int speed, const std::pair< int, int > &direction={ 0, -1 }, const int damage=10)
 Constructor for creating a Bullet with both an Entity ID and attributes.
 
 Bullet (const std::uint32_t EntityId, const GUI::ECS::Online::Bullet &bullet)
 Combines entity ID and Bullet attributes from another instance.
 
 ~Bullet ()=default
 Default destructor for the Bullet class.
 
void setVisible (const bool visible)
 Sets the visibility of the bullet.
 
void setPosition (const std::pair< float, float > &pos)
 Sets the position of the bullet.
 
void setSprite (const GUI::ECS::Components::SpriteComponent &sprite)
 Sets the sprite representing the bullet.
 
void setEnemy (const bool enemy)
 Marks the bullet as fired by an enemy or not.
 
void setSpeed (const unsigned int speed)
 Sets the speed of the bullet.
 
void setDirection (const std::pair< int, int > &direction)
 Sets the direction of the bullet.
 
void setSize (const std::pair< float, float > &dimension)
 Sets the size of the bullet.
 
void setDamage (const int damage)
 Sets the damage dealt by the bullet.
 
void tick ()
 Advances the bullet's state by one tick.
 
const GUI::ECS::Components::SpriteComponent render ()
 Renders the bullet.
 
const bool isVisible () const
 
const bool isEnemy () const
 
const std::pair< float, float > getPosition () const
 
const bool isColliding (const GUI::ECS::Systems::Collision &second) const
 
void update (const GUI::ECS::Online::Bullet &copy)
 Updates the sprite by copying another Bullet.
 
Bulletoperator= (const GUI::ECS::Online::Bullet &copy)
 Overloads the assignment operator to copy from another Bullet.
 
const unsigned int getSpeed () const
 Get the Speed at which the bullet is traveling.
 
const GUI::ECS::Systems::Collision getCollision () const
 Get the Collision component.
 
const GUI::ECS::Components::SpriteComponent getSprite () const
 Get the Sprite component.
 
const std::pair< int, int > getPositionInitial () const
 Get the initial position that was set for the object.
 
const int getDamage () const
 Get the Damage the bullet will inflict upon impact.
 
const std::pair< int, int > getDirection () const
 Get the Direction in which the bullet is travelling.
 
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

Represents a bullet entity in the game.

Definition at line 31 of file Bullet.hpp.

Constructor & Destructor Documentation

◆ Bullet() [1/5]

GUI::ECS::Online::Bullet::Bullet ( const std::uint32_t EntityId = 0)

Default constructor for the Bullet class.

Parameters
EntityIdThe unique identifier of the entity. Default is 0.

Definition at line 16 of file Bullet.cpp.

◆ Bullet() [2/5]

GUI::ECS::Online::Bullet::Bullet ( const GUI::ECS::Components::SpriteComponent & sprite,
const bool fromEnemy,
const std::pair< int, int > & positionInitial,
const unsigned int speed,
const std::pair< int, int > & direction = { 0, -1 },
const int damage = 10 )

Parameterized constructor for initializing a Bullet object.

Parameters
spriteThe sprite representing the bullet's appearance.
fromEnemyIndicates if the bullet was fired by an enemy.
positionInitialThe initial position of the bullet.
speedThe speed of the bullet.
directionThe direction vector of the bullet. Default is {0, -1}.
damageThe damage inflicted by the bullet. Default is 10.

Definition at line 21 of file Bullet.cpp.

◆ Bullet() [3/5]

GUI::ECS::Online::Bullet::Bullet ( const GUI::ECS::Online::Bullet & bullet)

Copy constructor for Bullet.

Parameters
bulletThe Bullet instance to copy.

Definition at line 33 of file Bullet.cpp.

◆ Bullet() [4/5]

GUI::ECS::Online::Bullet::Bullet ( const std::uint32_t EntityId,
const GUI::ECS::Components::SpriteComponent & sprite,
const bool fromEnemy,
const std::pair< int, int > & positionInitial,
const unsigned int speed,
const std::pair< int, int > & direction = { 0, -1 },
const int damage = 10 )

Constructor for creating a Bullet with both an Entity ID and attributes.

Parameters
EntityIdThe unique identifier of the entity.
spriteThe sprite representing the bullet's appearance.
fromEnemyIndicates if the bullet was fired by an enemy.
positionInitialThe initial position of the bullet.
speedThe speed of the bullet.
directionThe direction vector of the bullet. Default is {0, -1}.
damageThe damage inflicted by the bullet. Default is 10.

Definition at line 27 of file Bullet.cpp.

◆ Bullet() [5/5]

GUI::ECS::Online::Bullet::Bullet ( const std::uint32_t EntityId,
const GUI::ECS::Online::Bullet & bullet )

Combines entity ID and Bullet attributes from another instance.

Parameters
EntityIdThe unique identifier of the entity.
bulletThe Bullet instance to copy attributes from.

Definition at line 39 of file Bullet.cpp.

◆ ~Bullet()

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

Default destructor for the Bullet class.

Member Function Documentation

◆ getCollision()

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

Get the Collision component.

Returns
const GUI::ECS::Systems::Collision

Definition at line 207 of file Bullet.cpp.

◆ getDamage()

const int GUI::ECS::Online::Bullet::getDamage ( ) const

Get the Damage the bullet will inflict upon impact.

Returns
const int

Definition at line 222 of file Bullet.cpp.

◆ getDirection()

const std::pair< int, int > GUI::ECS::Online::Bullet::getDirection ( ) const

Get the Direction in which the bullet is travelling.

Returns
const std::pair<int, int>

Definition at line 227 of file Bullet.cpp.

◆ getInfo()

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

◆ getPosition()

const std::pair< float, float > GUI::ECS::Online::Bullet::getPosition ( ) const

Definition at line 129 of file Bullet.cpp.

◆ getPositionInitial()

const std::pair< int, int > GUI::ECS::Online::Bullet::getPositionInitial ( ) const

Get the initial position that was set for the object.

Returns
const std::pair<int, int>

Definition at line 217 of file Bullet.cpp.

◆ getSpeed()

const unsigned int GUI::ECS::Online::Bullet::getSpeed ( ) const

Get the Speed at which the bullet is traveling.

Returns
const unsigned int the speed of the bullet

Definition at line 202 of file Bullet.cpp.

◆ getSprite()

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

Get the Sprite component.

Returns
const GUI::ECS::Components::SpriteComponent

Definition at line 212 of file Bullet.cpp.

◆ isColliding()

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

Definition at line 139 of file Bullet.cpp.

◆ isEnemy()

const bool GUI::ECS::Online::Bullet::isEnemy ( ) const

Definition at line 124 of file Bullet.cpp.

◆ isVisible()

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

Definition at line 119 of file Bullet.cpp.

◆ operator=()

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

Overloads the assignment operator to copy from another Bullet.

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

Definition at line 196 of file Bullet.cpp.

◆ render()

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

Renders the bullet.

Returns
The current sprite component representing the bullet.

Definition at line 114 of file Bullet.cpp.

◆ setDamage()

void GUI::ECS::Online::Bullet::setDamage ( const int damage)

Sets the damage dealt by the bullet.

Parameters
damageThe amount of damage.

Definition at line 84 of file Bullet.cpp.

◆ setDirection()

void GUI::ECS::Online::Bullet::setDirection ( const std::pair< int, int > & direction)

Sets the direction of the bullet.

Parameters
directionA pair of integers representing the direction vector.

Definition at line 73 of file Bullet.cpp.

◆ setEnemy()

void GUI::ECS::Online::Bullet::setEnemy ( const bool enemy)

Marks the bullet as fired by an enemy or not.

Parameters
enemyTrue if the bullet belongs to an enemy, false otherwise.

Definition at line 63 of file Bullet.cpp.

◆ setPosition()

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

Sets the position of the bullet.

Parameters
posThe new position as a pair of floats.

Definition at line 52 of file Bullet.cpp.

◆ setSize()

void GUI::ECS::Online::Bullet::setSize ( const std::pair< float, float > & dimension)

Sets the size of the bullet.

Parameters
dimensionA pair of floats representing width and height.

Definition at line 78 of file Bullet.cpp.

◆ setSpeed()

void GUI::ECS::Online::Bullet::setSpeed ( const unsigned int speed)

Sets the speed of the bullet.

Parameters
speedThe speed value.

Definition at line 68 of file Bullet.cpp.

◆ setSprite()

void GUI::ECS::Online::Bullet::setSprite ( const GUI::ECS::Components::SpriteComponent & sprite)

Sets the sprite representing the bullet.

Parameters
spriteThe new sprite component.

Definition at line 58 of file Bullet.cpp.

◆ setVisible()

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

Sets the visibility of the bullet.

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

Definition at line 46 of file Bullet.cpp.

◆ tick()

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

Advances the bullet's state by one tick.

Definition at line 89 of file Bullet.cpp.

◆ update()

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

Updates the sprite by copying another Bullet.

Parameters
copyThe Bullet to copy data from.

Definition at line 176 of file Bullet.cpp.


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