smoke purpp

This commit is contained in:
ntr committed 2023-08-31 16:55:31 +10:00
1 parent dba4e3fe2b
commit d086069e18
9 files changed
+92 -85

No files matched your search

+24 -17
View File
@@ -134,26 +134,33 @@ public class Timing: MonoBehaviour {
ui.HideRecentLap();
}
public Lap PB() {
if (lapService == null) {
Debug.LogWarning("null lapservice");
return null;
}
return lapService.PB;
public Lap LapRecord => lapService.LapRecord;
public Lap Pb => lapService.Pb;
public TimingNotice CompareLap(Lap lap) {
double? lrSeconds = LapRecord != null ? LapRecord.TotalTime : null;
double? pbSeconds = Pb != null ? Pb.TotalTime : null;
return TimingNotice.Compare(lap.TotalTime, pbSeconds, lrSeconds);
}
public TimingNotice PBSectorDiff(SectorTime s) => PB() switch {
Lap pb => pb.Sectors.SingleOrDefault(fls => fls.Sector == s.Sector) switch {
SectorTime fastestSector => (new TimingNotice { Seconds = s.Seconds }).Compare(fastestSector.Seconds),
null => new TimingNotice { Seconds = s.Seconds }, // this one should never happen
},
null => new TimingNotice { Seconds = s.Seconds }, // there is no pb
};
public TimingNotice CompareSector(SectorTime s) {
double? lrSeconds = LapRecord switch {
null => null,
Lap lr => lr.Sectors.SingleOrDefault(lrs => lrs.Sector == s.Sector) switch {
SectorTime lrSector => lrSector.Seconds,
_ => null,
},
};
public TimingNotice PBLapDiff(Lap lap) => PB() switch {
Lap pb => (new TimingNotice { Seconds = lap.TotalTime }).Compare(pb.TotalTime),
null => new TimingNotice { Seconds = lap.TotalTime },
};
double? pbSeconds = Pb switch {
null => null,
Lap pb => pb.Sectors.SingleOrDefault(pbs => pbs.Sector == s.Sector) switch {
SectorTime pbSector => pbSector.Seconds,
_ => null,
},
};
return TimingNotice.Compare(s.Seconds, pbSeconds, lrSeconds);
}
}