コード例 #1
0
        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);
            }
        }
コード例 #2
0
        // 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");
            }
        }
コード例 #3
0
ファイル: Sim.cs プロジェクト: NickThissen/iRacingSdkWrapper
        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);
            }
        }