internal void FillTimingInfo(DriverInfo driverInfo, DriverData r3EDriverData, R3ESharedData r3RData) { if (driverInfo.IsPlayer) { driverInfo.Timing.LastLapTime = r3RData.LapTimePreviousSelf != -1 ? TimeSpan.FromSeconds(r3RData.LapTimePreviousSelf) : TimeSpan.Zero; if (r3RData.SectorTimesCurrentSelf.Sector1 != -1 || r3RData.SectorTimesCurrentSelf.Sector2 != -1 || r3RData.SectorTimesPreviousSelf.Sector3 != -1) { driverInfo.Timing.LastSector1Time = TimeSpan.FromSeconds(r3RData.SectorTimesCurrentSelf.Sector1); driverInfo.Timing.LastSector2Time = TimeSpan.FromSeconds(r3RData.SectorTimesCurrentSelf.Sector2 - r3RData.SectorTimesCurrentSelf.Sector1); driverInfo.Timing.LastSector3Time = TimeSpan.FromSeconds(r3RData.SectorTimesPreviousSelf.Sector3 - r3RData.SectorTimesPreviousSelf.Sector2); } driverInfo.Timing.CurrentSector = r3EDriverData.TrackSector; driverInfo.Timing.CurrentLapTime = TimeSpan.FromSeconds(r3RData.LapTimeCurrentSelf); return; } if (r3EDriverData.SectorTimesCurrentSelf.Sector1 != -1 || r3EDriverData.SectorTimesCurrentSelf.Sector2 != -1 || r3EDriverData.SectorTimesPreviousSelf.Sector3 != -1) { driverInfo.Timing.LastSector1Time = TimeSpan.FromSeconds(r3EDriverData.SectorTimesCurrentSelf.Sector1); driverInfo.Timing.LastSector2Time = TimeSpan.FromSeconds(r3EDriverData.SectorTimesCurrentSelf.Sector2 - r3EDriverData.SectorTimesCurrentSelf.Sector1); driverInfo.Timing.LastSector3Time = TimeSpan.FromSeconds(r3EDriverData.SectorTimesPreviousSelf.Sector3 - r3EDriverData.SectorTimesPreviousSelf.Sector2); } driverInfo.Timing.CurrentLapTime = TimeSpan.FromSeconds(r3EDriverData.LapTimeCurrentSelf); driverInfo.Timing.LastLapTime = r3EDriverData.SectorTimesPreviousSelf.Sector3 != -1 ? TimeSpan.FromSeconds(r3EDriverData.SectorTimesPreviousSelf.Sector3) : TimeSpan.Zero; driverInfo.Timing.CurrentSector = r3EDriverData.TrackSector; }
internal void AddDriversData(SimulatorDataSet data, R3ESharedData r3RData) { if (r3RData.NumCars == -1) { return; } data.DriversInfo = new DriverInfo[r3RData.NumCars]; string playerName = FromByteArray(r3RData.PlayerName); DriverInfo playersInfo = null; for (int i = 0; i < r3RData.NumCars; i++) { DriverData r3RDriverData = r3RData.DriverData[i]; DriverInfo driverInfo = CreateDriverInfo(r3RData, r3RDriverData, playerName); /*if (string.IsNullOrWhiteSpace(driverInfo.DriverName)) * { * continue; * }*/ if (driverInfo.IsPlayer) { playersInfo = driverInfo; driverInfo.CurrentLapValid = r3RData.CurrentLapValid == 1; _lastPlayer = driverInfo; } else { AddWheelInfo(driverInfo, r3RDriverData); driverInfo.CurrentLapValid = r3RDriverData.CurrentLapValid == 1; } AddWheelInfo(driverInfo, r3RDriverData); data.DriversInfo[i] = driverInfo; if (driverInfo.Position == 1) { data.SessionInfo.LeaderCurrentLap = driverInfo.CompletedLaps + 1; data.LeaderInfo = driverInfo; } AddLappingInformation(data, r3RData, driverInfo); FillTimingInfo(driverInfo, r3RDriverData, r3RData); if (driverInfo.FinishStatus == DriverFinishStatus.Finished && !driverInfo.IsPlayer && driverInfo.Position > _lastPlayer?.Position) { driverInfo.CompletedLaps--; driverInfo.FinishStatus = DriverFinishStatus.None; } _connector.StoreLastTickInfo(driverInfo); } if (playersInfo != null) { data.PlayerInfo = playersInfo; } }
private static void AddWheelInfo(DriverInfo driverInfo, DriverData r3RDriverData) { driverInfo.CarInfo.WheelsInfo.FrontLeft.TyreType = ((Constant.TireSubtype)r3RDriverData.TireSubtypeFront).ToString(); driverInfo.CarInfo.WheelsInfo.FrontLeft.TyreTypeFilled = ((Constant.TireSubtype)r3RDriverData.TireSubtypeFront) != Constant.TireSubtype.Unavailable; driverInfo.CarInfo.WheelsInfo.FrontRight.TyreType = driverInfo.CarInfo.WheelsInfo.FrontLeft.TyreType; driverInfo.CarInfo.WheelsInfo.FrontRight.TyreTypeFilled = driverInfo.CarInfo.WheelsInfo.FrontLeft.TyreTypeFilled; driverInfo.CarInfo.WheelsInfo.RearLeft.TyreTypeFilled = ((Constant.TireSubtype)r3RDriverData.TireSubtypeRear) != Constant.TireSubtype.Unavailable; driverInfo.CarInfo.WheelsInfo.RearLeft.TyreType = ((Constant.TireSubtype)r3RDriverData.TireSubtypeRear).ToString(); driverInfo.CarInfo.WheelsInfo.RearRight.TyreType = driverInfo.CarInfo.WheelsInfo.RearLeft.TyreType; driverInfo.CarInfo.WheelsInfo.RearRight.TyreTypeFilled = driverInfo.CarInfo.WheelsInfo.RearLeft.TyreTypeFilled; }
private static void AddWheelInfo(DriverInfo driverInfo, DriverData r3RDriverData) { driverInfo.CarInfo.WheelsInfo.FrontLeft.TyreType = ((Constant.TireSubtype)r3RDriverData.TireSubtypeFront).ToString(); driverInfo.CarInfo.WheelsInfo.FrontRight.TyreType = driverInfo.CarInfo.WheelsInfo.FrontLeft.TyreType; driverInfo.CarInfo.WheelsInfo.RearLeft.TyreType = ((Constant.TireSubtype)r3RDriverData.TireSubtypeRear).ToString(); driverInfo.CarInfo.WheelsInfo.RearRight.TyreType = driverInfo.CarInfo.WheelsInfo.RearLeft.TyreType; if (driverInfo.CarInfo.WheelsInfo.FrontLeft.TyreType == "Unavailable") { driverInfo.CarInfo.WheelsInfo.FrontLeft.TyreType = "Prime"; driverInfo.CarInfo.WheelsInfo.FrontRight.TyreType = "Prime"; } if (driverInfo.CarInfo.WheelsInfo.RearLeft.TyreType == "Unavailable") { driverInfo.CarInfo.WheelsInfo.RearLeft.TyreType = "Prime"; driverInfo.CarInfo.WheelsInfo.RearRight.TyreType = "Prime"; } }
private DriverInfo CreateDriverInfo(R3ESharedData r3RData, DriverData r3RDriverData, string playerName) { DriverInfo driverInfo = new DriverInfo { DriverName = FromByteArray(r3RDriverData.DriverInfo.Name), CompletedLaps = r3RDriverData.CompletedLaps, CarName = string.Empty, InPits = r3RDriverData.InPitlane == 1 }; driverInfo.IsPlayer = driverInfo.DriverName == playerName; driverInfo.Position = r3RDriverData.Place; driverInfo.Speed = Velocity.FromMs(r3RDriverData.CarSpeed); driverInfo.LapDistance = r3RDriverData.LapDistance; driverInfo.TotalDistance = r3RDriverData.CompletedLaps * r3RData.LayoutLength + r3RDriverData.LapDistance; driverInfo.CarName = _database.GetCarName(r3RDriverData.DriverInfo.ModelId); driverInfo.FinishStatus = FromR3RStatus(r3RDriverData.FinishStatus); driverInfo.WorldPosition = new Point3D(Distance.FromMeters(r3RDriverData.Position.X), Distance.FromMeters(r3RDriverData.Position.Y), Distance.FromMeters(r3RDriverData.Position.Z)); ComputeDistanceToPlayer(_lastPlayer, driverInfo, r3RData); return(driverInfo); }