mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-06-04 02:36:31 +00:00
end condition: change scene only if scene has a player
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include "EndConditionSystem.hpp"
|
||||
#include <map>
|
||||
#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<ScoreComponent, HealthComponent>();
|
||||
|
||||
for (auto & [_ , healthComponent]: this->_wal.getScene()->view<HealthComponent>())
|
||||
if (!view.size())
|
||||
return;
|
||||
for (auto & [_ , scoreComponent, healthComponent]: view)
|
||||
alivePlayersCount += (healthComponent.getHealthPoint() != 0);
|
||||
if (alivePlayersCount <= 1)
|
||||
Runner::gameState.nextScene = Runner::gameState.ScoreScene;
|
||||
|
||||
Reference in New Issue
Block a user