diff --git a/sources/Component/Score/ScoreComponent.cpp b/sources/Component/Score/ScoreComponent.cpp index a1e833a6..b54a835d 100644 --- a/sources/Component/Score/ScoreComponent.cpp +++ b/sources/Component/Score/ScoreComponent.cpp @@ -5,7 +5,7 @@ namespace BBM { ScoreComponent::ScoreComponent(WAL::Entity &entity) : Component(entity), - score(PLAYING) + aliveTime(std::chrono::nanoseconds::zero()) {} WAL::Component *ScoreComponent::clone(WAL::Entity &entity) const diff --git a/sources/Component/Score/ScoreComponent.hpp b/sources/Component/Score/ScoreComponent.hpp index d36c0a6f..15da0650 100644 --- a/sources/Component/Score/ScoreComponent.hpp +++ b/sources/Component/Score/ScoreComponent.hpp @@ -2,6 +2,7 @@ #pragma once #include "Component/Component.hpp" +#include namespace BBM { @@ -9,10 +10,8 @@ namespace BBM class ScoreComponent : public WAL::Component { public: - //! @brief score of player (4 is the looser, 1 is the winner) - enum Score {FIRST = 1, SECOND = 2, THIRD = 3, FOURTH = 4, PLAYING = -1}; //! @brief the score of the player - enum Score score; + std::chrono::nanoseconds aliveTime; //! @inherit WAL::Component *clone(WAL::Entity &entity) const override; diff --git a/sources/System/Score/ScoreSystem.cpp b/sources/System/Score/ScoreSystem.cpp index 02d21c23..4b32fda2 100644 --- a/sources/System/Score/ScoreSystem.cpp +++ b/sources/System/Score/ScoreSystem.cpp @@ -11,10 +11,9 @@ namespace BBM { : System(wal) {} - void ScoreSystem::onSelfUpdate() + void ScoreSystem::onUpdate(WAL::ViewEntity &entity, std::chrono::nanoseconds dtime) { - ScoreComponent::Score maxScore = ScoreComponent::Score::PLAYING; - - for (auto &[_, score, _], this->_wal.getScene()->view()) + if (entity.get().getHealthPoint()) + entity.get().aliveTime += dtime; } } \ No newline at end of file diff --git a/sources/System/Score/ScoreSystem.hpp b/sources/System/Score/ScoreSystem.hpp index 94d51ed6..33ad3c95 100644 --- a/sources/System/Score/ScoreSystem.hpp +++ b/sources/System/Score/ScoreSystem.hpp @@ -12,7 +12,7 @@ namespace BBM { public: //! @inherit - void onFixedUpdate(WAL::ViewEntity &entity) override; + void onUpdate(WAL::ViewEntity &entity, std::chrono::nanoseconds dtime) override; //! @brief ctor ScoreSystem(WAL::Wal &wal);