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, (int)Math.Floor(currentLocation.X / plane.ChunkSize), (int)Math.Floor(currentLocation.Y / plane.ChunkSize) )); currentLocation.X += plane.ChunkSize; if(currentLocation.X > area.Right) { currentLocation.X = area.Left; currentLocation.Y += plane.ChunkSize; } } return result; } } }