diff --git a/sources/Models/GameState.hpp b/sources/Models/GameState.hpp index cc521c00..da17fdc1 100644 --- a/sources/Models/GameState.hpp +++ b/sources/Models/GameState.hpp @@ -26,7 +26,7 @@ namespace BBM LobbyScene, TitleScreenScene, CreditScene, - ScoreScene = MainMenuScene, + ScoreScene, }; diff --git a/sources/Runner/Runner.cpp b/sources/Runner/Runner.cpp index 6af5e04c..312d1213 100644 --- a/sources/Runner/Runner.cpp +++ b/sources/Runner/Runner.cpp @@ -34,6 +34,7 @@ #include "System/BumperTimer/BumperTimerSystem.hpp" #include "System/Music/MusicSystem.hpp" #include "System/Lobby/LobbySystem.hpp" +#include "System/EndCondition/EndConditionSystem.hpp" #include "Component/Lobby/LobbyComponent.hpp" namespace BBM @@ -58,6 +59,8 @@ namespace BBM } if (gameState.nextScene == gameState.currentScene) return; + if (gameState.nextScene == GameState::SceneID::ScoreScene) + gameState._loadedScenes[GameState::SceneID::ScoreScene] = Runner::loadScoreScene(*engine.getScene()); gameState._loadedScenes[gameState.currentScene] = engine.getScene(); engine.changeScene(gameState._loadedScenes[gameState.nextScene]); gameState.currentScene = gameState.nextScene; @@ -84,6 +87,7 @@ namespace BBM .addSystem() .addSystem() .addSystem() + .addSystem() .addSystem(); } diff --git a/sources/Runner/ScoreScene.cpp b/sources/Runner/ScoreScene.cpp index b65176c1..90368250 100644 --- a/sources/Runner/ScoreScene.cpp +++ b/sources/Runner/ScoreScene.cpp @@ -20,7 +20,8 @@ namespace BBM {SoundComponent::JUMP, "assets/sounds/click.ogg"} }; - scene->addEntity("Control entity") + addMenuControl(*scene); + scene->addEntity("Audio ressources") .addComponent("assets/musics/music_result.ogg") .addComponent(sounds); scene->addEntity("background") diff --git a/sources/System/EndCondition/EndConditionSystem.cpp b/sources/System/EndCondition/EndConditionSystem.cpp index 655322d3..0403d3a1 100644 --- a/sources/System/EndCondition/EndConditionSystem.cpp +++ b/sources/System/EndCondition/EndConditionSystem.cpp @@ -2,6 +2,7 @@ #include "EndConditionSystem.hpp" #include #include "Runner/Runner.hpp" +#include "Component/Score/ScoreComponent.hpp" namespace BBM { @@ -12,8 +13,11 @@ namespace BBM { void EndConditionSystem::onSelfUpdate() { unsigned int alivePlayersCount = 0; + auto &view = this->_wal.getScene()->view(); - for (auto & [_ , healthComponent]: this->_wal.getScene()->view()) + if (!view.size()) + return; + for (auto & [_ , scoreComponent, healthComponent]: view) alivePlayersCount += (healthComponent.getHealthPoint() != 0); if (alivePlayersCount <= 1) Runner::gameState.nextScene = Runner::gameState.ScoreScene;