Пример #1
0
        private static MyCubeSize GetCubeSize(MySlimBlock block)
        {
            MyCubeBlockDefinition definition;

            if (block.CubeGrid != null)
            {
                return(block.CubeGrid.GridSizeEnum);
            }
            MyFracturedBlock fatBlock = block.FatBlock as MyFracturedBlock;

            if (((fatBlock == null) || (fatBlock.OriginalBlocks.Count <= 0)) || !MyDefinitionManager.Static.TryGetCubeBlockDefinition(fatBlock.OriginalBlocks[0], out definition))
            {
                return(block.BlockDefinition.CubeSize);
            }
            return(definition.CubeSize);
        }
Пример #2
0
        private static MyCubeSize GetCubeSize(MySlimBlock block)
        {
            if (block.CubeGrid != null)
            {
                return(block.CubeGrid.GridSizeEnum);
            }

            // Fractured small blocks are in large fracture block!
            MyFracturedBlock fractureBlock = block.FatBlock as MyFracturedBlock;

            if (fractureBlock != null && fractureBlock.OriginalBlocks.Count > 0)
            {
                MyCubeBlockDefinition def;
                if (MyDefinitionManager.Static.TryGetCubeBlockDefinition(fractureBlock.OriginalBlocks[0], out def))
                {
                    return(def.CubeSize);
                }
            }

            return(block.BlockDefinition.CubeSize);
        }
        public static MyFracturedPiece CreateFracturePiece(MyFracturedBlock fracturedBlock, bool sync)
        {
            System.Diagnostics.Debug.Assert(Sync.IsServer, "Only on server");
            var m = fracturedBlock.CubeGrid.PositionComp.WorldMatrix;
            m.Translation = fracturedBlock.CubeGrid.GridIntegerToWorld(fracturedBlock.Position);
            var fp = CreateFracturePiece(ref fracturedBlock.Shape, fracturedBlock.CubeGrid.GetPhysicsBody().HavokWorld.DestructionWorld, ref m, false);
            fp.OriginalBlocks = fracturedBlock.OriginalBlocks;

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

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

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

            return fp;
        }
Пример #4
0
        public static MyFracturedPiece CreateFracturePiece(MyFracturedBlock fracturedBlock, bool sync)
        {
            System.Diagnostics.Debug.Assert(Sync.IsServer, "Only on server");
            var m = fracturedBlock.CubeGrid.PositionComp.WorldMatrix;
            m.Translation = fracturedBlock.CubeGrid.GridIntegerToWorld(fracturedBlock.Position);
            var fp = CreateFracturePiece(ref fracturedBlock.Shape, fracturedBlock.CubeGrid.Physics.HavokWorld.DestructionWorld, ref m, false);
            fp.OriginalBlocks = fracturedBlock.OriginalBlocks;

            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;
        }
 public MyFBDebugRender(MyFracturedBlock b)
 {
     m_block = b;
 }
Пример #6
0
 public MyFBDebugRender(MyFracturedBlock b)
 {
     m_block = b;
 }