Ejemplo n.º 1
0
        public void UpdateRenderObject(bool visible)
        {
            if (!Container.Entity.InScene && visible)
            {
                return;
            }
            MyHierarchyComponentBase hierarchyComponent = Container.Get <MyHierarchyComponentBase>();

            if (visible)
            {
                if (hierarchyComponent != null)
                {
                    if (Visible && (hierarchyComponent.Parent == null || hierarchyComponent.Parent.Container.Entity.Visible))
                    {
                        if (CanBeAddedToRender())
                        {
                            if (!IsRenderObjectAssigned(0))
                            {
                                AddRenderObjects();
                            }
                            else
                            {
                                UpdateRenderObjectVisibility(visible);
                            }
                        }
                    }
                }
            }
            else
            {
                if (m_renderObjectIDs[0] != VRageRender.MyRenderProxy.RENDER_ID_UNASSIGNED)
                {
                    UpdateRenderObjectVisibility(visible);
                }
                RemoveRenderObjects();
            }

            if (hierarchyComponent != null)
            {
                foreach (var child in hierarchyComponent.Children)
                {
                    MyRenderComponentBase renderComponent = null;
                    if (child.Container.TryGet(out renderComponent))
                    {
                        renderComponent.UpdateRenderObject(visible);
                    }
                }
            }
        }
        private void UpdateRenderObjectVisibilityIncludingChildren(bool visible)
        {
            UpdateRenderObjectVisibility(visible);

            MyHierarchyComponentBase hierarchy = Container.Get <MyHierarchyComponentBase>();

            foreach (var child in hierarchy.Children)
            {
                MyRenderComponentBase renderComponent = null;
                if (child.Container.Entity.InScene && child.Container.TryGet(out renderComponent))
                {
                    renderComponent.UpdateRenderObjectVisibilityIncludingChildren(visible);
                }
            }
        }