From 1e0cb31ec62a5895c475a52c4e0066672047416f Mon Sep 17 00:00:00 2001 From: Aki Date: Sat, 31 Dec 2022 22:50:55 +0100 Subject: Extracted method to deal damage to hit points --- sim/src/HitPoints.cpp | 18 ++++++++++++++++++ sim/src/TurretControl.cpp | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 sim/src/HitPoints.cpp (limited to 'sim/src') diff --git a/sim/src/HitPoints.cpp b/sim/src/HitPoints.cpp new file mode 100644 index 0000000..4f2ff81 --- /dev/null +++ b/sim/src/HitPoints.cpp @@ -0,0 +1,18 @@ +#include + + +namespace kurator +{ +namespace sim +{ + + +void +HitPoints::deal(double damage) +{ + health -= damage; +} + + +} // namespace sim +} // namespace kurator diff --git a/sim/src/TurretControl.cpp b/sim/src/TurretControl.cpp index 56083f1..6513f39 100644 --- a/sim/src/TurretControl.cpp +++ b/sim/src/TurretControl.cpp @@ -44,7 +44,7 @@ TurretControl::update(entt::registry& registry, entt::dispatcher& dispatcher, co auto& target_points = registry.get(state.target); const auto damage = def.effective_damage(distance); if (damage > 0.0) { - target_points.health -= damage; + target_points.deal(damage); dispatcher.trigger(Hit{damage, control.owner, state.target}); } control.delay = def.rate_of_fire; -- cgit v1.1