Ejemplo n.º 1
0
        public void UpdateFuelConsumption(SimulatorDataSet simulatorDataSet)
        {
            if (simulatorDataSet?.PlayerInfo == null)
            {
                return;
            }

            if (simulatorDataSet?.PlayerInfo.CarInfo.FuelSystemInfo.FuelRemaining.InLiters <= 0)
            {
                return;
            }

            if (_lastTickFuelStatus?.SessionTime == simulatorDataSet.SessionInfo.SessionTime)
            {
                return;
            }

            if (SkipThisTick(simulatorDataSet))
            {
                // Force to also skip next tick
                _lastTickFuelStatus = null;
                return;
            }

            if (_lastTickFuelStatus == null)
            {
                _lastTickFuelStatus = new FuelStatusSnapshot(simulatorDataSet);
                return;
            }

            UpdateLapConsumption(simulatorDataSet);
            UpdateMinuteConsumption(simulatorDataSet);

            FuelStatusSnapshot  currentSnapshot         = new FuelStatusSnapshot(simulatorDataSet);
            FuelConsumptionInfo lastTickConsumptionInfo = FuelConsumptionInfo.CreateConsumption(_lastTickFuelStatus, currentSnapshot);

            if (!lastTickConsumptionInfo.IsFuelConsumptionValid(simulatorDataSet))
            {
                _lastTickFuelStatus = currentSnapshot;
                return;
            }

            _totalFuelConsumption = _totalFuelConsumption.AddConsumption(lastTickConsumptionInfo);
            UpdateTotalData(simulatorDataSet);
            _lastTickFuelStatus = currentSnapshot;
        }
Ejemplo n.º 2
0
        private void UpdateLapConsumption(SimulatorDataSet simulatorDataSet)
        {
            if (_lastLapNumber == simulatorDataSet.PlayerInfo.CompletedLaps)
            {
                return;
            }

            _lastLapNumber = simulatorDataSet.PlayerInfo.CompletedLaps;

            if (_lastLapFuelStatus == null)
            {
                _lastLapFuelStatus = new FuelStatusSnapshot(simulatorDataSet);
                return;
            }

            FuelStatusSnapshot  currentLapConsumption = new FuelStatusSnapshot(simulatorDataSet);
            FuelConsumptionInfo fuelConsumption       = FuelConsumptionInfo.CreateConsumption(_lastLapFuelStatus, currentLapConsumption);

            ActPerLap          = fuelConsumption.ConsumedFuel;
            _lastLapFuelStatus = currentLapConsumption;
        }
Ejemplo n.º 3
0
        private void UpdateMinuteConsumption(SimulatorDataSet simulatorDataSet)
        {
            if (_nextMinuteConsumptionUpdate > simulatorDataSet.SessionInfo.SessionTime)
            {
                return;
            }

            _lastDataSet = simulatorDataSet;
            _nextMinuteConsumptionUpdate = _nextMinuteConsumptionUpdate + TimeSpan.FromMinutes(1);

            if (_lastMinuteFuelStatus == null)
            {
                _lastMinuteFuelStatus = new FuelStatusSnapshot(simulatorDataSet);
                return;
            }

            FuelStatusSnapshot  currentMinuteFuelConsumption = new FuelStatusSnapshot(simulatorDataSet);
            FuelConsumptionInfo fuelConsumption = FuelConsumptionInfo.CreateConsumption(_lastMinuteFuelStatus, currentMinuteFuelConsumption);

            ActPerMinute          = fuelConsumption.ConsumedFuel;
            _lastMinuteFuelStatus = currentMinuteFuelConsumption;
        }