public void Remove(Entity e)
{
lock (InterpolatedStates.FlipLocker)
{
lock (ReadBuffers.FlipLocker)
{
if (e.BufferedStates.BufferedStatesManager == this)
{
int index = entities.IndexOf(e);
int endIndex = entities.Count - 1;
entities[index] = entities[endIndex];
entities.RemoveAt(endIndex);
if (index < entities.Count)
entities[index].BufferedStates.motionStateIndex = index;
if (ReadBuffers.Enabled)
ReadBuffers.Remove(index, endIndex);
if (InterpolatedStates.Enabled)
InterpolatedStates.Remove(index, endIndex);
e.BufferedStates.BufferedStatesManager = null;
}
else
throw new InvalidOperationException("Entity does not belong to this BufferedStatesManager; cannot remove.");
}
}
}