23 PRETTY_DEBUG <<
"Resetting the values stored in the class" << std::endl;
24 _ecsEntities = ecsEntities;
27 _spriteBullet.reset();
28 _spritePlayer.reset();
32 _enemyBullets.clear();
33 _playerBullets.clear();
34 PRETTY_DEBUG <<
"The values stored in the class have been reset" << std::endl;
36 PRETTY_DEBUG <<
"Fetching the window manager" << std::endl;
39 if (!window_ptr.has_value()) {
40 PRETTY_ERROR <<
"The window manager has not been found" << std::endl;
43 _window = window_ptr.value();
44 PRETTY_DEBUG <<
"The window manager has been fetched" << std::endl;
46 PRETTY_DEBUG <<
"Fetching the event manager" << std::endl;
49 if (!event_ptr.has_value()) {
53 _event = event_ptr.value();
54 PRETTY_DEBUG <<
"The event manager has been fetched" << std::endl;
56 PRETTY_DEBUG <<
"Fetching the sprites contained in the ecs array (if present)" << std::endl;
59 for (std::any node : sprites) {
61 if (!sprite.has_value()) {
64 std::string name = sprite.value()->getName();
65 std::string applicationContext = sprite.value()->getApplication();
67 PRETTY_DEBUG <<
"Current sprite info { name: '" << name <<
"', application context: '" << applicationContext <<
"' }" << std::endl;
70 applicationContext ==
"sprite42" || name ==
"r-typesheet42" ||
71 applicationContext ==
"sprite42" || name ==
"r-typesheet42"
73 PRETTY_DEBUG <<
"Sprite player has been found" << std::endl;
74 _spritePlayer = sprite.value();
75 PRETTY_DEBUG <<
"Sprite player content:\n" << *_spritePlayer << std::endl;
77 applicationContext ==
"sprite30c" || name ==
"sprite30c" ||
78 applicationContext ==
"typesheet30c" || name ==
"typesheet30c"
81 _spriteBullet = sprite.value();
82 _spriteBullet->forceTick();
83 PRETTY_DEBUG <<
"Sprite bullet content:\n" << *_spriteBullet << std::endl;
85 applicationContext ==
"sprite3c" || name ==
"sprite3c" ||
86 applicationContext ==
"r-typesheet3c" || name ==
"r-typesheet3c"
88 PRETTY_DEBUG <<
"Sprite bullet enemy found" << std::endl;
89 _spriteBulletEnemy = sprite.value();
90 _spriteBulletEnemy->forceTick();
91 PRETTY_DEBUG <<
"Sprite bullet enemy content:\n" << *_spriteBulletEnemy << std::endl;
93 applicationContext ==
"r-typesheet13" || name ==
"r-typesheet13" ||
94 applicationContext ==
"sprite13" || name ==
"sprite13"
97 _spriteEnemy = sprite.value();
98 PRETTY_DEBUG <<
"Sprite enemy content:\n" << *_spriteEnemy << std::endl;
101 PRETTY_DEBUG <<
"The sprite player has been fetched" << std::endl;
103 PRETTY_DEBUG <<
"Checking if the elements are loaded or not" << std::endl;
104 if (_spriteBullet ==
nullptr || _spritePlayer ==
nullptr || _spriteEnemy ==
nullptr || _spriteBulletEnemy ==
nullptr) {
105 PRETTY_ERROR <<
"The sprite player, bullet, enemy or bullet enemy has not been found" << std::endl;
110 _setTextComponents();
111 PRETTY_DEBUG <<
"Fetching a background for the game" << std::endl;
113 PRETTY_DEBUG <<
"Declaring the ressource required for the settings menu to have a background" << std::endl;
114 std::optional<std::shared_ptr<GUI::ECS::Components::ImageComponent>> backgroundItem;
115 PRETTY_DEBUG <<
"Declared the ressource required for the settings menu to have a background" << std::endl;
117 for (std::any backgroundCast : backgrounds) {
119 if (!backgroundCapsule.has_value()) {
123 backgroundCapsule.value()->getApplication() ==
"space" || backgroundCapsule.value()->getName() ==
"space" ||
124 backgroundCapsule.value()->getApplication() ==
"Space" || backgroundCapsule.value()->getName() ==
"Space"
126 backgroundItem.emplace(backgroundCapsule.value());
129 PRETTY_DEBUG <<
"Background fetched if present" << std::endl;
134 if (network ==
nullptr) {
137 _network.emplace(network);
142 PRETTY_DEBUG <<
"The start function has been called" << std::endl;
150 PRETTY_DEBUG <<
"The stop function has been called" << std::endl;
158 PRETTY_DEBUG <<
"The reset function has been called" << std::endl;
170 PRETTY_DEBUG <<
"Skipping tick because we are not playing" << std::endl;
174 PRETTY_DEBUG <<
"Orchestrator dump (before tick):\n" << getInfo(0) << std::endl;
177 PRETTY_DEBUG <<
"Going to process received packets" << std::endl;
180 switch (packet.type) {
182 _setPosition(packet.id, packet.info.coords);
189 _spawnEnemy(packet.id, packet.info.coords);
191 _spawn(packet.id, packet.info.coords);
193 _spawnEnemyBullet(packet.id, packet.info.coords);
195 _spawnFriendBullet(packet.id, packet.info.coords);
199 _killEntity(packet.id);
208 PRETTY_DEBUG <<
"Processed received packets" << std::endl;
211 PRETTY_DEBUG <<
"Going to process the events" << std::endl;
212 if (_event->getKeys().size() > 0) {
214 if (_playerId < _playerBrain.size()) {
215 std::pair<float, float> position = _playerBrain[_playerId]->getCollision().getPosition();
219 position.second += _stepUp;
220 }
else if (_event->isKeyPressed(
GUI::ECS::Systems::Key::Down) && position.second < _window->getDimensions().second - _screenPosYOffset) {
221 position.second += _stepDown;
223 position.first += _stepLeft;
225 position.first += _stepRight;
229 PRETTY_DEBUG <<
"Checking if the player has shot" << std::endl;
232 if (_playerId < _playerBrain.size()) {
241 PRETTY_DEBUG <<
"Checked if the player had shot" << std::endl;
244 PRETTY_DEBUG <<
"Updating the player's position" << std::endl;
245 if (_playerId < _playerBrain.size()) {
246 _playerBrain[_playerId]->setPosition(position);
252 PRETTY_DEBUG <<
"The player position has been updated" << std::endl;
258 PRETTY_DEBUG <<
"Updating the enemy count component (if present)" << std::endl;
259 if (_remainingEnemies.has_value()) {
260 PRETTY_DEBUG <<
"Remaining enemy counter updated" << std::endl;
261 _remainingEnemies.value()->setText(
"Remaining ennemies: " +
Recoded::myToString(_activeEnemies));
263 PRETTY_DEBUG <<
"Orchestrator dump (after tick): \n" << getInfo(0) << std::endl;
271 for (std::size_t i = 0; i < _playerBrain.size(); i++) {
272 _playerBrain[i]->tick();
274 for (std::size_t i = 0; i < _enemyBrain.size(); i++) {
275 _enemyBrain[i]->tick();
277 for (std::size_t i = 0; i < _enemyBullets.size(); i++) {
278 _enemyBullets[i].tick();
280 for (std::size_t i = 0; i < _playerBullets.size(); i++) {
281 _playerBullets[i].tick();
288 PRETTY_DEBUG <<
"Displaying the background image (if present)" << std::endl;
289 if (_backgroundItem.has_value()) {
290 PRETTY_DEBUG <<
"The background is present, displaying" << std::endl;
291 _window->draw(*(_backgroundItem.value()));
293 PRETTY_WARNING <<
"There is no background to display" << std::endl;
295 PRETTY_DEBUG <<
"Displayed the background image (if present)" << std::endl;
296 PRETTY_DEBUG <<
"Going to render the players" << std::endl;
297 unsigned int index = 0;
298 for (std::shared_ptr<GUI::ECS::Online::PlayerBrain> item : _playerBrain) {
299 std::string name = item->getSprite().getName();
300 std::pair<float, float> pos = item->getCollision().getPosition();
301 std::pair<float, float> dim = item->getCollision().getDimension();
302 bool visible = item->isVisible();
304 _window->draw(item->render());
308 PRETTY_DEBUG <<
"Going to render the ennemies" << std::endl;
310 for (std::shared_ptr<GUI::ECS::Online::EnemyBrain> item : _enemyBrain) {
311 std::string name = item->getSprite().getName();
312 std::pair<float, float> pos = item->getCollision().getPosition();
313 std::pair<float, float> dim = item->getCollision().getDimension();
314 bool visible = item->isVisible();
316 _window->draw(item->render());
320 PRETTY_DEBUG <<
"Going to render the player bullets" << std::endl;
323 std::string name = item.getSprite().getName();
324 std::pair<float, float> pos = item.getCollision().getPosition();
325 std::pair<float, float> dim = item.getCollision().getDimension();
326 bool enemy = item.isEnemy();
327 bool visible = item.isVisible();
329 _window->draw(item.render());
333 PRETTY_DEBUG <<
"Going to render the enemy bullets" << std::endl;
336 std::string name = item.getSprite().getName();
337 std::pair<float, float> pos = item.getCollision().getPosition();
338 std::pair<float, float> dim = item.getCollision().getDimension();
339 bool enemy = item.isEnemy();
340 bool visible = item.isVisible();
342 _window->draw(item.render());
346 PRETTY_DEBUG <<
"Rendering the overlay text (if present)" << std::endl;
347 if (_remainingEnemies.has_value()) {
348 PRETTY_DEBUG <<
"Remaining ennemies has a value, displaying" << std::endl;
349 _window->draw(*(_remainingEnemies.value()));
351 PRETTY_DEBUG <<
"Displayed the overlay text (if present)" << std::endl;
369 std::string indentation =
"";
370 for (
unsigned int i = 0; i < indent; ++i) {
373 std::string result = indentation +
"Player brain:\n";
382 result += indentation +
"- Screen Position X Offset: '" +
Recoded::myToString(_screenPosXOffset) +
"'\n";
383 result += indentation +
"- Screen Position Y Offset: '" +
Recoded::myToString(_screenPosYOffset) +
"'\n";
384 result += indentation +
"- Active Enemies: '" +
Recoded::myToString(_activeEnemies) +
"'\n";
386 result += indentation +
"- Remaining enemies (has value): '" +
Recoded::myToString(_remainingEnemies.has_value()) +
"'\n";
387 if (_remainingEnemies.has_value()) {
388 result += indentation +
"- Remaining enemies: {\n" + _remainingEnemies.value()->getInfo(indent + 1) + indentation +
"}\n";
390 result += indentation +
"- background item (has value): '" +
Recoded::myToString(_backgroundItem.has_value()) +
"'\n";
391 if (_backgroundItem.has_value()) {
392 result += indentation +
"- background item: {\n" + _backgroundItem.value()->getInfo(indent + 1) + indentation +
"}\n";
394 result += indentation +
"- Sprite Bullet: {\n" + _spriteBullet->getInfo(indent + 1) + indentation +
"}\n";
395 result += indentation +
"- Sprite Bullet Enemy: {\n" + _spriteBulletEnemy->getInfo(indent + 1) + indentation +
"}\n";
396 result += indentation +
"- Sprite Player: {\n" + _spritePlayer->getInfo(indent + 1) + indentation +
"}\n";
397 result += indentation +
"- Sprite Enemy: {\n" + _spriteEnemy->getInfo(indent + 1) + indentation +
"}\n";
398 result += indentation +
"- Enemy Bullets: {\n";
399 for (
unsigned int index = 0; index < _enemyBullets.size(); index++) {
401 result += _enemyBullets[index].getInfo(indent + 2);
402 result += indentation +
"\t}\n";
404 result += indentation +
"}\n";
405 result += indentation +
"- Window: {\n" + _window->getInfo(indent + 1) + indentation +
"}\n";
406 result += indentation +
"- Event: {\n" + _event->getInfo(indent + 1) + indentation +
"}\n";
407 result += indentation +
"- Player Bullets: {\n";
408 for (
unsigned int index = 0; index < _playerBullets.size(); index++) {
410 result += _playerBullets[index].getInfo(indent + 2);
411 result += indentation +
"\t}\n";
413 result += indentation +
"}\n";
414 result += indentation +
"- Player Brains: {\n";
415 for (
unsigned int index = 0; index < _playerBrain.size(); index++) {
417 result += _playerBrain[index]->getInfo(indent + 2);
418 result += indentation +
"\t}\n";
420 result += indentation +
"}\n";
421 result += indentation +
"- Enemy Brains: {\n";
422 for (
unsigned int index = 0; index < _enemyBrain.size(); index++) {
424 result += _enemyBrain[index]->getInfo(indent + 2);
425 result += indentation +
"\t}\n";
427 result += indentation +
"}\n";
433void GUI::ECS::Online::Orchestrator::_spawn(
const std::uint32_t
id,
const std::pair<float, float> &pos)
435 PRETTY_DEBUG <<
"In _spawn function in charge of creating the user" << std::endl;
436 if (_spritePlayer ==
nullptr) {
437 PRETTY_ERROR <<
"The _spritePlayer is set to nullptr" << std::endl;
440 if (_spriteBullet ==
nullptr) {
441 PRETTY_ERROR <<
"The _spriteBullet is set to nullptr" << std::endl;
444 PRETTY_DEBUG <<
"The _playerBrain shared pointer is going to be created" << std::endl;
445 std::shared_ptr<GUI::ECS::Online::PlayerBrain> playerEntity = std::make_shared<GUI::ECS::Online::PlayerBrain>(
id);
446 PRETTY_DEBUG <<
"The playerEntity shared pointer has been created" << std::endl;
447 playerEntity->setSprite(_spritePlayer, _spriteBullet);
448 PRETTY_DEBUG <<
"The playerEntity has been set with the sprites of bullet and player" << std::endl;
449 playerEntity->setDimension({ 2,2 });
450 playerEntity->setPosition(pos);
451 playerEntity->setBulletSize({ 0.5,0.5 });
452 _playerBrain.push_back(playerEntity);
456void GUI::ECS::Online::Orchestrator::_spawnFriendBullet(
const std::uint32_t
id,
const std::pair<float, float> &pos)
458 PRETTY_DEBUG <<
"In _spawnFriendBullet function in charge of creating the user" << std::endl;
459 if (_spriteBullet ==
nullptr) {
460 PRETTY_ERROR <<
"The _spriteBullet is set to nullptr" << std::endl;
463 PRETTY_DEBUG <<
"The _spawnFriendBullet shared pointer is going to be created" << std::endl;
464 const bool fromEnemy =
false;
466 bullet.setSprite(*_spriteBullet);
467 bullet.setEnemy(fromEnemy);
468 bullet.setPosition(pos);
470 bullet.setDirection({ 1,0 });
472 _playerBullets.push_back(bullet);
476void GUI::ECS::Online::Orchestrator::_spawnEnemyBullet(
const std::uint32_t
id,
const std::pair<float, float> &pos)
478 PRETTY_DEBUG <<
"In _spawnEnemyBullet function in charge of creating the user" << std::endl;
479 if (_spriteBullet ==
nullptr) {
480 PRETTY_ERROR <<
"The _spriteBullet is set to nullptr" << std::endl;
483 PRETTY_DEBUG <<
"The _spawnEnemyBullet shared pointer is going to be created" << std::endl;
484 const bool fromEnemy =
true;
486 bullet.setSprite(*_spriteBullet);
487 bullet.setEnemy(fromEnemy);
488 bullet.setPosition(pos);
490 bullet.setDirection({ 1,0 });
492 _enemyBullets.push_back(bullet);
497void GUI::ECS::Online::Orchestrator::_setPosition(
const std::uint32_t
id,
const std::pair<float, float> &pos)
500 std::size_t entityIndex = -1;
501 for (std::size_t i = 0; i < _playerBrain.size(); i++) {
502 if (_playerBrain[i]->getEntityNodeId() ==
id) {
508 if (entityIndex != -1) {
510 _playerBrain[entityIndex]->setPosition(pos);
515 for (std::size_t i = 0; i < _enemyBrain.size(); i++) {
516 if (_enemyBrain[i]->getEntityNodeId() ==
id) {
522 if (entityIndex != -1) {
524 _enemyBrain[entityIndex]->setPosition(pos);
529 for (std::size_t i = 0; i < _playerBullets.size(); i++) {
530 if (_playerBullets[i].getEntityNodeId() ==
id) {
536 if (entityIndex != -1) {
538 _playerBullets[entityIndex].setPosition(pos);
543 for (std::size_t i = 0; i < _enemyBullets.size(); i++) {
544 if (_enemyBullets[i].getEntityNodeId() ==
id) {
550 if (entityIndex != -1) {
552 _enemyBullets[entityIndex].setPosition(pos);
558void GUI::ECS::Online::Orchestrator::_killEntity(
const std::uint32_t
id)
561 std::size_t entityIndex = -1;
562 for (std::size_t i = 0; i < _playerBrain.size(); i++) {
563 if (_playerBrain[i]->getEntityNodeId() ==
id) {
569 if (entityIndex != -1) {
571 _playerBrain.erase(_playerBrain.begin() + entityIndex);
576 for (std::size_t i = 0; i < _enemyBrain.size(); i++) {
577 if (_enemyBrain[i]->getEntityNodeId() ==
id) {
583 if (entityIndex != -1) {
585 _enemyBrain.erase(_enemyBrain.begin() + entityIndex);
591 for (std::size_t i = 0; i < _playerBullets.size(); i++) {
592 if (_playerBullets[i].getEntityNodeId() ==
id) {
598 if (entityIndex != -1) {
600 _playerBullets.erase(_playerBullets.begin() + entityIndex);
605 for (std::size_t i = 0; i < _enemyBullets.size(); i++) {
606 if (_enemyBullets[i].getEntityNodeId() ==
id) {
612 if (entityIndex != -1) {
614 _enemyBullets.erase(_enemyBullets.begin() + entityIndex);
622 if (!_network.has_value()) {
623 PRETTY_CRITICAL <<
"There is no network manager to use to send packets" << std::endl;
627 _network.value()->sendMessage(node);
630void GUI::ECS::Online::Orchestrator::_kill()
632 PRETTY_DEBUG <<
"The _kill function has been called" << std::endl;
633 for (
unsigned int index = 0; index < _playerBrain.size(); index++) {
634 PRETTY_DEBUG <<
"Resetting players: " << index << std::endl;
635 _playerBrain[index].reset();
637 _playerBrain.clear();
638 for (
unsigned int index = 0; index < _enemyBrain.size(); index++) {
639 PRETTY_DEBUG <<
"Resetting enemy: " << index << std::endl;
640 _enemyBrain[index].reset();
645 PRETTY_DEBUG <<
"Enemies cleared, size: " << _enemyBrain.size() << std::endl;
646 PRETTY_DEBUG <<
"Clearing remaining bullets" << std::endl;
647 unsigned int bIndex = 0;
648 while (_playerBullets.size() > 0) {
649 PRETTY_DEBUG <<
"Removing bullet: " << bIndex <<
", bullet enemy: " <<
Recoded::myToString(_playerBullets[_playerBullets.size() - 1].isEnemy()) << std::endl;
650 _playerBullets.pop_back();
653 PRETTY_DEBUG <<
"Removed the player bullets" << std::endl;
655 while (_enemyBullets.size() > 0) {
656 PRETTY_DEBUG <<
"Removing bullet: " << bIndex <<
", bullet enemy: " <<
Recoded::myToString(_enemyBullets[_enemyBullets.size() - 1].isEnemy()) << std::endl;
657 _enemyBullets.pop_back();
660 PRETTY_DEBUG <<
"Removed the enemy bullets" << std::endl;
661 PRETTY_DEBUG <<
"A the end of the kill function" << std::endl;
664void GUI::ECS::Online::Orchestrator::_spawnEnemy(
const std::uint32_t
id, std::pair<float, float> pos)
667 if (_spriteEnemy ==
nullptr) {
668 PRETTY_ERROR <<
"The _spriteEnemy is set to nullptr" << std::endl;
671 if (_spriteBulletEnemy ==
nullptr) {
672 PRETTY_ERROR <<
"The _spriteBulletEnemy is set to nullptr" << std::endl;
675 PRETTY_DEBUG <<
"The _enemyBrain shared pointer is going to be created" << std::endl;
676 std::shared_ptr<GUI::ECS::Online::EnemyBrain> enemy = std::make_shared<GUI::ECS::Online::EnemyBrain>(
id);
677 PRETTY_DEBUG <<
"The _enemyBrain shared pointer has been created" << std::endl;
678 enemy->setSprite(_spriteEnemy, _spriteBulletEnemy);
679 PRETTY_DEBUG <<
"The sprite enemy and sprite bullet enemy has been set" << std::endl;
680 enemy->setPosition(pos);
681 PRETTY_DEBUG <<
"The enemy has been set with the position: " << pos << std::endl;
682 enemy->setVisible(
true);
683 enemy->setDimension({ 4,4 });
684 enemy->setBulletSize({ 0.5, 0.5 });
686 _enemyBrain.push_back(enemy);
688 PRETTY_DEBUG <<
"The enemy has been added to the _enemyBrain" << std::endl;
691const int GUI::ECS::Online::Orchestrator::_randInt(
int min,
int max)
693 static std::random_device
rd;
694 static std::mt19937 gen(
rd());
695 std::uniform_int_distribution<> dist(min, max);
699void GUI::ECS::Online::Orchestrator::_setTheScene()
701 PRETTY_DEBUG <<
"Resetting the victory and loss variables" << std::endl;
704 PRETTY_DEBUG <<
"Reset the victory and loss variables" << std::endl;
705 PRETTY_DEBUG <<
"Resetting the position of the items on screen" << std::endl;
706 std::pair<float, float> pos = { 1,1 };
707 _spriteBullet->setPosition(pos);
708 _spriteBulletEnemy->setPosition(pos);
709 _spriteEnemy->setPosition(pos);
710 _spritePlayer->setPosition(pos);
711 PRETTY_DEBUG <<
"Reset the position of the items on screen" << std::endl;
713 PRETTY_DEBUG <<
"The enemies have been spawned" << std::endl;
716void GUI::ECS::Online::Orchestrator::_setTextComponents()
719 PRETTY_DEBUG <<
"Setting the health value of the player" << std::endl;
722 PRETTY_DEBUG <<
"Declaring font holder instances" << std::endl;
723 std::optional<std::shared_ptr<GUI::ECS::Systems::Font>> defaultFont;
724 std::optional<std::shared_ptr<GUI::ECS::Systems::Font>> titleFont;
725 std::optional<std::shared_ptr<GUI::ECS::Systems::Font>> bodyFont;
726 std::optional<std::shared_ptr<GUI::ECS::Systems::Font>> buttonFont;
727 PRETTY_DEBUG <<
"Declared font holder instances" << std::endl;
728 PRETTY_DEBUG <<
"Fetching the fonts that will be used in the window" << std::endl;
729 unsigned int index = 0;
730 unsigned int titleFontIndex = 0;
731 unsigned int bodyFontIndex = 0;
732 unsigned int defaultFontIndex = 0;
733 unsigned int buttonFontIndex = 0;
734 for (std::any fontCast : fonts) {
736 if (!fontCapsule.has_value()) {
739 std::string applicationContext = fontCapsule.value()->getApplication();
740 if (applicationContext ==
"title") {
741 titleFontIndex = index;
742 }
else if (applicationContext ==
"body") {
743 bodyFontIndex = index;
744 }
else if (applicationContext ==
"default") {
745 defaultFontIndex = index;
746 }
else if (applicationContext ==
"button") {
747 buttonFontIndex = index;
758 if (!defaultFontCapsule.has_value()) {
759 PRETTY_DEBUG <<
"No default font found, aborting program" << std::endl;
762 defaultFont.emplace(defaultFontCapsule.value());
763 titleFont.emplace(defaultFontCapsule.value());
764 bodyFont.emplace(defaultFontCapsule.value());
765 buttonFont.emplace(defaultFontCapsule.value());
766 if (titleFontCapsule.has_value()) {
767 PRETTY_SUCCESS <<
"Title font found, not defaulting to the default font." << std::endl;
768 titleFont.emplace(titleFontCapsule.value());
770 if (bodyFontCapsule.has_value()) {
771 PRETTY_SUCCESS <<
"Body font found, not defaulting to the default font." << std::endl;
772 bodyFont.emplace(bodyFontCapsule.value());
774 if (buttonFontCapsule.has_value()) {
775 PRETTY_SUCCESS <<
"Button font found, not defaulting to the default font." << std::endl;
776 buttonFont.emplace(buttonFontCapsule.value());
778 PRETTY_DEBUG <<
"Fetched the fonts that will be used in the window" << std::endl;
779 PRETTY_DEBUG <<
"Creating the text to display the user's health" << std::endl;
780 const unsigned int size = 20;
781 const std::pair<float, float> posEnnemies = { 10, 40 };
782 std::shared_ptr<GUI::ECS::Components::TextComponent> textEnnemies = std::make_shared<GUI::ECS::Components::TextComponent>(
785 "Remaining ennemies: ",
792 _remainingEnemies.emplace(textEnnemies);
806void GUI::ECS::Online::Orchestrator::_shootSound()
808 if (_ecsEntities[
typeid(
SoundLib)].size() == 0) {
809 PRETTY_WARNING <<
"Skipping audio playing because the sound library is missing" << std::endl;
813 if (!soundLib.has_value()) {
814 PRETTY_WARNING <<
"The library to find the found player is missing, skipping sound" << std::endl;
817 soundLib.value()->shootSound();
828void GUI::ECS::Online::Orchestrator::_damageSound()
830 if (_ecsEntities[
typeid(
SoundLib)].size() == 0) {
831 PRETTY_WARNING <<
"Skipping audio playing because the sound library is missing" << std::endl;
835 if (!soundLib.has_value()) {
836 PRETTY_WARNING <<
"The library to find the found player is missing, skipping sound" << std::endl;
839 soundLib.value()->damageSound();
850void GUI::ECS::Online::Orchestrator::_deadSound()
852 if (_ecsEntities[
typeid(
SoundLib)].size() == 0) {
853 PRETTY_WARNING <<
"Skipping audio playing because the sound library is missing" << std::endl;
857 if (!soundLib.has_value()) {
858 PRETTY_WARNING <<
"The library to find the found player is missing, skipping sound" << std::endl;
861 soundLib.value()->deadSound();
872void GUI::ECS::Online::Orchestrator::_buttonSound()
874 if (_ecsEntities[
typeid(
SoundLib)].size() == 0) {
875 PRETTY_WARNING <<
"Skipping audio playing because the sound library is missing" << std::endl;
879 if (!soundLib.has_value()) {
880 PRETTY_WARNING <<
"The library to find the found player is missing, skipping sound" << std::endl;
883 soundLib.value()->buttonSound();
894void GUI::ECS::Online::Orchestrator::_gameOverSound()
896 if (_ecsEntities[
typeid(
SoundLib)].size() == 0) {
897 PRETTY_WARNING <<
"Skipping audio playing because the sound library is missing" << std::endl;
901 if (!soundLib.has_value()) {
902 PRETTY_WARNING <<
"The library to find the found player is missing, skipping sound" << std::endl;
905 soundLib.value()->gameOverSound();
916void GUI::ECS::Online::Orchestrator::_winSound()
918 if (_ecsEntities[
typeid(
SoundLib)].size() == 0) {
919 PRETTY_WARNING <<
"Skipping audio playing because the sound library is missing" << std::endl;
923 if (!soundLib.has_value()) {
924 PRETTY_WARNING <<
"The library to find the found player is missing, skipping sound" << std::endl;
927 soundLib.value()->winSound();
#define PRETTY_ERROR
Error log with details and colour.
#define PRECISE_DEBUG
Debug log with precise details.
#define PRETTY_DEBUG
Debug log with details and colour.
#define PRETTY_CRITICAL
Critical log with details and colour.
#define PRETTY_WARNING
Warning log with details and colour.
#define PRETTY_SUCCESS
Success log with details and colour.
Declaration of the Orchestrator class and its related functionality.
This is the class in charge of informing the user that they tried to access a non-existant Event Mana...
This is the class in charge of informing the user that they tried to access a non-existant font insta...
This is the class in charge of informing the user that the program could not find any network class i...
This is the class in charge of informing the user that they tried to access a non-existant animation ...
This is the class in charge of informing the user that they tried to access a non-existant window.
Represents an image component in the GUI ECS system.
Represents a drawable and interactive sprite in the ECS system.
Represents a bullet entity in the game.
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.
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)
Manages input events such as mouse movements, key presses, and window interactions.
Manages font entities in the GUI ECS.
Manages an SFML-based graphical window and handles rendering of ECS components.
The SoundLib class manages sound effects and interactions with ECS entities.
std::ostream & operator<<(std::ostream &os, const Bullet &item)
Outputs the sprite's info to a stream.
const std::string myToString(const Rect< RectType > &rectangle)
Converts a Rect<T> object to its string representation.
std::optional< T > unCast(const std::any &classNode, const bool raiseOnError=true, const std::string customErrorMessage="")
Casts the content of a std::any back to its original type.