diff options
author | Aki <please@ignore.pl> | 2022-12-31 22:50:55 +0100 |
---|---|---|
committer | Aki <please@ignore.pl> | 2022-12-31 22:50:55 +0100 |
commit | 1e0cb31ec62a5895c475a52c4e0066672047416f (patch) | |
tree | 042f74b68d31bbf06d8cf0610c4a7ec69197f460 /sim | |
parent | 7c34183e2697356c603328b006415247d280455b (diff) | |
download | kurator-1e0cb31ec62a5895c475a52c4e0066672047416f.zip kurator-1e0cb31ec62a5895c475a52c4e0066672047416f.tar.gz kurator-1e0cb31ec62a5895c475a52c4e0066672047416f.tar.bz2 |
Extracted method to deal damage to hit points
Diffstat (limited to 'sim')
-rw-r--r-- | sim/CMakeLists.txt | 1 | ||||
-rw-r--r-- | sim/include/kurator/sim/HitPoints.h | 1 | ||||
-rw-r--r-- | sim/src/HitPoints.cpp | 18 | ||||
-rw-r--r-- | sim/src/TurretControl.cpp | 2 |
4 files changed, 21 insertions, 1 deletions
diff --git a/sim/CMakeLists.txt b/sim/CMakeLists.txt index e10056a..b8c3a89 100644 --- a/sim/CMakeLists.txt +++ b/sim/CMakeLists.txt @@ -5,6 +5,7 @@ add_library( src/Battle.cpp src/Builder.cpp src/FloatingMovement.cpp + src/HitPoints.cpp src/Point.cpp src/RandomSpawner.cpp src/TeamManager.cpp diff --git a/sim/include/kurator/sim/HitPoints.h b/sim/include/kurator/sim/HitPoints.h index 20cffc2..feda050 100644 --- a/sim/include/kurator/sim/HitPoints.h +++ b/sim/include/kurator/sim/HitPoints.h @@ -10,6 +10,7 @@ namespace sim struct HitPoints { double health; + void deal(double damage); }; 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 <kurator/sim/HitPoints.h> + + +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<HitPoints>(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; |