R-Type  2
Doom but in better
Loading...
Searching...
No Matches
EnemyBrain.hpp
Go to the documentation of this file.
1/*
2** EPITECH PROJECT, 2024
3** rtype (Workspace)
4** File description:
5** EnemyBrain.hpp
6*/
7
17#pragma once
18#include <random>
19#include "Log.hpp"
20#include "Recoded.hpp"
21#include "LogMacros.hpp"
22#include "Utilities.hpp"
28
29namespace GUI
30{
31 namespace ECS
32 {
33 namespace Demo
34 {
40 class EnemyBrain : public EntityNode {
41 public:
47 EnemyBrain(const std::uint32_t entityId = 0);
48
55
62 EnemyBrain(const std::uint32_t entityId, const GUI::ECS::Demo::EnemyBrain &copy);
63
67 ~EnemyBrain() = default;
68
75 void setSprite(const std::shared_ptr<GUI::ECS::Components::SpriteComponent> &sprite, const std::shared_ptr<GUI::ECS::Components::SpriteComponent> &bullet);
76
82 void setPosition(const std::pair<float, float> &pos);
83
89 void setDimension(const std::pair<float, float> &size);
90
96 void setHealth(const long int health);
97
103 void setVisible(const bool visible);
104
110 void setBulletSize(const std::pair<float, float> &size);
111
119 const bool isColliding(const GUI::ECS::Systems::Collision &second) const;
120
126 const bool isVisible() const;
127
133 const std::optional<GUI::ECS::Demo::Bullet> tick();
134
141
147 void update(const GUI::ECS::Demo::EnemyBrain &copy);
148
157
163 const bool getVisible() const;
164
170 const long int getHealth() const;
171
177 const GUI::ECS::Demo::Bullet getBullet() const;
178
185
192
202 const std::string getInfo(const unsigned int indent = 0) const;
203
204 private:
213 const int _randInt(int min = 5, int max = 20);
214
215 bool _visible = true;
216 long int _health = 1;//00; //!< The health of the enemy.
217 unsigned int _delayBeforeShot = 20;
218 GUI::ECS::Demo::Bullet _bullet;
221 };
222
231 std::ostream &operator<<(std::ostream &os, const EnemyBrain &item);
232 }
233 }
234}
File in charge of containing the logic for the bullet class.
Declaration of the PlayerBrain class and related functionality.
This is the file that links the EntityNode children.
Macro definitions for logging messages with varying levels of detail and formatting.
This is the file in charge of containing the Log class (the one in charge of outputing info only when...
This is an agglomerator in which all the files from Recoded folder will be included.
This is the file that contains the class in charge of managing a sprite.
Represents a drawable and interactive sprite in the ECS system.
Represents a bullet entity in the game.
Definition Bullet.hpp:31
The EnemyBrain class represents the logic and behavior of an enemy entity.
const bool getVisible() const
Gets the visibility status of the enemy.
const std::optional< GUI::ECS::Demo::Bullet > tick()
Updates the enemy's state and determines if it should fire a bullet.
void update(const GUI::ECS::Demo::EnemyBrain &copy)
Updates the sprite by copying another EnemyBrain.
void setVisible(const bool visible)
Sets the visibility of the enemy.
const GUI::ECS::Systems::Collision getCollision() const
Gets the collision data for the enemy.
void setPosition(const std::pair< float, float > &pos)
Sets the position of the enemy.
const bool isColliding(const GUI::ECS::Systems::Collision &second) const
Checks if the enemy is colliding with another entity.
const GUI::ECS::Demo::Bullet getBullet() const
Gets the bullet 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 ...
const GUI::ECS::Components::SpriteComponent render()
Renders the enemy's sprite.
EnemyBrain & operator=(const GUI::ECS::Demo::EnemyBrain &copy)
Overloads the assignment operator to copy from another EnemyBrain.
void setHealth(const long int health)
Sets the health of the enemy.
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.
const bool isVisible() const
Checks if the enemy is visible.
const long int getHealth() const
Gets the health of the enemy.
void setDimension(const std::pair< float, float > &size)
Sets the dimensions of the enemy.
const GUI::ECS::Components::SpriteComponent getSprite() const
Gets the sprite data for the enemy.
~EnemyBrain()=default
Destructor.
EnemyBrain(const std::uint32_t entityId=0)
Default constructor.
void setBulletSize(const std::pair< float, float > &size)
Sets the size of the bullet.
Represents a rectangular component that can detect collisions and mouse interactions,...
Definition Collision.hpp:39
std::ostream & operator<<(std::ostream &os, const Bullet &item)
Outputs the sprite's info to a stream.
Definition Bullet.cpp:259