summaryrefslogtreecommitdiff
path: root/sim
diff options
context:
space:
mode:
Diffstat (limited to 'sim')
-rw-r--r--sim/include/kurator/sim/HitPoints.h1
-rw-r--r--sim/src/BaseBattle.cpp2
-rw-r--r--sim/src/HitPoints.cpp7
3 files changed, 9 insertions, 1 deletions
diff --git a/sim/include/kurator/sim/HitPoints.h b/sim/include/kurator/sim/HitPoints.h
index feda050..8930e3a 100644
--- a/sim/include/kurator/sim/HitPoints.h
+++ b/sim/include/kurator/sim/HitPoints.h
@@ -11,6 +11,7 @@ struct HitPoints
{
double health;
void deal(double damage);
+ bool is_alive() const;
};
diff --git a/sim/src/BaseBattle.cpp b/sim/src/BaseBattle.cpp
index 224c16c..f195181 100644
--- a/sim/src/BaseBattle.cpp
+++ b/sim/src/BaseBattle.cpp
@@ -103,7 +103,7 @@ BaseBattle::kill_off_dead()
{
auto view = _registry.view<HitPoints>();
for (auto&& [entity, points] : view.each()) {
- if (points.health > 0.0)
+ if (points.is_alive())
continue;
if (_registry.all_of<universe::UniqueIdentifier, Team>(entity)) {
const auto& [identifier, team] = _registry.get<universe::UniqueIdentifier, Team>(entity);
diff --git a/sim/src/HitPoints.cpp b/sim/src/HitPoints.cpp
index 4f2ff81..da980f1 100644
--- a/sim/src/HitPoints.cpp
+++ b/sim/src/HitPoints.cpp
@@ -14,5 +14,12 @@ HitPoints::deal(double damage)
}
+bool
+HitPoints::is_alive() const
+{
+ return health > 0.0;
+}
+
+
} // namespace sim
} // namespace kurator