rendered paste bodypublic FlatRedBall.Math.Geometry.Point FindEmptySpaceClosestTo(float xPosition, float yPosition)
{
int startXCoord = (int)Math.Round(((xPosition - xLeft) / xSpacing));
int startYCoord = (int)Math.Round(((yPosition - yBottom) / ySpacing));
//int outerRange = 1;
//int innerRange = 0;
for (int outerRange = 1; outerRange < 13; outerRange++)
{
for (int i = startXCoord - outerRange; i < startXCoord + outerRange + 1; i++)
{
for (int j = startYCoord - outerRange; j < startYCoord + outerRange + 1; j++)
{
if (i > -1 && i < fireMapX && j > -1 && j < fireMapY)
{
if (fireMap[i, j].State == FireSpace.FireStates.State_Active || fireMap[i, j].State == FireSpace.FireStates.State_Dormant)
return new FlatRedBall.Math.Geometry.Point((i * xSpacing) + xLeft, (j * ySpacing) + yBottom);
}
}
}
}
return new FlatRedBall.Math.Geometry.Point(xPosition, yPosition);
}