Exemple #1
0
        public static VehicleSetupConfig Load(string pathToFile)
        {
            VehicleSetupConfig setup = new VehicleSetupConfig();

            using (DocumentParser doc = new DocumentParser(pathToFile))
            {
                string line = doc.ReadFirstLine();

                while (line != null)
                {
                    switch (line)
                    {
                    case "[default_driver]":
                        while (!doc.NextLineIsASection() && !doc.EOF())
                        {
                            setup.Drivers.Add(doc.ReadNextLine());
                        }
                        break;

                    case "[driver_suffix]":
                        setup.DriverSuffix = doc.ReadNextLine();
                        break;

                    case "[attachment]":
                        setup.Attachments.Add(new VehicleAttachment(doc));
                        break;

                    case "[wheel_module]":
                        setup.WheelModules.Add(new VehicleWheelModule(doc));
                        break;

                    case "[suspension_factors]":
                        setup.SuspensionFactors = new VehicleSuspensionFactors(doc);
                        break;

                    case "[ai_script]":
                        setup.AIScript = doc.ReadNextLine();
                        break;

                    case "[material_map]":
                        setup.MaterialMaps.Add(new VehicleMaterialMap(doc));
                        break;

                    case "[wheel_map]":
                        setup.WheelMaps.Add(new VehicleWheelMap(doc));
                        break;

                    case "[disable_ejection]":
                        setup.EjectDriver = false;
                        break;

                    case "[stats]":
                        setup.Stats.TopSpeed  = doc.ReadInt();
                        setup.Stats.Time      = doc.ReadFloat();
                        setup.Stats.Weight    = doc.ReadFloat();
                        setup.Stats.Toughness = doc.ReadFloat();
                        if (!doc.EOF() && !doc.NextLineIsASection())
                        {
                            setup.Stats.UnlockLevel = doc.ReadFloat();
                        }
                        break;

                    case "[decal_points]":
                        while (!doc.NextLineIsASection() && !doc.EOF())
                        {
                            setup.DecalPoints.Add(doc.ReadVector3());
                        }
                        break;

                    case "[in_car_cam_offset]":
                        setup.InCarCamOffset = doc.ReadVector3();
                        break;

                    case "[garage_camera_offset]":
                        setup.GarageCameraOffset = doc.ReadVector3();
                        break;

                    case "[small_driver]":
                        setup.SmallDriver = true;
                        break;

                    case "[Human_Trailer]":
                        while (!doc.NextLineIsASection() && !doc.EOF())
                        {
                            setup.HumanTrailer.Add(doc.ReadNextLine());
                        }
                        break;

                    case "[AI_Trailer]":
                        while (!doc.NextLineIsASection() && !doc.EOF())
                        {
                            setup.AITrailer.Add(doc.ReadNextLine());
                        }
                        break;

                    case "[MP_Trailer]":
                        while (!doc.NextLineIsASection() && !doc.EOF())
                        {
                            setup.MPTrailer.Add(doc.ReadNextLine());
                        }
                        break;

                    default:
                        throw new NotImplementedException("Unexpected [SECTION]: " + line);
                    }

                    line = doc.ReadNextLine();
                }
            }

            return(setup);
        }
        public static VehicleSetupConfig Load(string pathToFile)
        {
            VehicleSetupConfig setup = new VehicleSetupConfig();

            using (var doc = new DocumentParser(pathToFile))
            {
                string line = doc.ReadFirstLine();

                while (line != null)
                {
                    switch (line)
                    {
                        case "[default_driver]":
                            while (!doc.NextLineIsASection() && !doc.EOF())
                            {
                                setup.Drivers.Add(doc.ReadNextLine());
                            }
                            break;

                        case "[attachment]":
                            setup.Attachments.Add(new VehicleAttachment(doc));
                            break;

                        case "[wheel_module]":
                            setup.WheelModules.Add(new VehicleWheelModule(doc));
                            break;

                        case "[suspension_factors]":
                            setup.SuspensionFactors = new VehicleSuspensionFactors(doc);
                            break;

                        case "[ai_script]":
                            setup.AIScript = doc.ReadNextLine();
                            break;

                        case "[material_map]":
                            setup.MaterialMaps.Add(new VehicleMaterialMap(doc));
                            break;

                        case "[wheel_map]":
                            setup.WheelMaps.Add(new VehicleWheelMap(doc));
                            break;

                        case "[disable_ejection]":
                            setup.EjectDriver = false;
                            break;

                        case "[stats]":
                            setup.Stats.TopSpeed = doc.ReadInt();
                            setup.Stats.Time = doc.ReadFloat();
                            setup.Stats.Weight = doc.ReadFloat();
                            setup.Stats.Toughness = doc.ReadFloat();
                            if (!doc.EOF() && !doc.NextLineIsASection()) { setup.Stats.UnlockLevel = doc.ReadFloat(); }
                            break;

                        case "[decal_points]":
                            while (!doc.NextLineIsASection() && !doc.EOF())
                            {
                                setup.DecalPoints.Add(doc.ReadVector3());
                            }
                            break;

                        default:
                            Console.WriteLine(pathToFile);
                            throw new NotImplementedException("Unexpected [SECTION]: " + line);
                    }

                    line = doc.ReadNextLine();
                }
            }

            return setup;
        }
        public override void Export(Asset asset, string path)
        {
            var model = (asset as Model);

            if (model.SupportingDocuments.ContainsKey("VehicleSetupConfig"))
            {
                ((VehicleSetupConfig)model.SupportingDocuments["VehicleSetupConfig"]).Save(path);
            }
            else
            {
                var vehicleSetup = new VehicleSetupConfig();

                vehicleSetup.Attachments.Add(
                    new VehicleAttachment {
                        Type = VehicleAttachment.AttachmentType.DynamicsWheels
                    }
                );

                vehicleSetup.WheelModules.Add(
                    new VehicleWheelModule {
                        Type = VehicleWheelModule.WheelModuleType.SkidMarks,
                        SkidMarkImage = "skidmark"
                    }
                );

                vehicleSetup.WheelModules.Add(
                    new VehicleWheelModule {
                        Type = VehicleWheelModule.WheelModuleType.TyreParticles,
                        TyreParticleVFX = "effects.drift"
                    }
                );

                vehicleSetup.WheelModules.Add(
                    new VehicleWheelModule {
                        Type = VehicleWheelModule.WheelModuleType.SkidNoise,
                        SkidNoiseSound = "sounds\\tyre\\skid1,sounds\\tyre\\skid2"
                    }
                );

                vehicleSetup.Attachments.Add(
                    new VehicleAttachment
                    {
                        Type = VehicleAttachment.AttachmentType.Horn,
                        Horn = "generic02_horn"
                    }
                );

                vehicleSetup.WheelMaps.Add(
                    new VehicleWheelMap
                    {
                        Name = "default",
                        Localisation = string.Format("FE_CAR_{0}_RIM_DEFAULT", this.ExportSettings.GetSetting<string>("VehicleName")),
                        Wheels = new VehicleAttachmentComplicatedWheels
                        {
                            FLWheel = "default_eagle_R",
                            FRWheel = "default_eagle_R",
                            RLWheel = "default_eagle_R",
                            RRWheel = "default_eagle_R"
                        }
                    }
                );

                vehicleSetup.Stats.TopSpeed = 160;
                vehicleSetup.Stats.Time = 3.00f;
                vehicleSetup.Stats.Weight = 1.3f;
                vehicleSetup.Stats.Toughness = 1.4f;
                vehicleSetup.Stats.UnlockLevel = 0;

                vehicleSetup.Save(path);
            }
        }