public override void DebugDraw()
            {
                if (!MyDebugDrawSettings.DEBUG_DRAW_MOUNT_POINTS || !m_block.Components.Has <MyFractureComponentBase>())
                {
                    return;
                }

                MyFractureComponentCubeBlock component = m_block.GetFractureComponent();

                if (component != null)
                {
                    MatrixD m = m_block.CubeGrid.PositionComp.WorldMatrix;
                    m.Translation = m_block.CubeGrid.GridIntegerToWorld(m_block.Position);
                    MyCubeBuilder.DrawMountPoints(m_block.CubeGrid.GridSize, m_block.BlockDefinition, m, component.MountPoints.ToArray());
                }
            }
        public static MyFracturedPiece CreateFracturePiece(MyFractureComponentCubeBlock fractureBlockComponent, bool sync)
        {
            if (!fractureBlockComponent.Block.BlockDefinition.CreateFracturedPieces)
                return null;

            if (!fractureBlockComponent.Shape.IsValid())
            {
                Debug.Fail("Invalid shape in fracture component");
                MyLog.Default.WriteLine("Invalid shape in fracture component, Id: " + fractureBlockComponent.Block.BlockDefinition.Id.ToString() + ", closed: " + fractureBlockComponent.Block.FatBlock.Closed);
                return null;
            }

            System.Diagnostics.Debug.Assert(Sync.IsServer, "Only on server");
            var m = fractureBlockComponent.Block.FatBlock.WorldMatrix;
            var fp = CreateFracturePiece(ref fractureBlockComponent.Shape, fractureBlockComponent.Block.CubeGrid.GetPhysicsBody().HavokWorld.DestructionWorld, ref m, false);
            fp.OriginalBlocks.Add(fractureBlockComponent.Block.BlockDefinition.Id);

            // Check valid shapes from block definitions. 
            if (MyFakes.ENABLE_FRACTURE_PIECE_SHAPE_CHECK)
                fp.DebugCheckValidShapes();

            MyPhysicalModelDefinition def;
            if (MyDefinitionManager.Static.TryGetDefinition<MyPhysicalModelDefinition>(fp.OriginalBlocks[0], out def))
                fp.Physics.MaterialType = def.PhysicalMaterial.Id.SubtypeId;

            ProfilerShort.Begin("MyEntities.Add");
            MyEntities.RaiseEntityCreated(fp);
            MyEntities.Add(fp);
            ProfilerShort.End();

            return fp;
        }
Ejemplo n.º 3
0
        public static MyFracturedPiece CreateFracturePiece(MyFractureComponentCubeBlock fractureBlockComponent, bool sync)
        {
            System.Diagnostics.Debug.Assert(Sync.IsServer, "Only on server");
            var m = fractureBlockComponent.Block.FatBlock.WorldMatrix;
            var fp = CreateFracturePiece(ref fractureBlockComponent.Shape, fractureBlockComponent.Block.CubeGrid.Physics.HavokWorld.DestructionWorld, ref m, false);
            fp.OriginalBlocks.Add(fractureBlockComponent.Block.BlockDefinition.Id);

            MyPhysicalModelDefinition def;
            if (MyDefinitionManager.Static.TryGetDefinition<MyPhysicalModelDefinition>(fp.OriginalBlocks[0], out def))
                fp.Physics.MaterialType = def.PhysicalMaterial.Id.SubtypeId;

            if (sync)
                MySyncDestructions.CreateFracturePiece((Sandbox.Common.ObjectBuilders.MyObjectBuilder_FracturedPiece)fp.GetObjectBuilder());

            return fp;
        }