private void CheckSessionFlagUpdates(SessionFlag prevFlags, SessionFlag curFlags) { if (prevFlags == null || curFlags == null) { return; } var go = SessionFlags.StartGo; var green = SessionFlags.Green; var yellow = SessionFlags.Caution; bool isGreen = !prevFlags.Contains(go) && curFlags.Contains(go) || !prevFlags.Contains(green) && curFlags.Contains(green); if (isGreen) { var e = new GreenFlagRaceEvent(); e.SessionTime = _telemetry.SessionTime.Value; e.Lap = Leader == null ? 0 : Leader.Live.Lap; this.OnRaceEvent(e); } if (!prevFlags.Contains(yellow) && curFlags.Contains(yellow)) { var e = new YellowFlagRaceEvent(); e.SessionTime = _telemetry.SessionTime.Value; e.Lap = Leader == null ? 0 : Leader.Live.Lap; this.OnRaceEvent(e); } }
// Example method that adds some caution flags to the string builder if they are displayed in the sim private void BitfieldsExample(StringBuilder sb, SdkWrapper.TelemetryUpdatedEventArgs e) { // The value of SessionFlags returns a SessionFlag object which contains information about all currently active flags // Use the Contains method to check if it contains a specific flag. // EngineWarnings and CameraStates behave similarly. SessionFlag flags = e.TelemetryInfo.SessionFlags.Value; if (flags.Contains(SessionFlags.Black)) { sb.AppendLine("Black flag!"); } if (flags.Contains(SessionFlags.Disqualify)) { sb.AppendLine("DQ"); } if (flags.Contains(SessionFlags.Repair)) { sb.AppendLine("Repair"); } if (flags.Contains(SessionFlags.Checkered)) { sb.AppendLine("Checkered"); } }
private void CheckSessionFlagUpdates(SessionFlag prevFlags, SessionFlag curFlags) { if (prevFlags == null || curFlags == null) return; var go = SessionFlags.StartGo; var green = SessionFlags.Green; var yellow = SessionFlags.Caution; bool isGreen = !prevFlags.Contains(go) && curFlags.Contains(go) || !prevFlags.Contains(green) && curFlags.Contains(green); if (isGreen) { var e= new GreenFlagRaceEvent(); e.SessionTime = _telemetry.SessionTime.Value; e.Lap = Leader == null ? 0 : Leader.Live.Lap; this.OnRaceEvent(e); } if (!prevFlags.Contains(yellow) && curFlags.Contains(yellow)) { var e = new YellowFlagRaceEvent(); e.SessionTime = _telemetry.SessionTime.Value; e.Lap = Leader == null ? 0 : Leader.Live.Lap; this.OnRaceEvent(e); } }