public rFactorCarAerodynamics(IniScanner hdv) { _hdv = hdv; if (_hdv.Data.ContainsKey("FRONTWING")) { List <double> fw_factor = new List <double>(); foreach (string d in _hdv.TryGetData("FRONTWING", "FWDragParams")) { fw_factor.Add(double.Parse(d)); } Drag_FrontWing = new Polynomial(fw_factor); } if (_hdv.Data.ContainsKey("REARWING")) { List <double> fw_factor = new List <double>(); foreach (string d in _hdv.TryGetData("REARWING", "RWDragParams")) { fw_factor.Add(double.Parse(d)); } Drag_RearWing = new Polynomial(fw_factor); } if (_hdv.Data.ContainsKey("LEFTFENDER")) { List <double> fw_factor = new List <double>(); foreach (string d in _hdv.TryGetData("LEFTFENDER", "FenderDragParams")) { fw_factor.Add(double.Parse(d)); } Drag_LeftFender = new Polynomial(fw_factor); } if (_hdv.Data.ContainsKey("RIGHTFENDER")) { List <double> fw_factor = new List <double>(); foreach (string d in _hdv.TryGetData("RIGHTFENDER", "FenderDragParams")) { fw_factor.Add(double.Parse(d)); } Drag_RightFender = new Polynomial(fw_factor); } Drag_Body = hdv.TryGetDouble("BODYAERO", "BodyDragBase"); if (Drag_Body == 0) { Drag_Body = double.Parse(hdv.TryGetData("BODYAREO", "BodyDragBase")[0]); } Drag_BodyHeightAvg = hdv.TryGetDouble("BODYAREO", "BodyDragHeightAvg"); Drag_BodyHeightDiff = hdv.TryGetDouble("BODYAREO", "BodyDragHeightDiff"); Drag_Radiator = new Polynomial(0, hdv.TryGetDouble("BODYAREO", "RadiatorDrag")); Drag_BrakesDuct = new Polynomial(0, hdv.TryGetDouble("BODYAREO", "BrakeDuctDrag")); }
public rFactor2CarEngine(MAS2File file, IniScanner mHdv) { masfile = file; EngineTorque_Min = new Dictionary <double, double>(); EngineTorque_Max = new Dictionary <double, double>(); // Read the engine files. scanner = new IniScanner { IniData = file.Master.ExtractString(file) }; scanner.FireEventsForKeys = new List <string>(); scanner.FireEventsForKeys.Add("Main.rpmtorque"); scanner.HandleCustomKeys += new Signal(HandleEngineLine); scanner.Read(); string[] rpm_idle = scanner.TryGetData("Main", "IdleRPMLogic"); string[] rpm_max = scanner.TryGetData("Main", "RevLimitRange"); _maxRpm = Convert.ToDouble(rpm_max[0]) + Convert.ToDouble(rpm_max[2]) * Convert.ToDouble(rpm_max[1]); // With maximum limits. _idleRpm = Convert.ToDouble(rpm_idle[0]) + Convert.ToDouble(rpm_idle[1]); _idleRpm /= 2.0; _inertia = scanner.TryGetDouble("EngineInertia"); // TODO: add more data like cooling, radiator, etc. // Engine modes. string[] mode_range = scanner.TryGetData("Main", "EngineBoostRange"); string[] mode_effects = scanner.TryGetData("Main", "BoostEffects"); // Is there any EngineBoost defined? if (mode_effects.Length == 3) { modes = (int)Convert.ToDouble(mode_range[2]); mode_rpm = Convert.ToDouble(mode_effects[0]); mode_fuel = Convert.ToDouble(mode_effects[1]); mode_wear = Convert.ToDouble(mode_effects[2]); mode_torque = scanner.TryGetDouble("BoostTorque"); mode_power = scanner.TryGetDouble("BoostPower"); } else { modes = 1; } // RAM string[] ram_effects = scanner.TryGetData("Main", "RamEffects"); if (ram_effects.Length == 4) { ram_torque = Convert.ToDouble(ram_effects[0]); ram_power = Convert.ToDouble(ram_effects[1]); ram_fuel = Convert.ToDouble(ram_effects[2]); ram_wear = Convert.ToDouble(ram_effects[3]); } _maxRpmMode = new Dictionary <int, double>(); _engineModes = new Dictionary <int, string>(); for (int i = 1; i <= modes; i++) { _engineModes.Add(i, "Mode " + i); _maxRpmMode.Add(i, mode_rpm * i + MaxRPM); } }
public rFactorCarWheels(IniScanner mHdv) { try { File = mHdv.TryGetString("GENERAL", "TireBrand"); if (File.EndsWith(".tbc") == false) { File = File + ".tbc"; } File = rFactor.Garage.Files.SearchFile(rFactor.Garage.GamedataDirectory, File); var sides = new string[4] { "FRONTLEFT", "FRONTRIGHT", "REARLEFT", "REARRIGHT" }; IniScanner mTyre = new IniScanner { IniFile = File }; mTyre.Read(); foreach (var side in sides) { var brakeTempInfo = new string[4] { "40", "300", "500", "700" }; if (mHdv.Data.ContainsKey(side) && mHdv.Data[side].ContainsKey("brakeresponsecurve")) { brakeTempInfo = mHdv.TryGetData(side, "BrakeResponseCurve"); } var brakeTempLow = double.Parse(brakeTempInfo[1]) + 273; var brakeTempHigh = double.Parse(brakeTempInfo[3]) + 273; var brakeFailureMain = mHdv.TryGetString(side, "BrakeFailure").Split(','); var brakeFailure = double.Parse(brakeFailureMain[0]); var optimalPressure = 158.25; // TODO var radius = 0.3261; // TODO rFactorCarWheel rcw = new rFactorCarWheel(radius, brakeTempHigh, brakeTempLow, brakeFailure, optimalPressure); switch (side) { case "FRONTLEFT": LeftFront = rcw; break; case "FRONTRIGHT": RightFront = rcw; break; case "REARLEFT": LeftRear = rcw; break; case "REARRIGHT": RightRear = rcw; break; } } }catch (Exception e) { LeftFront = new rFactorCarWheel(); RightFront = new rFactorCarWheel(); LeftRear = new rFactorCarWheel(); RightRear = new rFactorCarWheel(); } }