private static Session GetSessionById(StaticRaceWeekend.Weekend w, int sessionNum) { Session ret = null; if (sessionNum == w.Practice.SessionNum) { ret = w.Practice; } else if (sessionNum == w.Qualify.SessionNum) { ret = w.Qualify; } else if (sessionNum == w.HappyHour.SessionNum) { ret = w.HappyHour; } else if (sessionNum == w.Race.SessionNum) { ret = w.Race; } else { ret = null; } w.SetCurrentSession(ret); return(ret); }
private static Session GetSessionToUpdate(StaticRaceWeekend.Weekend w, TelemetryEvents.SessionInfo e) { Session ret = null; switch (e.SessionType) { case TelemetryEvents.SessionInfo.eSessionType.kSessionTypePractice: ret = w.Practice; break; case TelemetryEvents.SessionInfo.eSessionType.kSessionTypeQualifyLone: case TelemetryEvents.SessionInfo.eSessionType.kSessionTypeQualifyOpen: ret = w.Qualify; break; case TelemetryEvents.SessionInfo.eSessionType.kSessionTypeTesting: ret = w.HappyHour; break; case TelemetryEvents.SessionInfo.eSessionType.kSessionTypeRace: ret = w.Race; break; default: throw new NotImplementedException(); } return(ret); }
internal static void Update(StaticRaceWeekend.Weekend w, TelemetryEvents.Standings e, out Session updatedSession) { var s = GetSessionById(w, e.SessionNum); if (s == null) { throw new Exception("Invalid session number."); } UpdateSession(s, e); updatedSession = s; }
internal static void Update(StaticRaceWeekend.Weekend w, TelemetryEvents.SessionInfo e, out Session changedSession) { w.CurrentSessionType = GetSessionType(e.SessionType); Session s = GetSessionToUpdate(w, e); s.SessionNum = e.SessionNum; if (s is NonRaceSession) { UpdateNonRaceSession(s as NonRaceSession, e); } else { UpdateRaceSession(s as RaceSession, e); } w.SetCurrentSession(s); changedSession = s; }