diff --git a/Robust.Shared.Maths/Box2i.cs b/Robust.Shared.Maths/Box2i.cs
index 4c1944d50..f0596ed57 100644
--- a/Robust.Shared.Maths/Box2i.cs
+++ b/Robust.Shared.Maths/Box2i.cs
@@ -1,4 +1,5 @@
using System;
+using System.Diagnostics.Contracts;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -101,6 +102,7 @@ namespace Robust.Shared.Maths
///
/// Returns the smallest rectangle that contains both of the rectangles.
///
+ [Pure]
public readonly Box2i Union(in Box2i other)
{
var botLeft = Vector2i.ComponentMin(BottomLeft, other.BottomLeft);
@@ -207,6 +209,7 @@ namespace Robust.Shared.Maths
///
/// Multiplies each side of the box by the scalar.
///
+ [Pure]
public Box2i Scale(int scalar)
{
return new Box2i(
@@ -215,6 +218,21 @@ namespace Robust.Shared.Maths
Right * scalar,
Top * scalar);
}
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ [Pure]
+ public bool Intersects(in Box2i other)
+ {
+ return other.Bottom <= this.Top && other.Top >= this.Bottom && other.Right >= this.Left &&
+ other.Left <= this.Right;
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ [Pure]
+ public readonly Box2i Enlarged(int size)
+ {
+ return new(Left - size, Bottom - size, Right + size, Top + size);
+ }
}
///