From d93e1fdf076fcac3f11f7c7c433b5c3f7ab8bf53 Mon Sep 17 00:00:00 2001 From: Juliano Leal Goncalves Date: Sat, 5 Jun 2021 21:52:48 -0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20'Contains'=20function=20for?= =?UTF-8?q?=20'Rectangle'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will be useful for various bound checks throughout the code. --- Source/engine/rectangle.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Source/engine/rectangle.hpp b/Source/engine/rectangle.hpp index 0a6363097..1d0756492 100644 --- a/Source/engine/rectangle.hpp +++ b/Source/engine/rectangle.hpp @@ -8,6 +8,14 @@ namespace devilution { struct Rectangle { Point position; Size size; + + constexpr bool Contains(Point point) const + { + return point.x >= this->position.x + && point.x <= (this->position.x + this->size.width) + && point.y >= this->position.y + && point.y <= (this->position.y + this->size.height); + } }; } // namespace devilution