This commit is contained in:
ntr committed 2023-09-01 22:27:50 +10:00
1 parent cffe1930a0
commit 9f5ce196cc
9 files changed
+90 -17

No files matched your search

+20 -8
View File
@@ -26,6 +26,16 @@ public class LapService {
public Lap Pb;
public Lap LapRecord;
public string Position => _pb switch {
PbDTO pb => pb.Position.ToString(),
null => "-",
};
public string Completions => _lr switch {
PbDTO lr => lr.Completions.ToString(),
null => "-",
};
public LapService(string mapName) {
_mapName = mapName;
LoadPlayerData();
@@ -54,15 +64,17 @@ public class LapService {
_pb = dto.Pb;
_lr = dto.LapRecord;
Pb = new Lap {
Map = _pb.Map,
Sectors = _pb.Sectors.Select((d, i) => new SectorTime { Sector = i + 1, Seconds = d }).ToList(),
};
if (dto.Pb != null)
Pb = new Lap {
Map = _pb.Map,
Sectors = _pb.Sectors.Select((d, i) => new SectorTime { Sector = i + 1, Seconds = d }).ToList(),
};
LapRecord = new Lap {
Map = _lr.Map,
Sectors = _lr.Sectors.Select((d, i) => new SectorTime { Sector = i + 1, Seconds = d }).ToList(),
};
if (dto.LapRecord != null)
LapRecord = new Lap {
Map = _lr.Map,
Sectors = _lr.Sectors.Select((d, i) => new SectorTime { Sector = i + 1, Seconds = d }).ToList(),
};
} catch (Exception e) {
Debug.LogWarning($"Failed to set lap times {e}");
_pb = null;