diff options
Diffstat (limited to 'universe')
-rw-r--r-- | universe/CMakeLists.txt | 1 | ||||
-rw-r--r-- | universe/include/kurator/universe/TurretType.h | 1 | ||||
-rw-r--r-- | universe/src/TurretType.cpp | 23 |
3 files changed, 25 insertions, 0 deletions
diff --git a/universe/CMakeLists.txt b/universe/CMakeLists.txt index bb7253f..daf55bc 100644 --- a/universe/CMakeLists.txt +++ b/universe/CMakeLists.txt @@ -3,6 +3,7 @@ add_library( ${PROJECT_NAME} src/NotFound.cpp src/SampleRepository.cpp + src/TurretType.cpp src/universe.cpp ) target_include_directories( diff --git a/universe/include/kurator/universe/TurretType.h b/universe/include/kurator/universe/TurretType.h index 7723d88..ff67cfe 100644 --- a/universe/include/kurator/universe/TurretType.h +++ b/universe/include/kurator/universe/TurretType.h @@ -17,6 +17,7 @@ struct TurretType double optimal_range; double falloff_modifier; double falloff_intensity; + double effective_damage(double distance) const; }; diff --git a/universe/src/TurretType.cpp b/universe/src/TurretType.cpp new file mode 100644 index 0000000..d213d07 --- /dev/null +++ b/universe/src/TurretType.cpp @@ -0,0 +1,23 @@ +#include <kurator/universe/TurretType.h> + +#include <algorithm> +#include <cmath> + + +namespace kurator +{ +namespace universe +{ + + +double +TurretType::effective_damage(const double distance) const +{ + const auto overflow = distance - optimal_range; + const auto falloff = std::max(0.0, overflow / optimal_range / falloff_modifier); + return base_damage * std::round(std::pow(falloff_intensity, std::pow(falloff, 2)) * 1000) / 1000; +} + + +} // namespace universe +} // namespace kurator |