Example #1
0
 public override void OnCubeGridChanged(MyCubeGrid oldGrid)
 {
     oldGrid.OnHavokSystemIDChanged       -= new Action <int>(this.CubeGrid_OnHavokSystemIDChanged);
     base.CubeGrid.OnHavokSystemIDChanged += new Action <int>(this.CubeGrid_OnHavokSystemIDChanged);
     if (base.CubeGrid.Physics != null)
     {
         this.UpdateHavokCollisionSystemID(base.CubeGrid.GetPhysicsBody().HavokCollisionSystemID, true);
     }
     if (base.InScene)
     {
         Matrix?nullable;
         MyCubeGridRenderCell orAddCell = base.CubeGrid.RenderData.GetOrAddCell((Vector3)(base.Position * base.CubeGrid.GridSize), true);
         if (this.m_leftSubpart != null)
         {
             nullable = null;
             this.m_leftSubpart.Render.SetParent(0, orAddCell.ParentCullObject, nullable);
         }
         if (this.m_rightSubpart != null)
         {
             nullable = null;
             this.m_rightSubpart.Render.SetParent(0, orAddCell.ParentCullObject, nullable);
         }
     }
     base.OnCubeGridChanged(oldGrid);
 }
Example #2
0
 private void RecreateConstraints(VRage.Game.Entity.MyEntity obj, bool refreshInPlace)
 {
     if ((((((obj != null) && !obj.MarkedForClose) && (obj.GetPhysicsBody() != null)) && (!obj.IsPreview && (base.CubeGrid.Projector == null))) && ((this.m_leftSubpart == null) || (!this.m_leftSubpart.MarkedForClose && !this.m_leftSubpart.Closed))) && ((this.m_rightSubpart == null) || (!this.m_rightSubpart.MarkedForClose && !this.m_rightSubpart.Closed)))
     {
         Matrix?nullable;
         MyCubeGridRenderCell orAddCell = base.CubeGrid.RenderData.GetOrAddCell((Vector3)(base.Position * base.CubeGrid.GridSize), true);
         if (this.m_leftSubpart != null)
         {
             nullable = null;
             this.m_leftSubpart.Render.SetParent(0, orAddCell.ParentCullObject, nullable);
         }
         if (this.m_rightSubpart != null)
         {
             nullable = null;
             this.m_rightSubpart.Render.SetParent(0, orAddCell.ParentCullObject, nullable);
         }
         base.DisposeSubpartConstraint(ref this.m_leftConstraint, ref this.m_leftConstraintData);
         base.DisposeSubpartConstraint(ref this.m_rightConstraint, ref this.m_rightConstraintData);
         if ((base.InScene && (base.CubeGrid.Physics != null)) && (base.CubeGrid.Physics.IsInWorld || ((MyPhysicsBody)base.CubeGrid.Physics).IsInWorldWelded()))
         {
             this.CreateConstraints();
         }
         if (obj.Physics != null)
         {
             this.UpdateHavokCollisionSystemID(obj.GetPhysicsBody().HavokCollisionSystemID, refreshInPlace);
         }
         this.UpdateSlidingDoorsPosition();
     }
 }
Example #3
0
        private void RecreateConstraints()
        {
            MyCubeGridRenderCell orAddCell = base.CubeGrid.RenderData.GetOrAddCell((Vector3)(base.Position * base.CubeGrid.GridSize), true);

            using (List <MyEntitySubpart> .Enumerator enumerator = this.m_subparts.GetEnumerator())
            {
                while (true)
                {
                    if (!enumerator.MoveNext())
                    {
                        break;
                    }
                    MyEntitySubpart current = enumerator.Current;
                    if (!current.Closed && !current.MarkedForClose)
                    {
                        Matrix?childToParent = null;
                        current.Render.SetParent(0, orAddCell.ParentCullObject, childToParent);
                        current.NeedsWorldMatrix = false;
                        current.InvalidateOnMove = false;
                        continue;
                    }
                    return;
                }
            }
            this.DisposeConstraints();
            if ((base.InScene && (base.CubeGrid.Physics != null)) && (base.CubeGrid.Physics.IsInWorld || ((MyPhysicsBody)base.CubeGrid.Physics).IsInWorldWelded()))
            {
                this.CreateConstraints();
            }
            if (base.CubeGrid.Physics != null)
            {
                this.UpdateHavokCollisionSystemID(base.CubeGrid.GetPhysicsBody().HavokCollisionSystemID, false);
            }
            this.UpdateDoorPosition();
        }
Example #4
0
        private void InitSubparts()
        {
            Matrix?nullable;

            base.DisposeSubpartConstraint(ref this.m_leftConstraint, ref this.m_leftConstraintData);
            base.DisposeSubpartConstraint(ref this.m_rightConstraint, ref this.m_rightConstraintData);
            base.Subparts.TryGetValue("DoorLeft", out this.m_leftSubpart);
            base.Subparts.TryGetValue("DoorRight", out this.m_rightSubpart);
            MyCubeGridRenderCell orAddCell = base.CubeGrid.RenderData.GetOrAddCell((Vector3)(base.Position * base.CubeGrid.GridSize), true);

            if (this.m_leftSubpart != null)
            {
                nullable = null;
                this.m_leftSubpart.Render.SetParent(0, orAddCell.ParentCullObject, nullable);
                this.m_leftSubpart.NeedsWorldMatrix = false;
                this.m_leftSubpart.InvalidateOnMove = false;
            }
            if (this.m_rightSubpart != null)
            {
                nullable = null;
                this.m_rightSubpart.Render.SetParent(0, orAddCell.ParentCullObject, nullable);
                this.m_rightSubpart.NeedsWorldMatrix = false;
                this.m_rightSubpart.InvalidateOnMove = false;
            }
            if (base.CubeGrid.Projector != null)
            {
                this.UpdateSlidingDoorsPosition();
            }
            else if (!base.CubeGrid.CreatePhysics)
            {
                this.UpdateSlidingDoorsPosition();
            }
            else
            {
                if ((this.m_leftSubpart != null) && (this.m_leftSubpart.Physics != null))
                {
                    this.m_leftSubpart.Physics.Close();
                    this.m_leftSubpart.Physics = null;
                }
                if ((this.m_rightSubpart != null) && (this.m_rightSubpart.Physics != null))
                {
                    this.m_rightSubpart.Physics.Close();
                    this.m_rightSubpart.Physics = null;
                }
                this.CreateConstraints();
                this.m_physicsInitiated = true;
                this.UpdateSlidingDoorsPosition();
            }
        }
Example #5
0
 protected void UpdateGridParent()
 {
     if (MyFakes.MANUAL_CULL_OBJECTS)
     {
         MyCubeGridRenderCell orAddCell = this.m_cubeBlock.CubeGrid.RenderData.GetOrAddCell((Vector3)(this.m_cubeBlock.Position * this.m_cubeBlock.CubeGrid.GridSize), true);
         if (orAddCell.ParentCullObject == uint.MaxValue)
         {
             orAddCell.RebuildInstanceParts(this.GetRenderFlags());
         }
         for (int i = 0; i < base.m_renderObjectIDs.Length; i++)
         {
             base.SetParent(i, orAddCell.ParentCullObject, new Matrix?(base.Entity.PositionComp.LocalMatrix));
         }
     }
 }
Example #6
0
 public override void OnCubeGridChanged(MyCubeGrid oldGrid)
 {
     oldGrid.OnHavokSystemIDChanged       -= new Action <int>(this.CubeGrid_OnHavokSystemIDChanged);
     base.CubeGrid.OnHavokSystemIDChanged += new Action <int>(this.CubeGrid_OnHavokSystemIDChanged);
     if (base.CubeGrid.Physics != null)
     {
         this.UpdateHavokCollisionSystemID(base.CubeGrid.GetPhysicsBody().HavokCollisionSystemID, true);
     }
     if (base.InScene)
     {
         MyCubeGridRenderCell orAddCell = base.CubeGrid.RenderData.GetOrAddCell((Vector3)(base.Position * base.CubeGrid.GridSize), true);
         using (List <MyEntitySubpart> .Enumerator enumerator = this.m_subparts.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 Matrix?childToParent = null;
                 enumerator.Current.Render.SetParent(0, orAddCell.ParentCullObject, childToParent);
             }
         }
     }
     base.OnCubeGridChanged(oldGrid);
 }
Example #7
0
        private void InitSubparts()
        {
            this.FillSubparts();
            MyCubeGridRenderCell orAddCell = base.CubeGrid.RenderData.GetOrAddCell((Vector3)(base.Position * base.CubeGrid.GridSize), true);

            foreach (MyEntitySubpart local1 in this.m_subparts)
            {
                Matrix?childToParent = null;
                local1.Render.SetParent(0, orAddCell.ParentCullObject, childToParent);
                local1.NeedsWorldMatrix = false;
                local1.InvalidateOnMove = false;
            }
            this.UpdateEmissivity(true);
            this.DisposeConstraints();
            if (!base.CubeGrid.CreatePhysics)
            {
                this.UpdateDoorPosition();
            }
            else
            {
                foreach (MyEntitySubpart subpart in this.m_subparts)
                {
                    if (subpart.Physics != null)
                    {
                        subpart.Physics.Close();
                        subpart.Physics = null;
                    }
                }
                if (base.CubeGrid.Projector != null)
                {
                    this.UpdateDoorPosition();
                }
                else
                {
                    this.CreateConstraints();
                    this.UpdateDoorPosition();
                }
            }
        }