From 30865a57fb3f52607c14b9d210a256b3be3ddcb8 Mon Sep 17 00:00:00 2001 From: Aki Date: Sun, 8 Jan 2023 00:53:34 +0100 Subject: Extracted total retrieval to health points to enable modification of components --- kurator/src/ForceBalance.cpp | 4 ++-- sim/include/kurator/sim/HitPoints.h | 1 + sim/src/HitPoints.cpp | 7 +++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/kurator/src/ForceBalance.cpp b/kurator/src/ForceBalance.cpp index 4f86379..7cfffbe 100644 --- a/kurator/src/ForceBalance.cpp +++ b/kurator/src/ForceBalance.cpp @@ -22,8 +22,8 @@ ForceBalance::update(const entt::registry& registry) for (const auto& [entity, points, team] : points.each()) { while (teams.size() <= static_cast(team.id)) teams.emplace_back(0.0); - total += points.health; - teams[team.id] += points.health; + total += points.total(); + teams[team.id] += points.total(); } } diff --git a/sim/include/kurator/sim/HitPoints.h b/sim/include/kurator/sim/HitPoints.h index 8930e3a..96b54b0 100644 --- a/sim/include/kurator/sim/HitPoints.h +++ b/sim/include/kurator/sim/HitPoints.h @@ -12,6 +12,7 @@ struct HitPoints double health; void deal(double damage); bool is_alive() const; + double total() const; }; diff --git a/sim/src/HitPoints.cpp b/sim/src/HitPoints.cpp index da980f1..28cf7f7 100644 --- a/sim/src/HitPoints.cpp +++ b/sim/src/HitPoints.cpp @@ -21,5 +21,12 @@ HitPoints::is_alive() const } +double +HitPoints::total() const +{ + return health; +} + + } // namespace sim } // namespace kurator -- cgit v1.1