public override void OnBeforeRemovedFromContainer()
        {
            if (m_parentContainer != null)
            {
                m_parentContainer.ComponentAdded   -= Container_ComponentAdded;
                m_parentContainer.ComponentRemoved -= Container_ComponentRemoved;
                m_parentContainer = null;
            }

            m_parent = null;

            base.OnBeforeRemovedFromContainer();
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MyEntity"/> class.
        /// </summary>
        public MyEntity(bool initComponents = true)
        {
            Components = new MyEntityComponentContainer(this);
            Components.ComponentAdded += Components_ComponentAdded;
            Components.ComponentRemoved += Components_ComponentRemoved;

            this.Flags = EntityFlags.Visible |
                         EntityFlags.SkipIfTooSmall |
                         EntityFlags.Save |
                         EntityFlags.NeedsResolveCastShadow |
                         EntityFlags.InvalidateOnMove;


            if (initComponents)
            {
                this.m_hudParams = new List<MyHudEntityParams>(1);
                this.Hierarchy = new MyHierarchyComponentBase();
                this.GameLogic = new MyNullGameLogicComponent();
                this.PositionComp = new MyPositionComponent();

                PositionComp.LocalMatrix = Matrix.Identity;

                this.Render = new MyRenderComponent();
                AddDebugRenderComponent(new MyDebugRenderComponent(this));
            }
        }