public static void CreateFractureComponent(long gridId, Vector3I position, ushort compoundBlockId, MyObjectBuilder_FractureComponentBase component)
        {
            Debug.Assert(Sync.IsServer);
            Debug.Assert(gridId != 0);
            Debug.Assert(component.Shapes != null && component.Shapes.Count > 0);

            MyMultiplayer.RaiseStaticEvent(s => MySyncDestructions.OnCreateFractureComponentMessage, gridId, position, compoundBlockId, component);
        }
        private static void AddFractureComponent(MyObjectBuilder_FractureComponentBase obFractureComponent, MyEntity entity)
        {
            var component = MyComponentFactory.CreateInstanceByTypeId(obFractureComponent.TypeId);
            var fractureComponent = component as MyFractureComponentBase;
            Debug.Assert(fractureComponent != null);
            if (fractureComponent != null)
            {
                try
                {
                    bool hasComponent = entity.Components.Has<MyFractureComponentBase>();
                    Debug.Assert(!hasComponent);
                    if (!hasComponent)
                    {
                        entity.Components.Add<MyFractureComponentBase>(fractureComponent);
                        fractureComponent.Deserialize(obFractureComponent);
                    }
                }
                catch (Exception e)
                {
                    MyLog.Default.WriteLine("Cannot add received fracture component: " + e.Message);
                    if (entity.Components.Has<MyFractureComponentBase>())
                    {
                        MyCubeBlock block = entity as MyCubeBlock;
                        if (block != null && block.SlimBlock != null)
                        {
                            block.SlimBlock.RemoveFractureComponent();
                        }
                        else
                        {
                            Debug.Fail("Fracture component not supported for other entities than MyCubeBlock for now!");
                            // Renderer has to be set to entity default because it is changed in fracture component.
                            entity.Components.Remove<MyFractureComponentBase>();
                        }
                    }

                    StringBuilder sb = new StringBuilder();
                    foreach (var shape in obFractureComponent.Shapes)
                        sb.Append(shape.Name).Append(" ");

                    Debug.Fail("Recieved fracture component not added");
                    MyLog.Default.WriteLine("Received fracture component not added, no shape found. Shapes: " + sb.ToString());
                }
            }
        }
 private static void AddFractureComponent(MyObjectBuilder_FractureComponentBase obFractureComponent, MyEntity entity)
 {
     var component = MyComponentFactory.CreateInstance(obFractureComponent.GetType());
     var fractureComponent = component as MyFractureComponentBase;
     Debug.Assert(fractureComponent != null);
     if (fractureComponent != null)
     {
         bool hasComponent = entity.Components.Has<MyFractureComponentBase>();
         Debug.Assert(!hasComponent);
         if (!hasComponent)
         {
             entity.Components.Add<MyFractureComponentBase>(fractureComponent);
             fractureComponent.Deserialize(obFractureComponent);
         }
     }
 }
        protected void SerializeInternal(MyObjectBuilder_FractureComponentBase ob)
        {
            Debug.Assert(m_tmpChildren.Count == 0);

            if (string.IsNullOrEmpty(Shape.Name) || Shape.IsCompound() || Shape.GetChildrenCount() > 0)
            {
                Shape.GetChildren(m_tmpChildren);
                foreach (var child in m_tmpChildren)
                {
                    var shape = new MyObjectBuilder_FractureComponentCubeBlock.FracturedShape()
                    {
                        Name = child.ShapeName,
                        Fixed = MyDestructionHelper.IsFixed(child.Shape)
                    };
                    ob.Shapes.Add(shape);
                }
                m_tmpChildren.Clear();
            }
            else
            {
                ob.Shapes.Add(new MyObjectBuilder_FractureComponentCubeBlock.FracturedShape() { Name = Shape.Name });
            }
        }
        public static void CreateFractureComponent(long gridId, Vector3I position, ushort compoundBlockId, MyObjectBuilder_FractureComponentBase component)
        {
            Debug.Assert(Sync.IsServer);
            Debug.Assert(gridId != 0);
            Debug.Assert(component.Shapes != null && component.Shapes.Count > 0);

            var msg = new CreateFractureComponentMsg();
            msg.Grid = gridId;
            msg.Position = position;
            msg.CompoundBlockId = compoundBlockId;
            msg.FractureComponent = component;
            MySession.Static.SyncLayer.SendMessageToAll(ref msg);
        }