Example #1
0
        private static void OnRemoveBlocks(MySyncGrid sync, ref RemoveBlocksMsg msg, MyNetworkClient sender)
        {
            var handler2 = sync.BlocksDestroyed;
            if (handler2 != null && msg.DestroyLocations != null) handler2(msg.DestroyLocations);

            var handler = sync.BlocksRemovedWithGenerator;
            if (handler != null && msg.LocationsWithGenerator != null) handler(msg.LocationsWithGenerator);

            var handler4 = sync.BlocksRemovedWithoutGenerator;
            if (handler4 != null && msg.LocationsWithoutGenerator != null) handler4(msg.LocationsWithoutGenerator);

            var handler3 = sync.BlocksDeformed;
            if (handler3 != null && msg.DestructionDeformationLocations != null) handler3(msg.DestructionDeformationLocations);
        }
Example #2
0
        /// <summary>
        /// Server method, sends queued blocks to clients
        /// Can be optimized by using VoxelSegmentation
        /// </summary>
        public void SendRemovedBlocks()
        {
            if (Sync.IsServer && (m_removeBlockQueueWithGenerators.Count > 0 || m_removeBlockQueueWithoutGenerators.Count > 0 || m_destroyBlockQueue.Count > 0 || m_destructionDeformationQueue.Count > 0))
            {
                var msg = new RemoveBlocksMsg();
                msg.GridEntityId = Entity.EntityId;
                msg.LocationsWithGenerator = m_removeBlockQueueWithGenerators;
                msg.LocationsWithoutGenerator = m_removeBlockQueueWithoutGenerators;
                msg.DestroyLocations = m_destroyBlockQueue;
                msg.DestructionDeformationLocations = m_destructionDeformationQueue;
                Sync.Layer.SendMessageToAll(ref msg);

                m_removeBlockQueueWithGenerators.Clear();
                m_removeBlockQueueWithoutGenerators.Clear();
                m_destroyBlockQueue.Clear();
                m_destructionDeformationQueue.Clear();
            }
        }