Ejemplo n.º 1
0
        private static void OnCreateSplit(MySyncGrid grid, ref CreateSplitMsg msg, MyNetworkClient sender)
        {
            MyCubeGrid m_grid;
            if (MyEntities.TryGetEntityById(msg.GridEntityId, out m_grid))
            {
                m_tmpBlockListReceive.Clear();
                foreach (var position in msg.SplitBlocks)
                {
                    var block = m_grid.GetCubeBlock(position);
                    Debug.Assert(block != null, "Block was null when trying to create a grid split. Desync?");
                    if (block == null)
                    {
                        MySandboxGame.Log.WriteLine("Block was null when trying to create a grid split. Desync?");
                        continue;
                    }

                    m_tmpBlockListReceive.Add(block);
                }

                MyCubeGrid.CreateSplit(m_grid, m_tmpBlockListReceive, sync: false, newEntityId: msg.NewGridEntityId);
                m_tmpBlockListReceive.Clear();
            }
        }
Ejemplo n.º 2
0
        public void AnnounceCreateSplit(List<MySlimBlock> blocks, long newEntityId)
        {
            var msg = new CreateSplitMsg();
            msg.GridEntityId = Entity.EntityId;
            msg.NewGridEntityId = newEntityId;

            m_tmpPositionListSend.Clear();
            msg.SplitBlocks = m_tmpPositionListSend;
            foreach (var block in blocks)
            {
                msg.SplitBlocks.Add(block.Position);
            }

            Sync.Layer.SendMessageToAll(ref msg);
        }