Exemple #1
0
        private void ProcessSlotOverrideData(Chunk chunk)
        {
            if ((chunk.Size - 3444) % 0x24 != 0)
            {
                throw new InvalidDataException("BCHUNK_CARINFO_SLOTTYPES is invalid!");
            }

            Progress?.Report("Processing slot override data");

            _carPartService.SetSlotOverrideData(Reader.ReadBytes(3444));

            while (Stream.Position < chunk.EndOffset)
            {
                var ss  = BinaryHelpers.ReadStruct <SpoilerStructure>(Reader);
                var car = _carService.FindCarByHash(ss.CarTypeNameHash);

                car.Spoiler = new AaronSpoilerRecord
                {
                    CarTypeNameHash = ss.CarTypeNameHash,
                    SpoilerType     = (AaronSpoilerType)ss.SpoilerHash
                };
            }
        }
Exemple #2
0
        public void LoadProject(string file)
        {
            CloseProject();

            var project = Serialization.Deserialize <AaronProject>(File.ReadAllText(file));

            project.Path = file;

            if (project.Version != AaronProjectVersion)
            {
                throw new Exception("Incompatible project. Please make a backup and copy your changes to a new project.");
            }

            // set slot override data
            _carPartService.SetSlotOverrideData(project.SlotOverrideData);

            DebugTiming.BeginTiming("LoadCars");

            // load cars
            foreach (var carFilePath in Directory.GetFiles(project.CarsDirectory, "*.json"))
            {
                _carService.AddCar(Serialization.Deserialize <AaronCarRecord>(File.ReadAllText(carFilePath)));
            }
            DebugTiming.EndTiming("LoadCars");

            DebugTiming.BeginTiming("LoadCarParts");

            // load car part
            foreach (var carPartFilePath in Directory.GetFiles(project.CarPartsDirectory, "*.json"))
            {
                var aaronCarPartCollection = Serialization.Deserialize <AaronCarPartCollection>(File.ReadAllText(carPartFilePath));
                _carPartService.AddCarPartCollection(
                    aaronCarPartCollection);
            }

            DebugTiming.EndTiming("LoadCarParts");

            DebugTiming.BeginTiming("LoadPresets");

            // load presets
            foreach (var presetCarFilePath in Directory.GetFiles(project.PresetCarsDirectory, "*.xml"))
            {
                var convertServerXmlToAaronPreset = PresetConverter.ConvertServerXMLToAaronPreset(
                    File.ReadAllText(presetCarFilePath).DataContractDeserializeObject <OwnedCarTrans>());

                convertServerXmlToAaronPreset.PresetName = Path.GetFileNameWithoutExtension(presetCarFilePath);

                _presetCarService.AddPresetCar(convertServerXmlToAaronPreset);
            }

            DebugTiming.EndTiming("LoadPresets");

            DebugTiming.BeginTiming("LoadPresetSkins");

            foreach (var presetSkinFilePath in Directory.GetFiles(project.PresetSkinsDirectory, "*.json"))
            {
                _presetSkinService.AddPresetSkin(
                    Serialization.Deserialize <AaronPresetSkinRecord>(File.ReadAllText(presetSkinFilePath)));
            }

            DebugTiming.EndTiming("LoadPresetSkins");

            DebugTiming.BeginTiming("LoadDataTables");

            foreach (var dataTableFilePath in Directory.GetFiles(project.DataTablesDirectory, "*.json"))
            {
                _dataTableService.AddDataTable(
                    Serialization.Deserialize <AaronDataTable>(File.ReadAllText(dataTableFilePath)));
            }

            DebugTiming.EndTiming("LoadDataTables");

            using (var namesFileStream = File.OpenRead(Path.Combine(Path.GetDirectoryName(file), "strings.json")))
            {
                foreach (var s in Serialization.Deserialize <List <string> >(
                             namesFileStream))
                {
                    _carPartService.AddString(s);
                }
            }

            _project = project;
            Messenger.Default.Send(new ProjectMessage(project));
        }