Added overlap detection against rectangles and points.
This commit is contained in:
		@@ -1,4 +1,5 @@
 | 
			
		||||
using System.Drawing;
 | 
			
		||||
using System.Numerics;
 | 
			
		||||
 | 
			
		||||
namespace SlatedGameToolkit.Framework.Utilities
 | 
			
		||||
{
 | 
			
		||||
@@ -12,5 +13,21 @@ namespace SlatedGameToolkit.Framework.Utilities
 | 
			
		||||
            rect.Height *= multiplier;
 | 
			
		||||
            return rect;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static bool IsOverlapping(this RectangleF a, RectangleF b) {
 | 
			
		||||
            if (a.Left > b.Right) return false;
 | 
			
		||||
            if (a.Right < b.Left) return false;
 | 
			
		||||
            if (a.Bottom > b.Top) return false;
 | 
			
		||||
            if (a.Top < b.Bottom) return false;
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static bool IsWithin(this RectangleF rect, Vector2 vector) {
 | 
			
		||||
            if (vector.X > rect.Right) return false;
 | 
			
		||||
            if (vector.X < rect.Left) return false;
 | 
			
		||||
            if (vector.Y > rect.Top) return false;
 | 
			
		||||
            if (vector.Y < rect.Bottom) return false;
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user