R-Type  2
Doom but in better
Loading...
Searching...
No Matches
Orchestrator.hpp
Go to the documentation of this file.
1/*
2** EPITECH PROJECT, 2024
3** rtype (Workspace)
4** File description:
5** Orchestrator.hpp
6*/
7
16#pragma once
17#include <any>
18#include <vector>
19#include <memory>
20#include <random>
21#include <unordered_map>
22#include "Log.hpp"
23#include "Recoded.hpp"
24#include "SoundLib.hpp"
25#include "LogMacros.hpp"
26#include "Utilities.hpp"
27#include "CustomExceptions.hpp"
32#include "GUI/ECS/Systems.hpp"
36
37namespace GUI
38{
39 namespace ECS
40 {
41 namespace Online
42 {
49 class Orchestrator : public EntityNode {
50 public:
56 Orchestrator(const std::uint32_t entityId = 0);
57
61 ~Orchestrator() = default;
62
68 void initialiseClass(std::unordered_map<std::type_index, std::vector<std::any>> &ecsEntities);
69
70 void setNetworkClass(const std::shared_ptr<GUI::Network::ThreadCapsule> &network);
71
75 void start();
76
80 void stop();
81
85 void reset();
86
90 void tick(const std::vector<GUI::Network::MessageNode> &packets);
91
95 void tick_all();
96
100 void render();
101
107 const bool isGameOver() const;
108
114 const bool isGameWon() const;
115
116
126 const std::string getInfo(const unsigned int indent = 0) const;
127
128 private:
129
133 void _shootSound();
137 void _damageSound();
141 void _deadSound();
145 void _buttonSound();
149 void _gameOverSound();
153 void _winSound();
154
158 void _spawn(const std::uint32_t id, const std::pair<float, float> &pos);
159
166 void _spawnFriendBullet(const std::uint32_t id, const std::pair<float, float> &pos);
167
174 void _spawnEnemyBullet(const std::uint32_t id, const std::pair<float, float> &pos);
175
182 void _setPosition(const std::uint32_t id, const std::pair<float, float> &pos);
183
189 void _killEntity(const std::uint32_t id);
190
196 void _sendMessage(const GUI::Network::MessageNode &node);
197
201 void _kill();
202
208 void _spawnEnemy(const std::uint32_t id, const std::pair<float, float> pos);
209
218 const int _randInt(int min = 0, int max = 5);
219
223 void _setTheScene();
224
228 void _setTextComponents();
229
230 bool _playing = false;
231 bool _gameWon = false;
232 bool _gameOver = false;
233 int _stepUp = -10;
234 int _stepDown = 10;
235 int _stepLeft = -10;
236 int _stepRight = 10;
237 float _screenPosXOffset = 75;
238 float _screenPosYOffset = 45;
239 long int _activeEnemies = 0;
240 std::size_t _playerId = 0;
241 std::optional<std::shared_ptr<GUI::ECS::Components::TextComponent>> _remainingEnemies;
242 std::optional<std::shared_ptr<GUI::ECS::Components::ImageComponent>> _backgroundItem;
243 std::shared_ptr<GUI::ECS::Components::SpriteComponent> _spriteBullet;
244 std::shared_ptr<GUI::ECS::Components::SpriteComponent> _spriteBulletEnemy;
245 std::shared_ptr<GUI::ECS::Components::SpriteComponent> _spritePlayer;
246 std::shared_ptr<GUI::ECS::Components::SpriteComponent> _spriteEnemy;
247 std::vector<GUI::ECS::Online::Bullet> _playerBullets;
248 std::vector<GUI::ECS::Online::Bullet> _enemyBullets;
249 std::shared_ptr<GUI::ECS::Systems::Window> _window;
250 std::shared_ptr<GUI::ECS::Systems::EventManager> _event;
251 std::vector<std::shared_ptr<GUI::ECS::Online::PlayerBrain>> _playerBrain;
252 std::vector<std::shared_ptr<GUI::ECS::Online::EnemyBrain>> _enemyBrain;
253 std::unordered_map<std::type_index, std::vector<std::any>> _ecsEntities;
254 std::optional<std::shared_ptr<GUI::Network::ThreadCapsule>> _network;
255 };
256
265 std::ostream &operator<<(std::ostream &os, const Orchestrator &item);
266 }
267 }
268}
File in charge of containing the custom errors that are going to be used for custom description error...
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 EnemyBrain class and its related functionality.
Declaration of the PlayerBrain class and related functionality.
This is an agglomerator in which all the files from Recoded folder will be included.
Declaration of the SoundLib class for managing sounds in the ECS architecture.
The Orchestrator class manages the overall game state, including entity creation, updates,...
const bool isGameWon() const
Checks if the game has been won.
void tick(const std::vector< GUI::Network::MessageNode > &packets)
Updates the game state for the current frame.
void start()
Starts the game logic and sets the game to a playing state.
void reset()
Resets the game state, clearing all entities and resetting conditions.
const bool isGameOver() const
Checks if the game is over.
void render()
Renders the game entities to the window.
void stop()
Stops the game logic and resets the playing state.
Orchestrator(const std::uint32_t entityId=0)
Default constructor.
void initialiseClass(std::unordered_map< std::type_index, std::vector< std::any > > &ecsEntities)
Initializes the ECS entities managed by the orchestrator.
void tick_all()
Ticks all entities.
~Orchestrator()=default
Destructor.
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 setNetworkClass(const std::shared_ptr< GUI::Network::ThreadCapsule > &network)
This is the file that links the Components children.
This is the file that links the utility children ressources.
std::ostream & operator<<(std::ostream &os, const Bullet &item)
Outputs the sprite's info to a stream.
Definition Bullet.cpp:260