Example #1
0
        public static Team Deserialize(byte[] teamData)
        {
            try
            {
                if (teamData == null)
                {
                    return((Team)null);
                }
                MemoryStream    memoryStream    = new MemoryStream(teamData);
                RijndaelManaged rijndaelManaged = new RijndaelManaged();
                byte[]          numArray1       = new byte[16]
                {
                    (byte)243,
                    (byte)22,
                    (byte)152,
                    (byte)32,
                    (byte)1,
                    (byte)244,
                    (byte)122,
                    (byte)111,
                    (byte)97,
                    (byte)42,
                    (byte)13,
                    (byte)2,
                    (byte)19,
                    (byte)15,
                    (byte)45,
                    (byte)230
                };
                rijndaelManaged.Key = numArray1;
                rijndaelManaged.IV  = Team.ReadByteArray((Stream)memoryStream);
                BinaryReader binaryReader = new BinaryReader((Stream) new CryptoStream((Stream)memoryStream, rijndaelManaged.CreateDecryptor(rijndaelManaged.Key, rijndaelManaged.IV), CryptoStreamMode.Read));
                long         num1         = binaryReader.ReadInt64();
                switch (num1)
                {
                case 402965919293045:
                case 465665919293045:
                case 630430777029345:
                case 630449177029345:
                    if (num1 == 630449177029345L || num1 == 465665919293045L)
                    {
                        binaryReader.ReadString();
                    }
                    string    varName    = binaryReader.ReadString();
                    int       count      = binaryReader.ReadInt32();
                    byte[]    numArray2  = binaryReader.ReadBytes(count);
                    Texture2D hatTexture = Texture2D.FromStream(DuckGame.Graphics.device, (Stream) new MemoryStream(numArray2));
                    Color[]   data1      = new Color[hatTexture.Width * hatTexture.Height];
                    hatTexture.GetData <Color>(data1);
                    for (int index = 0; index < data1.Length; ++index)
                    {
                        if (data1[index].r == byte.MaxValue && data1[index].g == (byte)0 && data1[index].b == byte.MaxValue)
                        {
                            data1[index] = new Color(0, 0, 0, 0);
                        }
                    }
                    string    str       = CRC32.Generate(numArray2).ToString();
                    Texture2D texture2D = (Texture2D)null;
                    bool      flag      = true;
                    if ((num1 == 630430777029345L || num1 == 630449177029345L) && (hatTexture.Height == 32 && hatTexture.Width == 96))
                    {
                        texture2D = new Texture2D(DuckGame.Graphics.device, 32, 32);
                        Color[] data2 = new Color[1024];
                        int     num2  = 64;
                        for (int index1 = 0; index1 < 32; ++index1)
                        {
                            for (int index2 = 0; index2 < 32; ++index2)
                            {
                                data2[index2 + index1 * 32] = data1[num2 + index2 + index1 * hatTexture.Width];
                            }
                        }
                        texture2D.SetData <Color>(data2);
                        flag = true;
                    }
                    hatTexture.SetData <Color>(data1);
                    binaryReader.Close();
                    return(new Team(varName, hatTexture)
                    {
                        hatID = str,
                        customData = teamData,
                        _capeTexture = texture2D,
                        capeRequestSuccess = flag
                    });

                default:
                    return((Team)null);
                }
            }
            catch
            {
                return((Team)null);
            }
        }