Example #1
0
        private static void OnRemoveBlocksWithIds(MySyncGrid sync, ref RemoveBlocksWithIdsMsg msg, MyNetworkClient sender)
        {
            var handler = sync.BlocksWithIdRemovedWithGenerator;
            if (handler != null && msg.LocationsWithGenerator != null) handler(msg.LocationsWithGenerator);

            var handler2 = sync.BlocksWithIdRemovedWithoutGenerator;
            if (handler2 != null && msg.LocationsWithoutGenerator != null) handler2(msg.LocationsWithoutGenerator);

            var handler3 = sync.BlocksDestroyedWithId;
            if (handler3 != null && msg.DestroyLocations != null) handler3(msg.DestroyLocations);
        }
Example #2
0
        /// <summary>
        /// Server method, sends queued blocks with compound ids to clients
        /// Not optimized
        /// </summary>
        public void SendRemovedBlocksWithIds()
        {
            if (Sync.IsServer && (m_removeBlockWithIdQueueWithGenerators.Count > 0 || m_removeBlockWithIdQueueWithoutGenerators.Count > 0 || m_destroyBlockQueueWithId.Count > 0))
            {
                var msg = new RemoveBlocksWithIdsMsg();
                msg.GridEntityId = Entity.EntityId;
                msg.LocationsWithGenerator = m_removeBlockWithIdQueueWithGenerators;
                msg.LocationsWithoutGenerator = m_removeBlockWithIdQueueWithoutGenerators;
                msg.DestroyLocations = m_destroyBlockQueueWithId;
                Sync.Layer.SendAsRpcToAll(ref msg);

                m_removeBlockWithIdQueueWithGenerators.Clear();
                m_removeBlockWithIdQueueWithoutGenerators.Clear();
                m_destroyBlockQueueWithId.Clear();
            }
        }