mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
@@ -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
|
||||
/// <summary>
|
||||
/// Returns the smallest rectangle that contains both of the rectangles.
|
||||
/// </summary>
|
||||
[Pure]
|
||||
public readonly Box2i Union(in Box2i other)
|
||||
{
|
||||
var botLeft = Vector2i.ComponentMin(BottomLeft, other.BottomLeft);
|
||||
@@ -207,6 +209,7 @@ namespace Robust.Shared.Maths
|
||||
/// <summary>
|
||||
/// Multiplies each side of the box by the scalar.
|
||||
/// </summary>
|
||||
[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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user