当前位置: 首页>>代码示例>>C#>>正文


C# MySlimBlock.GetFractureComponent方法代码示例

本文整理汇总了C#中Sandbox.Game.Entities.Cube.MySlimBlock.GetFractureComponent方法的典型用法代码示例。如果您正苦于以下问题:C# MySlimBlock.GetFractureComponent方法的具体用法?C# MySlimBlock.GetFractureComponent怎么用?C# MySlimBlock.GetFractureComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sandbox.Game.Entities.Cube.MySlimBlock的用法示例。


在下文中一共展示了MySlimBlock.GetFractureComponent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DebugDrawMountPoints

        private void DebugDrawMountPoints(MySlimBlock block)
        {
            
            if (block.FatBlock is MyCompoundCubeBlock)
            {
                MyCompoundCubeBlock compoundBlock = block.FatBlock as MyCompoundCubeBlock;
                foreach (MySlimBlock componentBlock in compoundBlock.GetBlocks())
                {
                    DebugDrawMountPoints(componentBlock);
                }
            }
            else
            {
                Matrix blockMatrix;                
                block.GetLocalMatrix(out blockMatrix);
                MatrixD blockWorldMatrix = blockMatrix * m_cubeGrid.WorldMatrix;

                if (MyFakes.ENABLE_FRACTURE_COMPONENT && block.FatBlock != null && block.FatBlock.Components.Has<MyFractureComponentBase>())
                {
                    var fractureComponent = block.GetFractureComponent();
                    if (fractureComponent != null)
                        MyCubeBuilder.DrawMountPoints(m_cubeGrid.GridSize, block.BlockDefinition, blockWorldMatrix, fractureComponent.MountPoints.GetInternalArray());
                }
                else
                {
                    MyCubeBuilder.DrawMountPoints(m_cubeGrid.GridSize, block.BlockDefinition, ref blockWorldMatrix);
                }
            }             
        }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:29,代码来源:MyDebugRenderComponentCubeGrid.cs

示例2: RemoveFractureComponentChildShapes

 private static void RemoveFractureComponentChildShapes(MySlimBlock block, string[] shapeNames)
 {
     var component = block.GetFractureComponent();
     if (component != null)
     {
         component.RemoveChildShapes(shapeNames);
     }
     else
     {
         Debug.Fail("Cannot remove child shapes from fracture component, fracture component not found in block");
         MyLog.Default.WriteLine("Cannot remove child shapes from fracture component, fracture component not found in block, BlockDefinition: "
             + block.BlockDefinition.Id.ToString() + ", Shapes: " + string.Join(", ", shapeNames));
     }
 }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:14,代码来源:MySyncDestructions.cs

示例3: RemoveShapesFromFracturedBlocks

        /// <summary>
        /// Removes breakable shapes form fracture component.
        /// </summary>
        /// <param name="bBody">body with shapes</param>
        /// <param name="block">block</param>
        /// <param name="blocksToDelete">collection of blocks to remove from grid</param>
        /// <param name="blocksUpdateDamage">collection of blocks for updating their damage according to remaining shapes count</param>
        /// <returns>true if block was processes otherwise false (block in compound does not exist)</returns>
        private bool RemoveShapesFromFracturedBlocks(HkdBreakableBody bBody, MySlimBlock block, ushort? compoundId, HashSet<MySlimBlock> blocksToDelete, HashSet<MySlimBlock> blocksUpdateDamage)
        {
            Debug.Assert(MyFakes.ENABLE_FRACTURE_COMPONENT);

            // Block can be removed when the removed shape is the last one!
            MyFractureComponentCubeBlock fractureComponent = block.GetFractureComponent();
            if (fractureComponent != null)
            {
                bool removeBlock = false;
                var bShape = bBody.BreakableShape;
                if (IsBreakableShapeCompound(bShape))
                {
                    m_tmpShapeNames.Clear();
                    m_tmpChildren_RemoveShapes.Clear();

                    bShape.GetChildren(m_tmpChildren_RemoveShapes);
                    var shapesCount = m_tmpChildren_RemoveShapes.Count;
                    for (int i = 0; i < shapesCount; ++i)
                    {
                        var child = m_tmpChildren_RemoveShapes[i];
                        if (string.IsNullOrEmpty(child.ShapeName))
                            child.Shape.GetChildren(m_tmpChildren_RemoveShapes);
                    }

                    m_tmpChildren_RemoveShapes.ForEach(delegate(HkdShapeInstanceInfo c)
                    {
                        var shapeName = c.ShapeName;
                        if (!string.IsNullOrEmpty(shapeName))
                            m_tmpShapeNames.Add(shapeName);
                    });

                    if (m_tmpShapeNames.Count != 0)
                    {
                        removeBlock = fractureComponent.RemoveChildShapes(m_tmpShapeNames);
                        MySyncDestructions.RemoveShapesFromFractureComponent(block.CubeGrid.EntityId, block.Position, compoundId ?? 0xFFFF, m_tmpShapeNames);
                    }

                    m_tmpChildren_RemoveShapes.Clear();
                    m_tmpShapeNames.Clear();
                }
                else
                {
                    var name = bBody.BreakableShape.Name;
                    removeBlock = fractureComponent.RemoveChildShapes(new string[] { name });

                    MySyncDestructions.RemoveShapeFromFractureComponent(block.CubeGrid.EntityId, block.Position, compoundId ?? 0xFFFF, name);
                }

                if (removeBlock)
                    blocksToDelete.Add(block);
                else
                    blocksUpdateDamage.Add(block);
            }
            else
            {
                blocksToDelete.Add(block);
            }

            return true;
        }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:68,代码来源:MyGridPhysics.Destruction.cs


注:本文中的Sandbox.Game.Entities.Cube.MySlimBlock.GetFractureComponent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。