mirror of
https://github.com/sbrl/Nibriboard.git
synced 2018-01-10 21:33:49 +00:00
[server] Implement Rectangle.Overlap()
This commit is contained in:
parent
e193220846
commit
22a03d9ab9
2 changed files with 20 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue