Пример #1
0
 //---------------------------------------------------------------------
 public void _releaseAllComponent()
 {
     ListComponent.Reverse();
     foreach (var i in ListComponent)
     {
         i.release();
         i.Entity    = null;
         i.EntityMgr = null;
     }
     ListComponent.Reverse();
 }
Пример #2
0
        //---------------------------------------------------------------------
        // 直接销毁该Entity
        internal void _destroy()
        {
            if (SignDestroy)
            {
                return;
            }
            SignDestroy = true;

            // 先销毁所有子Entity
            if (mMapChild != null)
            {
                Dictionary <string, Dictionary <string, Entity> > map_children =
                    new Dictionary <string, Dictionary <string, Entity> >(mMapChild);
                foreach (var i in map_children)
                {
                    List <string> list_entity = new List <string>(i.Value.Keys);
                    foreach (var j in list_entity)
                    {
                        EntityMgr.destroyEntity(j);
                    }
                }
                map_children.Clear();
            }

            // 销毁Entity上挂接的所有组件
            ListComponent.Reverse();
            foreach (var i in ListComponent)
            {
                //if (!EbTool.isNull(i))
                {
                    i.release();
                    i.Entity    = null;
                    i.EntityMgr = null;
                }
            }
            ListComponent.Clear();
            mMapComponent.Clear();

            //if (mPublisher != null)
            //{
            //    mPublisher.removeHandler(this);
            //}

            //if (mMapCacheData != null)
            //{
            //    mMapCacheData.Clear();
            //}

            if (mMapChild != null)
            {
                mMapChild.Clear();
                mMapChild = null;
            }

            // 从父Entity中移除
            if (Parent != null)
            {
                Parent.removeChild(this);
            }

            Type    = "";
            Guid    = "";
            mParent = null;
        }