public void FillCells(OrganismState state, int cellX, int cellY, int cellRadius, Boolean clear)
{
Debug.Assert(cellX - cellRadius >= 0 && cellY - cellRadius + 1 >= 0);
for (var x = cellX - cellRadius; x <= cellX + cellRadius; x++)
{
for (var y = cellY - cellRadius; y <= cellY + cellRadius; y++)
{
if (clear)
{
// Make sure we are only clearing ourselves, the value may be null because clearindex
// may have been called
if (!(_cellOrganisms[x, y] == null || _cellOrganisms[x, y].ID == state.ID))
{
Debug.Assert(_cellOrganisms[x, y] == null || _cellOrganisms[x, y].ID == state.ID);
}
_cellOrganisms[x, y] = null;
}
else
{
// Make sure there was no one else here
if (!(_cellOrganisms[x, y] == null))
{
Debug.Assert(_cellOrganisms[x, y] == null);
}
_cellOrganisms[x, y] = state;
}
}
}
}