mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-05-27 00:06:49 +00:00
when there is only one player remaing, goes back
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
|
||||
#include "EndConditionSystem.hpp"
|
||||
#include <map>
|
||||
#include "Runner/Runner.hpp"
|
||||
|
||||
namespace BBM {
|
||||
|
||||
EndConditionSystem::EndConditionSystem(WAL::Wal &wal)
|
||||
: System(wal)
|
||||
{}
|
||||
|
||||
void EndConditionSystem::onSelfUpdate()
|
||||
{
|
||||
unsigned int alivePlayersCount = 0;
|
||||
|
||||
for (auto & [_ , healthComponent]: this->_wal.getScene()->view<HealthComponent>())
|
||||
alivePlayersCount += (healthComponent.getHealthPoint() != 0);
|
||||
if (alivePlayersCount <= 1)
|
||||
Runner::gameState.nextScene = Runner::gameState.MainMenuScene;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user