public void AddOrganism(OrganismState state)
{
if (IsImmutable)
{
throw new ApplicationException("WorldState must be mutable to add organisms.");
}
Debug.Assert(state.GridX >= 0 && state.GridX < _gridWidth && state.GridY >= 0 && state.GridY < _gridHeight);
Debug.Assert(_cellOrganisms[state.GridX, state.GridY] == null);
if (_organisms.ContainsKey(state.ID))
{
throw new OrganismAlreadyExistsException();
}
FillCells(state, state.GridX, state.GridY, state.CellRadius, false);
// Lock the size and position since we've added it to the index and these shouldn't be changed now
state.LockSizeAndPosition();
_organisms.Add(state.ID, state);
}