awake todo

This commit is contained in:
ntr committed 2023-08-29 21:26:03 +10:00
1 parent cebc2ef588
commit 6450d3b093
3 files changed
+16 -10

No files matched your search

+12 -3
View File
@@ -39,6 +39,9 @@ public class Timing: MonoBehaviour {
Debug.Log("Track Sector Count - " + sectors.Length);
lapService = new LapService(mapName);
}
void Start() {
StartCoroutine(lapService.GetPb());
}
@@ -131,9 +134,15 @@ public class Timing: MonoBehaviour {
ui.HideRecentLap();
}
public Lap PB => lapService.PB;
public Lap PB() {
if (lapService == null) {
Debug.LogWarning("null lapservice");
return null;
}
return lapService.PB;
}
public TimingNotice PBSectorDiff(SectorTime s) => PB switch {
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
@@ -141,7 +150,7 @@ public class Timing: MonoBehaviour {
null => new TimingNotice { Seconds = s.Seconds }, // there is no pb
};
public TimingNotice PBLapDiff(Lap lap) => PB switch {
public TimingNotice PBLapDiff(Lap lap) => PB() switch {
Lap pb => (new TimingNotice { Seconds = lap.TotalTime }).Compare(pb.TotalTime),
null => new TimingNotice { Seconds = lap.TotalTime },
};