public Boolean OnlyOverlapsSelf(OrganismState state)
{
Debug.Assert(IndexBuilt);
var minGridX = state.GridX - state.CellRadius;
var maxGridX = state.GridX + state.CellRadius;
var minGridY = state.GridY - state.CellRadius;
var maxGridY = state.GridY + state.CellRadius;
// If it would be out of bounds, return false.
if (minGridX < 0 || maxGridX > _gridWidth - 1 ||
minGridY < 0 || maxGridY > _gridHeight - 1)
{
return false;
}
for (var x = minGridX; x <= maxGridX; x++)
{
for (var y = minGridY; y <= maxGridY; y++)
{
if (_cellOrganisms[x, y] == null) continue;
if (_cellOrganisms[x, y].ID != state.ID)
{
return false;
}
}
}
return true;
}