Beispiel #1
0
        static void OnRemoveShapeFromFractureComponentMessage(ref RemoveShapeFromFractureComponentMsg msg, MyNetworkClient sender)
        {
            Debug.Assert(!Sync.IsServer);
            Debug.Assert(msg.ShapeNames != null && msg.ShapeNames.Length > 0);

            MyEntity entity;

            if (MyEntities.TryGetEntityById(msg.Grid, out entity))
            {
                MyCubeGrid grid      = entity as MyCubeGrid;
                var        cubeBlock = grid.GetCubeBlock(msg.Position);
                if (cubeBlock != null && cubeBlock.FatBlock != null)
                {
                    var compound = cubeBlock.FatBlock as MyCompoundCubeBlock;
                    if (compound != null)
                    {
                        var blockInCompound = compound.GetBlock(msg.CompoundBlockId);
                        if (blockInCompound != null)
                        {
                            RemoveFractureComponentChildShapes(blockInCompound, msg.ShapeNames);
                        }
                    }
                    else
                    {
                        RemoveFractureComponentChildShapes(cubeBlock, msg.ShapeNames);
                    }
                }
            }
        }
Beispiel #2
0
        public static void RemoveShapesFromFractureComponent(long gridId, Vector3I position, ushort compoundBlockId, List <string> shapeNames)
        {
            Debug.Assert(Sync.IsServer);
            Debug.Assert(gridId != 0);
            Debug.Assert(shapeNames != null && shapeNames.Count > 0);

            var msg = new RemoveShapeFromFractureComponentMsg();

            msg.Grid            = gridId;
            msg.Position        = position;
            msg.CompoundBlockId = compoundBlockId;
            msg.ShapeNames      = shapeNames.ToArray();
            MySession.Static.SyncLayer.SendMessageToAll(ref msg);
        }
Beispiel #3
0
        public static void RemoveShapeFromFractureComponent(long gridId, Vector3I position, ushort compoundBlockId, string shapeName)
        {
            Debug.Assert(Sync.IsServer);
            Debug.Assert(gridId != 0);
            Debug.Assert(shapeName != null && !string.IsNullOrEmpty(shapeName));

            var msg = new RemoveShapeFromFractureComponentMsg();

            msg.Grid            = gridId;
            msg.Position        = position;
            msg.CompoundBlockId = compoundBlockId;
            msg.ShapeNames      = new string[] { shapeName };
            MySession.Static.SyncLayer.SendMessageToAll(ref msg);
        }
        static void OnRemoveShapeFromFractureComponentMessage(ref RemoveShapeFromFractureComponentMsg msg, MyNetworkClient sender)
        {
            Debug.Assert(!Sync.IsServer);
            Debug.Assert(msg.ShapeNames != null && msg.ShapeNames.Length > 0);

            MyEntity entity;
            if (MyEntities.TryGetEntityById(msg.Grid, out entity))
            {
                MyCubeGrid grid = entity as MyCubeGrid;
                var cubeBlock = grid.GetCubeBlock(msg.Position);
                if (cubeBlock != null && cubeBlock.FatBlock != null)
                {
                    var compound = cubeBlock.FatBlock as MyCompoundCubeBlock;
                    if (compound != null)
                    {
                        var blockInCompound = compound.GetBlock(msg.CompoundBlockId);
                        if (blockInCompound != null)
                        {
                            var component = blockInCompound.GetFractureComponent();
                            if (component != null)
                                component.RemoveChildShapes(msg.ShapeNames);
                        }
                    }
                    else
                    {
                        var component = cubeBlock.GetFractureComponent();
                        if (component != null)
                            component.RemoveChildShapes(msg.ShapeNames);
                    }
                }
            }
        }
        public static void RemoveShapesFromFractureComponent(long gridId, Vector3I position, ushort compoundBlockId, List<string> shapeNames)
        {
            Debug.Assert(Sync.IsServer);
            Debug.Assert(gridId != 0);
            Debug.Assert(shapeNames != null && shapeNames.Count > 0);

            var msg = new RemoveShapeFromFractureComponentMsg();
            msg.Grid = gridId;
            msg.Position = position;
            msg.CompoundBlockId = compoundBlockId;
            msg.ShapeNames = shapeNames.ToArray();
            MySession.Static.SyncLayer.SendMessageToAll(ref msg);
        }
        public static void RemoveShapeFromFractureComponent(long gridId, Vector3I position, ushort compoundBlockId, string shapeName)
        {
            Debug.Assert(Sync.IsServer);
            Debug.Assert(gridId != 0);
            Debug.Assert(shapeName != null && !string.IsNullOrEmpty(shapeName));

            var msg = new RemoveShapeFromFractureComponentMsg();
            msg.Grid = gridId;
            msg.Position = position;
            msg.CompoundBlockId = compoundBlockId;
            msg.ShapeNames = new string[] { shapeName };
            MySession.Static.SyncLayer.SendMessageToAll(ref msg);
        }