public void DestroyAllMovableObjects()
{
foreach ( KeyValuePair<string, MovableObjectCollection> col in this.movableObjectCollectionMap )
{
MovableObjectCollection coll = col.Value;
lock ( coll )
{
if ( Root.Instance.HasMovableObjectFactory( col.Key ) )
{
// Only destroy if we have a factory instance; otherwise must be injected
MovableObjectFactory factory = Root.Instance.GetMovableObjectFactory( col.Key );
foreach ( MovableObject movableObject in coll.Values )
{
if ( movableObject.Manager == this )
{
MovableObject tmp = movableObject;
factory.DestroyInstance( ref tmp );
}
}
coll.Clear();
}
}
}
this.movableObjectCollectionMap.Clear();
}