Пример #1
0
        private DriverInfo CreateDriverInfo(AllPacketsComposition rawData, string driverName, int driverIndex)
        {
            var        rawDriverData    = rawData.PacketParticipantsData.MParticipants[driverIndex];
            var        rawDriverLapInfo = rawData.PacketLapData.MLapData[driverIndex];
            var        rawCarMotionData = rawData.PacketMotionData.MCarMotionData[driverIndex];
            DriverInfo driverInfo       = new DriverInfo
            {
                DriverName      = driverName,
                CompletedLaps   = rawDriverLapInfo.MCurrentLapNum - 1,
                CarName         = string.Empty,
                InPits          = rawDriverLapInfo.MPitStatus != 0 || rawDriverLapInfo.MDriverStatus == 0,
                IsPlayer        = driverIndex == rawData.PacketCarTelemetryData.MHeader.MPlayerCarIndex,
                Position        = rawDriverLapInfo.MCarPosition,
                PositionInClass = rawDriverLapInfo.MCarPosition,
                Speed           = Velocity.FromKph(rawData.PacketCarTelemetryData.MCarTelemetryData[driverIndex].MSpeed),
                LapDistance     = rawDriverLapInfo.MLapDistance >= 0 ? rawDriverLapInfo.MLapDistance : rawData.PacketSessionData.MTrackLength + rawDriverLapInfo.MLapDistance,
                TotalDistance   = rawDriverLapInfo.MTotalDistance
            };

            driverInfo.CarName         = TranslationTable.GetCarName(rawDriverData.MTeamId);
            driverInfo.CarClassName    = TranslationTable.GetClass(rawData.PacketSessionData.MFormula);
            driverInfo.CarClassId      = driverInfo.CarClassName;
            driverInfo.FinishStatus    = rawData.AdditionalData.RetiredDrivers[driverIndex] ? DriverFinishStatus.Dnf : TranslateFinishStatus(rawDriverLapInfo.MResultStatus);
            driverInfo.WorldPosition   = new Point3D(Distance.FromMeters(rawCarMotionData.MWorldPositionX), Distance.FromMeters(rawCarMotionData.MWorldPositionY), Distance.FromMeters(rawCarMotionData.MWorldPositionZ));
            driverInfo.CurrentLapValid = rawDriverLapInfo.MCurrentLapInvalid == 0 && rawDriverLapInfo.MDriverStatus != 2 && rawDriverLapInfo.MDriverStatus != 3;

            ComputeDistanceToPlayer(_lastPlayer, driverInfo);
            FillTimingInfo(driverInfo, rawDriverLapInfo, driverIndex);
            return(driverInfo);
        }
Пример #2
0
        private static void AddWheelInfo(DriverInfo driverInfo, CarStatusData rawCarStatus)
        {
            string tyreType = TranslationTable.GetTyreCompound(rawCarStatus.MTyreVisualCompound);

            driverInfo.CarInfo.WheelsInfo.FrontLeft.TyreType  = tyreType;
            driverInfo.CarInfo.WheelsInfo.FrontRight.TyreType = tyreType;

            driverInfo.CarInfo.WheelsInfo.RearLeft.TyreType  = tyreType;
            driverInfo.CarInfo.WheelsInfo.RearRight.TyreType = tyreType;

            string tyreVisualType = TranslationTable.GetTyreVisualCompound(rawCarStatus.MTyreVisualCompound);

            driverInfo.CarInfo.WheelsInfo.FrontLeft.TyreVisualType  = tyreVisualType;
            driverInfo.CarInfo.WheelsInfo.FrontRight.TyreVisualType = tyreVisualType;

            driverInfo.CarInfo.WheelsInfo.RearLeft.TyreVisualType  = tyreVisualType;
            driverInfo.CarInfo.WheelsInfo.RearRight.TyreVisualType = tyreVisualType;
        }
Пример #3
0
        private void FillSessionInfo(AllPacketsComposition data, SimulatorDataSet simData)
        {
            // Timing
            simData.SessionInfo.SessionTime = TimeSpan.FromSeconds(data.PacketCarTelemetryData.MHeader.MSessionTime);
            _layoutLength    = data.PacketSessionData.MTrackLength;
            _playerDataIndex = data.PacketSessionData.MHeader.MPlayerCarIndex;
            simData.SessionInfo.TrackInfo.LayoutLength = Distance.FromMeters(_layoutLength);
            simData.SessionInfo.IsActive = true;
            simData.SessionInfo.WeatherInfo.AirTemperature   = Temperature.FromCelsius(data.PacketSessionData.MAirTemperature);
            simData.SessionInfo.WeatherInfo.TrackTemperature = Temperature.FromCelsius(data.PacketSessionData.MTrackTemperature);
            if (data.PacketSessionData.MWeather == 3)
            {
                simData.SessionInfo.WeatherInfo.RainIntensity = 30;
            }
            else if (data.PacketSessionData.MWeather == 4)
            {
                simData.SessionInfo.WeatherInfo.RainIntensity = 60;
            }
            else if (data.PacketSessionData.MWeather == 5)
            {
                simData.SessionInfo.WeatherInfo.RainIntensity = 100;
            }


            switch ((SessionKind)data.PacketSessionData.MSessionType)
            {
            case SessionKind.TimeTrial:
            case SessionKind.Practice1:
            case SessionKind.Practice2:
            case SessionKind.Practice3:
            case SessionKind.ShortPractice:
                simData.SessionInfo.SessionType = SessionType.Practice;
                break;

            case SessionKind.Qualification1:
            case SessionKind.Qualification2:
            case SessionKind.Qualification3:
            case SessionKind.ShortQualification:
            case SessionKind.OnlineQualification:
                simData.SessionInfo.SessionType = SessionType.Qualification;
                break;

            case SessionKind.Race:
            case SessionKind.Race2:
                simData.SessionInfo.SessionType = SessionType.Race;
                break;

            default:
                simData.SessionInfo.SessionType = SessionType.Na;
                break;
            }

            simData.SessionInfo.SessionPhase = SessionPhase.Green;

            simData.SessionInfo.TrackInfo.TrackName       = TranslationTable.GetTrackName(data.PacketSessionData.MTrackId);
            simData.SessionInfo.TrackInfo.TrackLayoutName = string.Empty;

            if (data.PacketSessionData.MTotalLaps > 2 && simData.SessionInfo.SessionType == SessionType.Race)
            {
                simData.SessionInfo.SessionLengthType = SessionLengthType.Laps;
                simData.SessionInfo.TotalNumberOfLaps = data.PacketSessionData.MTotalLaps;
            }
            else
            {
                simData.SessionInfo.SessionLengthType    = SessionLengthType.Time;
                simData.SessionInfo.SessionTimeRemaining = data.PacketSessionData.MSessionTimeLeft;
            }
        }