using System;
using System.Collections.Generic;
using Nibriboard.RippleSpace;
using SBRL.Utilities;
namespace SBRL.Utilities
{
///
/// A collection of tools aid in the manipulation of chunks.
///
public static class ChunkTools
{
///
/// Gets a list of chunk references that cross inside the specified rectangle.
///
/// The plane to operate on.
/// The rectangle to find the containing chunks for.
/// All the chunk references that fall inside the specified area.
public static List GetContainingChunkReferences(Plane plane, Rectangle area)
{
List result = new List();
Vector2 currentLocation = area.TopLeft;
while(currentLocation.X < area.BottomRight.X &&
currentLocation.Y < area.BottomRight.Y)
{
result.Add(new ChunkReference(
plane,
currentLocation.X,
currentLocation.Y
));
currentLocation.X += plane.ChunkSize;
if(currentLocation.X > area.Right)
{
currentLocation.X = area.Left;
currentLocation.Y += plane.ChunkSize;
}
}
return result;
}
}
}