1
0
Fork 0

[server] Implement Rectangle.Overlap()

This commit is contained in:
Starbeamrainbowlabs 2017-03-20 19:47:33 +00:00
parent e193220846
commit 22a03d9ab9
2 changed files with 20 additions and 1 deletions

View File

@ -237,9 +237,12 @@ namespace Nibriboard.Client
/// <returns>Whether this client can see the chunk located at the specified chunk reference</returns>
public bool CanSee(ChunkReference chunkRef)
{
LocationReference chunkLocation = chunkRef.InPlanespace();
if(chunkRef.Plane != CurrentPlane)
return false;
Rectangle chunkArea = chunkRef.InPlanespaceRectangle();
return chunkArea.Overlap(CurrentViewPort);
}
#region Message Handlers

View File

@ -119,6 +119,22 @@ namespace SBRL.Utilities
Width = width;
Height = height;
}
/// <summary>
/// Figures out whether this rectangle overlaps another rectangle.
/// </summary>
/// <param name="otherRectangle">The other rectangle to check the overlap of.</param>
/// <returns>Whether this rectangle overlaps another rectangle.</returns>
public bool Overlap(Rectangle otherRectangle)
{
if(Top > otherRectangle.Bottom &&
Bottom < otherRectangle.Top &&
Left > otherRectangle.Right &&
Right < otherRectangle.Left)
return false;
return true;
}
}
}