diff --git a/Source/engine/rectangle.hpp b/Source/engine/rectangle.hpp index 0dcc5b312..7a4c46f6d 100644 --- a/Source/engine/rectangle.hpp +++ b/Source/engine/rectangle.hpp @@ -16,6 +16,14 @@ struct Rectangle { && point.y >= this->position.y && point.y < (this->position.y + this->size.height); } + + /** + * @brief Computes the center of this rectangle in integer coordinates. Values are truncated towards zero. + */ + constexpr Point Center() const + { + return position + Displacement(size / 2); + } }; } // namespace devilution