Пример #1
0
        private void ProcessData()
        {
            EGameState    gameState    = (EGameState)_data.MGameState;
            ESessionState sessionState = (ESessionState)_data.MSessionState;

            if (gameState != _lastGameState)
            {
                if (gameState == EGameState.GameFrontEnd)
                {
                    Reset();
                }
                _lastGameState = gameState;
            }

            if (gameState != EGameState.GameFrontEnd)
            {
                lock (_timingData)
                {
                    if (_timingData.RaceInfo.TrackLongName == null)
                    {
                        if (_data.MTrackLocation.Value != "")
                        {
                            _timingData.RaceInfo.TrackLongName  = _data.MTrackLocation.Value + " " + _data.MTrackVariation.Value;
                            _timingData.RaceInfo.TrackShortName = _data.MTrackLocation.Value;
                            _timingData.RaceInfo.TrackName      = _data.MTrackLocation.Value + " " + _data.MTrackVariation.Value;
                            _timingData.RaceInfo.TrackVariation = _data.MTrackVariation.Value;
                            _timingData.RaceInfo.TrackLength    = (int)_data.MTrackLength;

                            _timingData.RaceInfo.TrackTemperature   = _data.MTrackTemperature;
                            _timingData.RaceInfo.AmbientTemperature = _data.MAmbientTemperature;

                            _trackManager.LoadCurrentTrack(_timingData.RaceInfo.TrackName, _displayName);
                        }
                    }
                }

                lock (_telemetryData)
                {
                    _telemetryData.Car.InCar = true;

                    _telemetryData.Engine.RPM        = _data.MRpm;
                    _telemetryData.Car.Speed         = ConvertSpeedToMPH(_data.MSpeed);
                    _telemetryData.Car.Gear          = _data.MGear;
                    _telemetryData.Car.FuelRemaining = _data.MFuelLevel * _data.MFuelCapacity;
                    _telemetryData.Car.FuelCapacity  = _data.MFuelCapacity;

                    _telemetryData.Engine.WaterTemp = _data.MWaterTempCelsius;

                    _telemetryData.Timing.CurrentLapTime = _data.MCurrentTime;

                    if (_recording)
                    {
                        SetTrackname(_timingData.RaceInfo.TrackName);

                        for (int i = 0; i < _data.MNumParticipants; i++)
                        {
                            float lapDistance = _data.MParticipantInfo[i].mCurrentLapDistance;

                            if (_lastLapDistance[i] == -1 || (Math.Abs(_lastLapDistance[i] - lapDistance) > _recordingDelta))
                            {
                                AddTrackPoint(i, _data.MParticipantInfo[i].mCurrentLap, _data.MParticipantInfo[i].mWorldPosition);
                                _lastLapDistance[i] = lapDistance;
                            }
                        }
                    }

                    if (_trackManager.CurrentTrack != null)
                    {
                        _telemetryData.ResetPlayers();
                        for (int i = 0; i < _data.MNumParticipants; i++)
                        {
                            float x    = -_data.MParticipantInfo[i].mWorldPosition[0] + Math.Abs(_trackManager.CurrentTrack.TrackBounds.MaxGameX);
                            float y    = _data.MParticipantInfo[i].mWorldPosition[2] + Math.Abs(_trackManager.CurrentTrack.TrackBounds.MinGameY);
                            float z    = _data.MParticipantInfo[i].mWorldPosition[1] + Math.Abs(_trackManager.CurrentTrack.TrackBounds.MinGameZ);
                            bool  isMe = false;
                            if (i == _data.MViewedParticipantIndex)
                            {
                                isMe = true;
                            }
                            _telemetryData.AddPlayer(x, y, z, isMe);
                        }
                    }
                }
            }
            else
            {
                _telemetryData.Car.InCar = false;
            }
        }