Exemplo n.º 1
0
        public static AUR_File Load(byte[] bytes)
        {
            AUR_File aurFile = new AUR_File();

            //Header
            int auraCount      = BitConverter.ToInt32(bytes, 8);
            int auraOffset     = BitConverter.ToInt32(bytes, 12);
            int auraTypeCount  = BitConverter.ToInt32(bytes, 16);
            int auraTypeOffset = BitConverter.ToInt32(bytes, 20);
            int charaCount     = BitConverter.ToInt32(bytes, 24);
            int charaOffset    = BitConverter.ToInt32(bytes, 28);

            //AuraTypes
            for (int i = 0; i < auraTypeCount; i++)
            {
                aurFile.AuraTypes.Add(new AUR_Type()
                {
                    Type = StringEx.GetString(bytes, BitConverter.ToInt32(bytes, auraTypeOffset + (4 * i)), false)
                });
            }

            //Auras
            for (int i = 0; i < auraCount; i++)
            {
                AUR_Aura aura = new AUR_Aura();

                aura.Index = BitConverter.ToInt32(bytes, auraOffset + 0).ToString();
                aura.I_04  = BitConverter.ToInt32(bytes, auraOffset + 4);

                int effectCount  = BitConverter.ToInt32(bytes, auraOffset + 8);
                int effectOffset = BitConverter.ToInt32(bytes, auraOffset + 12);

                for (int a = 0; a < effectCount; a++)
                {
                    aura.AuraEffects.Add(new AUR_Effect()
                    {
                        Type = aurFile.GetAuraType(BitConverter.ToInt32(bytes, effectOffset)),
                        I_04 = BitConverter.ToInt32(bytes, effectOffset + 4)
                    });
                    effectOffset += 8;
                }

                auraOffset += 16;
                aurFile.Auras.Add(aura);
            }

            //Characters
            for (int i = 0; i < charaCount; i++)
            {
                aurFile.CharacterAuras.Add(new AUR_Character()
                {
                    Index = BitConverter.ToInt32(bytes, charaOffset + (16 * i) + 0).ToString(),
                    I_04  = BitConverter.ToInt32(bytes, charaOffset + (16 * i) + 4),
                    I_08  = BitConverter.ToInt32(bytes, charaOffset + (16 * i) + 8),
                    I_12  = Convert.ToBoolean(BitConverter.ToInt32(bytes, charaOffset + (16 * i) + 12)),
                });
            }

            return(aurFile);
        }
Exemplo n.º 2
0
        public static void Write(AUR_File file, string path)
        {
            byte[] bytes = file.SaveToBytes();

            //Saving
            File.WriteAllBytes(path, bytes.ToArray());
        }
Exemplo n.º 3
0
        public static AUR_File Serialize(string path, bool writeXml)
        {
            byte[] rawBytes = File.ReadAllBytes(path);

            AUR_File file = Load(rawBytes);

            //Write Xml
            if (writeXml)
            {
                YAXSerializer serializer = new YAXSerializer(typeof(AUR_File));
                serializer.SerializeToFile(file, path + ".xml");
            }

            return(file);
        }