public static void ClientSubmitStartDroneCommandsImmediately() { switch (ClientDroneStartQueue.Count) { case 0: return; case 1: var onlyEntry = ClientDroneStartQueue.GetFirstEntry(); Instance.CallServer(_ => _.ServerRemote_StartDrone(onlyEntry.Key, onlyEntry.Value)); ClientDroneStartQueue.Clear(); return; default: { using var tempList = Api.Shared.GetTempList <(IItem, Vector2Ushort)>(); foreach (var entry in ClientDroneStartQueue) { tempList.Add((entry.Key, entry.Value)); } ClientDroneStartQueue.Clear(); // ReSharper disable once AccessToDisposedClosure Instance.CallServer(_ => _.ServerRemote_StartDrones(tempList.AsList())); return; } } }