mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-05-25 07:34:01 +00:00
33 lines
870 B
C++
33 lines
870 B
C++
|
|
#include "EndConditionSystem.hpp"
|
|
#include <map>
|
|
#include <System/Renderer/CameraSystem.hpp>
|
|
#include "Runner/Runner.hpp"
|
|
#include "Component/Score/ScoreComponent.hpp"
|
|
|
|
namespace BBM
|
|
{
|
|
|
|
EndConditionSystem::EndConditionSystem(WAL::Wal &wal)
|
|
: System(wal)
|
|
{}
|
|
|
|
void EndConditionSystem::onSelfUpdate(std::chrono::nanoseconds dtime)
|
|
{
|
|
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) {
|
|
endConditionRate -= dtime;
|
|
if (endConditionRate <= 0ns) {
|
|
this->_wal.getSystem<CameraSystem>().hasEnded = false;
|
|
Runner::gameState.nextScene = Runner::gameState.ScoreScene;
|
|
endConditionRate = 500ms;
|
|
}
|
|
}
|
|
}
|
|
} |