namespace MonoGame.Extended.Collisions
{
///
/// Represents a single cell in a collision grid.
///
public class CollisionGridCell : ICollidable
{
private readonly CollisionGrid _parentGrid;
///
/// Creates a collision grid cell at a location in the parent grid.
///
/// The collision grid which this cell is a part of.
/// The column position of this cell.
/// The row position of this cell.
///
public CollisionGridCell(CollisionGrid parentGrid, int column, int row, int data)
{
_parentGrid = parentGrid;
Column = column;
Row = row;
Data = data;
Flag = data == 0 ? CollisionGridCellFlag.Empty : CollisionGridCellFlag.Solid;
}
///
/// Gets the Column in the parent grid that this cell represents.
///
public int Column { get; }
///
/// Gets the Row in the parent grid that this cell represents.
///
public int Row { get; }
public int Data { get; private set; }
public object Tag { get; set; }
public CollisionGridCellFlag Flag { get; set; }
///
/// Gets the bounding box of the cell.
///
public RectangleF BoundingBox => _parentGrid.GetCellRectangle(Column, Row).ToRectangleF();
}
}