private void OnRaceFinished(object sender, GameEndedArgs e) {
var basic = e.StartProperties.BasicProperties;
var bestLap = e.Result?.GetExtraByType<Game.ResultExtraBestLap>();
var time = basic?.CarId == null || basic.TrackId == null || bestLap == null ||
bestLap.IsCancelled ? null : bestLap?.Time;
if (SettingsHolder.Drive.WatchForSharedMemory) {
var sharedTime = PlayerStatsManager.Instance.Last?.BestLap;
if (sharedTime.HasValue) {
time = sharedTime.Value;
}
}
if (time.HasValue) {
AddEntry(new LapTimeEntry(SourceId,
basic.CarId, basic.TrackId, basic.TrackConfigurationId,
DateTime.Now, time.Value));
}
}