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);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void UpdateRenderObjectVisibilityIncludingChildren(bool visible)
        {
            UpdateRenderObjectVisibility(visible);

            MyHierarchyComponentBase hierarchy;

            if (Container.TryGet <MyHierarchyComponentBase>(out hierarchy))
            {
                foreach (var child in hierarchy.Children)
                {
                    MyRenderComponentBase renderComponent = null;
                    if (child.Container.Entity.InScene && child.Container.TryGet(out renderComponent))
                    {
                        renderComponent.UpdateRenderObjectVisibilityIncludingChildren(visible);
                    }
                }
            }
        }
Ejemplo n.º 3
0
 void Components_ComponentAdded(Type t, MyEntityComponentBase c)
 {
     // TODO: this has to be refactored because it is very dangerous - each component member set here can be overwritten with new one of the same base type
     // (assume more than one GameLogicComponent), components should support aggregates (parameter can be added to MyComponentTypeAttribute).
     if ((typeof(MyPhysicsComponentBase)).IsAssignableFrom(t))
         m_physics = c as MyPhysicsComponentBase;
     else if ((typeof(MySyncComponentBase)).IsAssignableFrom(t))
         m_syncObject = c as MySyncComponentBase;
     else if ((typeof(MyGameLogicComponent)).IsAssignableFrom(t))
         m_gameLogic = c as MyGameLogicComponent;
     else if ((typeof(MyPositionComponentBase)).IsAssignableFrom(t))
     {
         m_position = c as MyPositionComponentBase;
         if (m_position == null)
             PositionComp = new VRage.Game.Components.MyNullPositionComponent();
     }
     else if ((typeof(MyHierarchyComponentBase)).IsAssignableFrom(t))
         m_hierarchy = c as MyHierarchyComponent<MyEntity>;
     else if ((typeof(MyRenderComponentBase)).IsAssignableFrom(t))
     {
         m_render = c as MyRenderComponentBase;
         if (m_render == null)
             Render = new VRage.Game.Components.MyNullRenderComponent();
     }
     else if ((typeof(MyInventoryBase)).IsAssignableFrom(t))
     {
         OnInventoryComponentAdded(c as MyInventoryBase);
     }
 }
Ejemplo n.º 4
0
 public static MyModel GetModel(this MyRenderComponentBase obj)
 {
     return((MyModel)obj.ModelStorage);
 }