Example #1
0
        public static Vcf ParseVcf(string filename)
        {
            Vcf vcf = new Vcf();

            using (Bwd2Reader br = new Bwd2Reader(filename))
            {
                br.FindNext("VCFC");

                vcf.VariantName             = br.ReadCString(16);
                vcf.VdfFilename             = br.ReadCString(13);
                vcf.VtfFilename             = br.ReadCString(13);
                vcf.EngineType              = br.ReadUInt32();
                vcf.SuspensionType          = br.ReadUInt32();
                vcf.BrakesType              = br.ReadUInt32();
                vcf.WdfFrontFilename        = br.ReadCString(13);
                vcf.WdfMidFilename          = br.ReadCString(13);
                vcf.WdfBackFilename         = br.ReadCString(13);
                vcf.ArmorFront              = br.ReadUInt32();
                vcf.ArmorLeft               = br.ReadUInt32();
                vcf.ArmorRight              = br.ReadUInt32();
                vcf.ArmorRear               = br.ReadUInt32();
                vcf.ChassisFront            = br.ReadUInt32();
                vcf.ChassisLeft             = br.ReadUInt32();
                vcf.ChassisRight            = br.ReadUInt32();
                vcf.ChassisRear             = br.ReadUInt32();
                vcf.ArmorOrChassisLeftToAdd = br.ReadUInt32();

                vcf.Specials = new List <SpecialType>();
                if (br.TryFindNext("SPEC"))
                {
                    vcf.Specials.Add((SpecialType)br.ReadInt32());
                }
                if (br.TryFindNext("SPEC"))
                {
                    vcf.Specials.Add((SpecialType)br.ReadInt32());
                }
                if (br.TryFindNext("SPEC"))
                {
                    vcf.Specials.Add((SpecialType)br.ReadInt32());
                }

                br.FindNext("WEPN");
                vcf.Weapons = new List <VcfWeapon>();
                while (br.Current != null && br.Current.Name != "EXIT")
                {
                    VcfWeapon vcfWeapon = new VcfWeapon
                    {
                        MountPoint  = br.ReadInt32(),
                        GdfFilename = br.ReadCString(13)
                    };

                    vcfWeapon.Gdf = GdfParser.ParseGdf(vcfWeapon.GdfFilename);

                    vcf.Weapons.Add(vcfWeapon);
                    br.Next();
                }
            }

            if (vcf.WdfFrontFilename.ToUpper() != "NULL")
            {
                vcf.FrontWheelDef = WdfParser.ParseWdf(vcf.WdfFrontFilename);
            }
            if (vcf.WdfMidFilename.ToUpper() != "NULL")
            {
                vcf.MidWheelDef = WdfParser.ParseWdf(vcf.WdfMidFilename);
            }
            if (vcf.WdfBackFilename.ToUpper() != "NULL")
            {
                vcf.BackWheelDef = WdfParser.ParseWdf(vcf.WdfBackFilename);
            }

            return(vcf);
        }