Beispiel #1
0
        static void OnCreateFractureComponentMessage(ref CreateFractureComponentMsg msg, MyNetworkClient sender)
        {
            Debug.Assert(!Sync.IsServer);

            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)
                        {
                            AddFractureComponent(msg.FractureComponent, blockInCompound.FatBlock);
                        }
                    }
                    else
                    {
                        AddFractureComponent(msg.FractureComponent, cubeBlock.FatBlock);
                    }
                }
            }
        }
Beispiel #2
0
        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);
        }
        static void OnCreateFractureComponentMessage(ref CreateFractureComponentMsg msg, MyNetworkClient sender)
        {
            Debug.Assert(!Sync.IsServer);

            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)
                            AddFractureComponent(msg.FractureComponent, blockInCompound.FatBlock);
                    }
                    else
                    {
                        AddFractureComponent(msg.FractureComponent, cubeBlock.FatBlock);
                    }
                }
            }
        }
        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);
        }