byte[] PreparePacket(PacketBase packet, SendTarget type, ulong target, ulong[] targets, bool isBroadcast) { packet.Sender = MyAPIGateway.Multiplayer.MyId; packet.ModId = _modId; var res = packet.ToBinary(); if (!(packet is PacketProxy) && res.Length >= 1024 * 64) { MyAPIGateway.Parallel.Start(() => { var pack = new PacketGZip { Data = res.Compress(), Sender = packet.Sender, ModId = _modId }; switch (type) { case SendTarget.ToOthers: SendMessageToOthers(pack); break; case SendTarget.ToOthersExcluding: SendMessageToOthers(pack, targets); break; case SendTarget.ToServer: SendMessageToServer(pack); break; case SendTarget.ToTarget: SendMessageTo(pack, target); break; case SendTarget.ToTargets: SendMessageTo(pack, targets); break; case SendTarget.Proxy: SendMessageToServer(new PacketProxy { Data = pack.ToBinary(), IsBroadcast = isBroadcast, Targets = targets }); break; default: throw new Exception("WTF?"); } }); return(null); } return(res); }