mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-06-11 04:48:33 +00:00
25 lines
663 B
C++
25 lines
663 B
C++
|
|
#include "EndConditionSystem.hpp"
|
|
#include <map>
|
|
#include "Runner/Runner.hpp"
|
|
#include "Component/Score/ScoreComponent.hpp"
|
|
|
|
namespace BBM {
|
|
|
|
EndConditionSystem::EndConditionSystem(WAL::Wal &wal)
|
|
: System(wal)
|
|
{}
|
|
|
|
void EndConditionSystem::onSelfUpdate()
|
|
{
|
|
unsigned int alivePlayersCount = 0;
|
|
auto &view = this->_wal.getScene()->view<ScoreComponent, HealthComponent>();
|
|
|
|
if (!view.size())
|
|
return;
|
|
for (auto & [_ , scoreComponent, healthComponent]: view)
|
|
alivePlayersCount += (healthComponent.getHealthPoint() != 0);
|
|
if (alivePlayersCount <= 1)
|
|
Runner::gameState.nextScene = Runner::gameState.ScoreScene;
|
|
}
|
|
} |