Ejemplo n.º 1
0
 internal void ValidateLapBasedOnSurface(DriverInfo driverInfo, RfVehicleInfo rfVehicleInfo)
 {
     if (!driverInfo.CurrentLapValid)
     {
         return;
     }
 }
Ejemplo n.º 2
0
        internal void AddDriversData(SimulatorDataSet data, RfShared rfData)
        {
            if (rfData.NumVehicles < 1)
            {
                return;
            }

            data.DriversInfo = new DriverInfo[rfData.NumVehicles];
            DriverInfo playersInfo = null;

            for (int i = 0; i < rfData.NumVehicles; i++)
            {
                RfVehicleInfo rfVehicleInfo = rfData.Vehicle[i];
                DriverInfo    driverInfo    = CreateDriverInfo(rfData, rfVehicleInfo);

                if (driverInfo.IsPlayer)
                {
                    playersInfo = driverInfo;
                    driverInfo.CurrentLapValid = true;
                }
                else
                {
                    driverInfo.CurrentLapValid = true;
                }

                data.DriversInfo[i] = driverInfo;
                if (driverInfo.Position == 1)
                {
                    data.SessionInfo.LeaderCurrentLap = driverInfo.CompletedLaps + 1;
                    data.LeaderInfo = driverInfo;
                }

                if (rfVehicleInfo.Control == 2)
                {
                    data.SessionInfo.IsMultiplayer = true;
                }

                AddLappingInformation(data, rfData, driverInfo);
                FillTimingInfo(driverInfo, rfVehicleInfo, rfData);
            }
            CheckValidityByPlayer(playersInfo);
            _lastPlayer = playersInfo;
            if (playersInfo != null)
            {
                data.PlayerInfo = playersInfo;
            }

            FillGapInformation(data.DriversInfo);
        }
Ejemplo n.º 3
0
        private DriverInfo CreateDriverInfo(RfShared rfData, RfVehicleInfo rfVehicleInfo)
        {
            DriverInfo driverInfo = new DriverInfo
            {
                DriverName    = StringExtensions.FromArray(rfVehicleInfo.DriverName),
                CompletedLaps = rfVehicleInfo.TotalLaps,
                CarName       = StringExtensions.FromArray(rfVehicleInfo.VehicleClass),
                InPits        = rfVehicleInfo.InPits == 1
            };

            driverInfo.IsPlayer      = rfVehicleInfo.IsPlayer == 1;
            driverInfo.Position      = rfVehicleInfo.Place;
            driverInfo.Speed         = Velocity.FromMs(rfVehicleInfo.Speed);
            driverInfo.LapDistance   = rfVehicleInfo.LapDist >= 0 ? rfVehicleInfo.LapDist : rfData.LapDist + rfVehicleInfo.LapDist;
            driverInfo.TotalDistance = rfVehicleInfo.TotalLaps * rfData.LapDist + driverInfo.LapDistance;
            driverInfo.FinishStatus  = FromRFStatus(rfVehicleInfo.FinishStatus);
            driverInfo.WorldPosition = new Point3D(Distance.FromMeters(rfVehicleInfo.Pos.X), Distance.FromMeters(rfVehicleInfo.Pos.Y), Distance.FromMeters(rfVehicleInfo.Pos.Z));
            ComputeDistanceToPlayer(_lastPlayer, driverInfo, rfData);
            return(driverInfo);
        }
Ejemplo n.º 4
0
        internal void FillTimingInfo(DriverInfo driverInfo, RfVehicleInfo rfVehicleInfo, RfShared rfShared)
        {
            driverInfo.Timing.LastSector1Time = CreateTimeSpan(rfVehicleInfo.CurSector1);
            driverInfo.Timing.LastSector2Time = CreateTimeSpan(rfVehicleInfo.CurSector2 - rfVehicleInfo.CurSector1);
            driverInfo.Timing.LastSector3Time = CreateTimeSpan(rfVehicleInfo.LastLapTime - rfVehicleInfo.LastSector2);
            driverInfo.Timing.LastLapTime     = CreateTimeSpan(rfVehicleInfo.LastLapTime);
            driverInfo.Timing.CurrentSector   = rfVehicleInfo.Sector == 0 ? 3 : rfVehicleInfo.Sector;

            switch (driverInfo.Timing.CurrentSector)
            {
            case 1:
                driverInfo.Timing.CurrentLapTime = CreateTimeSpan(rfVehicleInfo.CurSector1);
                break;

            case 2:
                driverInfo.Timing.CurrentLapTime = CreateTimeSpan(rfVehicleInfo.CurSector2);
                break;

            case 0:
                driverInfo.Timing.CurrentLapTime = CreateTimeSpan(rfVehicleInfo.LastLapTime);
                break;
            }
        }