private void InitPackets() { var tasks = new List <Task>(); foreach (Type type in typeof(StarMain).Assembly.GetTypes().Where(p => p.Namespace == "StarLib.Packets.Starbound")) { if (!typeof(Packet).IsAssignableFrom(type)) { continue; } _log.Debug("Adding default packet type {0}", type.FullName); DefaultPacketTypes.Add(type); _log.Debug("Building and caching packet serializer/deserializer for type {0}", type.FullName); tasks.Add(Task.Run(() => PacketSerializer.BuildAndStore(type))); } Task.WhenAll(tasks).Wait(); }