BEPUphysics.EntityStateManagement.BufferedStatesManager.Remove C# (CSharp) Method

Remove() public method

Removes an entity from the manager.
Thrown if the entity does not belong to this manager.
public Remove ( Entity e ) : void
e Entity Entity to remove.
return void
        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.");

                }
            }
        }