예제 #1
0
        /// <summary>
        /// Destroy this object. Optionally, destroy it's children. If destroying children, destroy the
        /// children's children, etc. The most important aspect of this function is that when destroyed,
        /// persistent objects are forgotten. Destroying non-persistent objects is not necessary.
        /// </summary>
        /// <param name="DestroyChildren"></param>
        public void Destroy(bool DestroyChildren)
        {
            State = ObjectState.Destroyed;
            MudObject.ForgetInstance(this);

            if (DestroyChildren && this is Container)
            {
                foreach (var child in (this as Container).EnumerateObjects())
                {
                    if (child.State != ObjectState.Destroyed)
                    {
                        child.Destroy(true);
                    }
                }
            }
        }