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); } } }
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)); } }
/// <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; }