void ObjectDestructed(BaseObject ob) { ob.Destructed -= ObjectDestructed; var movable = ob as MovableObject; if (movable != null) { movable.PropertyChanged -= MovablePropertyChanged; } var env = ob as EnvironmentObject; if (env != null) { m_environments.Remove(env); } m_rootObjects.Remove(ob); if (m_objects.Remove(ob) == false) { throw new Exception(); } #if TRACK_DESTRUCTED_OBJECTS m_destructedObjects.Add(ob); #endif }
public BaseObject CreateObject(ObjectID objectID) { if (objectID == ObjectID.NullObjectID || objectID == ObjectID.AnyObjectID) { throw new ArgumentException(); } if (m_objects.Contains(objectID)) { throw new Exception(); } var ob = ConstructObject(objectID); m_objects.Add(ob); m_rootObjects.Add(ob); var env = ob as EnvironmentObject; if (env != null) { m_environments.Add(env); } var movable = ob as MovableObject; if (movable != null) { movable.PropertyChanged += MovablePropertyChanged; } ob.Destructed += ObjectDestructed; return(ob); }