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; }