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 Online
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::Online::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 void tick();
134
142 const GUI::ECS::Online::Bullet shoot(const std::uint32_t id);
143
150
156 void update(const GUI::ECS::Online::EnemyBrain &copy);
157
166
172 const bool getVisible() const;
173
179 const long int getHealth() const;
180
187
194
201
211 const std::string getInfo(const unsigned int indent = 0) const;
212
213 private:
222 const int _randInt(int min = 5, int max = 20);
223
224 bool _visible = true;
225 long int _health = 3;
226 unsigned int _delayBeforeShot = 20;
230 };
231
240 std::ostream &operator<<(std::ostream &os, const EnemyBrain &item);
241 }
242 }
243}
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...
File in charge of containing the logic for the bullet class.
Declaration of the PlayerBrain class and related functionality.
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 GUI::ECS::Components::SpriteComponent render()
Renders the enemy's sprite.
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 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 ...
void setVisible(const bool visible)
Sets the visibility of the enemy.
const bool isVisible() const
Checks if the enemy is visible.
const bool isColliding(const GUI::ECS::Systems::Collision &second) const
Checks if the enemy is colliding with another entity.
void setPosition(const std::pair< float, float > &pos)
Sets the position of the enemy.
EnemyBrain & operator=(const GUI::ECS::Online::EnemyBrain &copy)
Overloads the assignment operator to copy from another EnemyBrain.
EnemyBrain(const std::uint32_t entityId=0)
Default constructor.
void setDimension(const std::pair< float, float > &size)
Sets the dimensions of the enemy.
const long int getHealth() const
Gets the health of the enemy.
const GUI::ECS::Online::Bullet shoot(const std::uint32_t id)
Make the enemy shoot a projectile with a defined id.
const bool getVisible() const
Gets the visibility status of the enemy.
const GUI::ECS::Components::SpriteComponent getSprite() const
Gets the sprite data for the enemy.
void setBulletSize(const std::pair< float, float > &size)
Sets the size of the bullet.
~EnemyBrain()=default
Destructor.
const GUI::ECS::Systems::Collision getCollision() const
Gets the collision data for the enemy.
void update(const GUI::ECS::Online::EnemyBrain &copy)
Updates the sprite by copying another EnemyBrain.
void tick()
Updates the enemy's state and determines if it should fire a bullet.
const GUI::ECS::Online::Bullet getBullet() const
Gets the bullet data for the enemy.
void setHealth(const long int health)
Sets the health of the enemy.
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:260