public static CornerData getCornerData(List<EnumWithThresholds> enumsWithThresholds, float leftFrontValue, float rightFrontValue, float leftRearValue, float rightRearValue)
 {
     CornerData cornerData = new CornerData();
     foreach (EnumWithThresholds enumWithThresholds in enumsWithThresholds)
     {
         if (leftFrontValue >= enumWithThresholds.lowerThreshold && leftFrontValue < enumWithThresholds.upperThreshold)
         {
             if (rightFrontValue >= enumWithThresholds.lowerThreshold && rightFrontValue < enumWithThresholds.upperThreshold)
             {
                 if (leftRearValue >= enumWithThresholds.lowerThreshold && leftRearValue < enumWithThresholds.upperThreshold &&
                     rightRearValue >= enumWithThresholds.lowerThreshold && rightRearValue < enumWithThresholds.upperThreshold)
                 {
                     // it's 'whatever' all around
                     addCornerStatus(cornerData, enumWithThresholds.e, Corners.ALL);
                 }
                 else
                 {
                     // front sides
                     addCornerStatus(cornerData, enumWithThresholds.e, Corners.FRONTS);
                 }
             }
             else if (leftRearValue >= enumWithThresholds.lowerThreshold && leftRearValue < enumWithThresholds.upperThreshold)
             {
                 addCornerStatus(cornerData, enumWithThresholds.e, Corners.LEFTS);
             }
             else
             {
                 addCornerStatus(cornerData, enumWithThresholds.e, Corners.FRONT_LEFT);
             }
         }
         else if (rightFrontValue >= enumWithThresholds.lowerThreshold && rightFrontValue < enumWithThresholds.upperThreshold)
         {
             if (rightRearValue >= enumWithThresholds.lowerThreshold && rightRearValue < enumWithThresholds.upperThreshold)
             {
                 addCornerStatus(cornerData, enumWithThresholds.e, Corners.RIGHTS);
             }
             else
             {
                 addCornerStatus(cornerData, enumWithThresholds.e, Corners.FRONT_RIGHT);
             }
         }
         else if (leftRearValue >= enumWithThresholds.lowerThreshold && leftRearValue < enumWithThresholds.upperThreshold)
         {
             if (rightRearValue >= enumWithThresholds.lowerThreshold && rightRearValue < enumWithThresholds.upperThreshold)
             {
                 addCornerStatus(cornerData, enumWithThresholds.e, Corners.REARS);
             }
             else
             {
                 addCornerStatus(cornerData, enumWithThresholds.e, Corners.REAR_LEFT);
             }
         }
         else if (rightRearValue >= enumWithThresholds.lowerThreshold && rightRearValue < enumWithThresholds.upperThreshold)
         {
             addCornerStatus(cornerData, enumWithThresholds.e, Corners.REAR_RIGHT);
         }
     }
     return cornerData;
 }
 private static void addCornerStatus(CornerData cornerData, Enum e, Corners corners)
 {
     if (cornerData.cornersForEachStatus.ContainsValue(corners))
     {
         var item = cornerData.cornersForEachStatus.First(kvp => kvp.Value == corners);
         cornerData.cornersForEachStatus.Remove(item.Key);
     }
     cornerData.cornersForEachStatus.Add(e, corners);
 }
Пример #3
0
 private void addTyreTempWarningMessages(CornerData.Corners corners, TyreTemp tyreTemp, List<MessageFragment> messageContents)
 {
     switch (corners)
     {
         case CornerData.Corners.ALL:
             switch (tyreTemp)
             {
                 case TyreTemp.COLD:
                     messageContents.Add(MessageFragment.Text(folderColdTyresAllRound));
                     break;
                 case TyreTemp.HOT:
                     messageContents.Add(MessageFragment.Text(folderHotTyresAllRound));
                     break;
                 case TyreTemp.COOKING:
                     messageContents.Add(MessageFragment.Text(folderCookingTyresAllRound));
                     break;
                 default:
                     break;
             }
             break;
         case CornerData.Corners.FRONTS:
             switch (tyreTemp)
             {
                 case TyreTemp.COLD:
                     messageContents.Add(MessageFragment.Text(folderColdFrontTyres));
                     break;
                 case TyreTemp.HOT:
                     messageContents.Add(MessageFragment.Text(folderHotFrontTyres));
                     break;
                 case TyreTemp.COOKING:
                     messageContents.Add(MessageFragment.Text(folderCookingFrontTyres));
                     break;
                 default:
                     break;
             }
             break;
         case CornerData.Corners.REARS:
             switch (tyreTemp)
             {
                 case TyreTemp.COLD:
                     messageContents.Add(MessageFragment.Text(folderColdRearTyres));
                     break;
                 case TyreTemp.HOT:
                     messageContents.Add(MessageFragment.Text(folderHotRearTyres));
                     break;
                 case TyreTemp.COOKING:
                     messageContents.Add(MessageFragment.Text(folderCookingRearTyres));
                     break;
                 default:
                     break;
             }
             break;
         case CornerData.Corners.LEFTS:
             switch (tyreTemp)
             {
                 case TyreTemp.COLD:
                     messageContents.Add(MessageFragment.Text(folderColdLeftTyres));
                     break;
                 case TyreTemp.HOT:
                     messageContents.Add(MessageFragment.Text(folderHotLeftTyres));
                     break;
                 case TyreTemp.COOKING:
                     messageContents.Add(MessageFragment.Text(folderCookingLeftTyres));
                     break;
                 default:
                     break;
             }
             break;
         case CornerData.Corners.RIGHTS:
             switch (tyreTemp)
             {
                 case TyreTemp.COLD:
                     messageContents.Add(MessageFragment.Text(folderColdRightTyres));
                     break;
                 case TyreTemp.HOT:
                     messageContents.Add(MessageFragment.Text(folderHotRightTyres));
                     break;
                 case TyreTemp.COOKING:
                     messageContents.Add(MessageFragment.Text(folderCookingRightTyres));
                     break;
                 default:
                     break;
             }
             break;
         case CornerData.Corners.FRONT_LEFT:
             switch (tyreTemp)
             {
                 case TyreTemp.HOT:
                     messageContents.Add(MessageFragment.Text(folderHotLeftFrontTyre));
                     break;
                 case TyreTemp.COOKING:
                     messageContents.Add(MessageFragment.Text(folderCookingLeftFrontTyre));
                     break;
                 default:
                     break;
             }
             break;
         case CornerData.Corners.FRONT_RIGHT:
             switch (tyreTemp)
             {
                 case TyreTemp.HOT:
                     messageContents.Add(MessageFragment.Text(folderHotRightFrontTyre));
                     break;
                 case TyreTemp.COOKING:
                     messageContents.Add(MessageFragment.Text(folderCookingRightFrontTyre));
                     break;
                 default:
                     break;
             }
             break;
         case CornerData.Corners.REAR_LEFT:
             switch (tyreTemp)
             {
                 case TyreTemp.HOT:
                     messageContents.Add(MessageFragment.Text(folderHotLeftRearTyre));
                     break;
                 case TyreTemp.COOKING:
                     messageContents.Add(MessageFragment.Text(folderCookingLeftRearTyre));
                     break;
                 default:
                     break;
             }
             break;
         case CornerData.Corners.REAR_RIGHT:
             switch (tyreTemp)
             {
                 case TyreTemp.HOT:
                     messageContents.Add(MessageFragment.Text(folderHotRightRearTyre));
                     break;
                 case TyreTemp.COOKING:
                     messageContents.Add(MessageFragment.Text(folderCookingRightRearTyre));
                     break;
                 default:
                     break;
             }
             break;
     }
 }
Пример #4
0
 private void addTyreConditionWarningMessages(CornerData.Corners corners, TyreCondition tyreCondition, List<MessageFragment> messageContents)
 {
     switch (corners)
     {
         case CornerData.Corners.ALL:
             switch (tyreCondition)
             {
                 case TyreCondition.MAJOR_WEAR:
                     messageContents.Add(MessageFragment.Text(folderWornAllRound));
                     break;
                 case TyreCondition.WORN_OUT:
                     messageContents.Add(MessageFragment.Text(folderKnackeredAllRound));
                     break;
                 default:
                     break;
             }
             break;
         case CornerData.Corners.FRONTS:
             switch (tyreCondition)
             {
                 case TyreCondition.MAJOR_WEAR:
                     messageContents.Add(MessageFragment.Text(folderWornFronts));
                     break;
                 case TyreCondition.WORN_OUT:
                     messageContents.Add(MessageFragment.Text(folderKnackeredFronts));
                     break;
                 default:
                     break;
             }
             break;
         case CornerData.Corners.REARS:
             switch (tyreCondition)
             {
                 case TyreCondition.MAJOR_WEAR:
                     messageContents.Add(MessageFragment.Text(folderWornRears));
                     break;
                 case TyreCondition.WORN_OUT:
                     messageContents.Add(MessageFragment.Text(folderKnackeredRears));
                     break;
                 default:
                     break;
             }
             break;
         case CornerData.Corners.LEFTS:
             switch (tyreCondition)
             {
                 case TyreCondition.MAJOR_WEAR:
                     messageContents.Add(MessageFragment.Text(folderWornLefts));
                     break;
                 case TyreCondition.WORN_OUT:
                     messageContents.Add(MessageFragment.Text(folderKnackeredLefts));
                     break;
                 default:
                     break;
             }
             break;
         case CornerData.Corners.RIGHTS:
             switch (tyreCondition)
             {
                 case TyreCondition.MAJOR_WEAR:
                     messageContents.Add(MessageFragment.Text(folderWornRights));
                     break;
                 case TyreCondition.WORN_OUT:
                     messageContents.Add(MessageFragment.Text(folderKnackeredRights));
                     break;
                 default:
                     break;
             }
             break;
         case CornerData.Corners.FRONT_LEFT:
             switch (tyreCondition)
             {
                 case TyreCondition.MAJOR_WEAR:
                     messageContents.Add(MessageFragment.Text(folderWornLeftFront));
                     break;
                 case TyreCondition.WORN_OUT:
                     messageContents.Add(MessageFragment.Text(folderKnackeredLeftFront));
                     break;
                 default:
                     break;
             }
             break;
         case CornerData.Corners.FRONT_RIGHT:
             switch (tyreCondition)
             {
                 case TyreCondition.MAJOR_WEAR:
                     messageContents.Add(MessageFragment.Text(folderWornRightFront));
                     break;
                 case TyreCondition.WORN_OUT:
                     messageContents.Add(MessageFragment.Text(folderKnackeredRightFront));
                     break;
                 default:
                     break;
             }
             break;
         case CornerData.Corners.REAR_LEFT:
             switch (tyreCondition)
             {
                 case TyreCondition.MAJOR_WEAR:
                     messageContents.Add(MessageFragment.Text(folderWornLeftRear));
                     break;
                 case TyreCondition.WORN_OUT:
                     messageContents.Add(MessageFragment.Text(folderKnackeredLeftRear));
                     break;
                 default:
                     break;
             }
             break;
         case CornerData.Corners.REAR_RIGHT:
             switch (tyreCondition)
             {
                 case TyreCondition.MAJOR_WEAR:
                     messageContents.Add(MessageFragment.Text(folderWornRightRear));
                     break;
                 case TyreCondition.WORN_OUT:
                     messageContents.Add(MessageFragment.Text(folderKnackeredRightRear));
                     break;
                 default:
                     break;
             }
             break;
     }
 }
Пример #5
0
 private void addBrakeTempWarningMessages(CornerData.Corners corners, BrakeTemp brakeTemp, List<MessageFragment> messageContents)
 {
     switch (corners)
     {
         case CornerData.Corners.ALL:
             switch (brakeTemp)
             {
                 case BrakeTemp.COLD:
                     messageContents.Add(MessageFragment.Text(folderColdBrakesAllRound));
                     break;
                 case BrakeTemp.HOT:
                     messageContents.Add(MessageFragment.Text(folderHotBrakesAllRound));
                     break;
                 case BrakeTemp.COOKING:
                     messageContents.Add(MessageFragment.Text(folderCookingBrakesAllRound));
                     break;
                 default:
                     break;
             }
             break;
         case CornerData.Corners.FRONTS:
             switch (brakeTemp)
             {
                 case BrakeTemp.COLD:
                     messageContents.Add(MessageFragment.Text(folderColdFrontBrakes));
                     break;
                 case BrakeTemp.HOT:
                     messageContents.Add(MessageFragment.Text(folderHotFrontBrakes));
                     break;
                 case BrakeTemp.COOKING:
                     messageContents.Add(MessageFragment.Text(folderCookingFrontBrakes));
                     break;
                 default:
                     break;
             }
             break;
         case CornerData.Corners.REARS:
             switch (brakeTemp)
             {
                 case BrakeTemp.COLD:
                     messageContents.Add(MessageFragment.Text(folderColdRearBrakes));
                     break;
                 case BrakeTemp.HOT:
                     messageContents.Add(MessageFragment.Text(folderHotRearBrakes));
                     break;
                 case BrakeTemp.COOKING:
                     messageContents.Add(MessageFragment.Text(folderCookingRearBrakes));
                     break;
                 default:
                     break;
             }
             break;
         default:
             break;
     }
 }
Пример #6
0
        protected override void triggerInternal(GameStateData previousGameState, GameStateData currentGameState)
        {
            if (currentGameState.SessionData.IsNewLap)
            {
                timeLeftFrontIsLockedForLap = 0;
                timeRightFrontIsLockedForLap = 0;
                timeLeftRearIsLockedForLap = 0;
                timeRightRearIsLockedForLap = 0;
                timeLeftFrontIsSpinningForLap = 0;
                timeRightFrontIsSpinningForLap = 0;
                timeLeftRearIsSpinningForLap = 0;
                timeRightRearIsSpinningForLap = 0;
                if (warnedOnLockingForLap)
                {
                    totalLockupThresholdForNextLap = totalLockupThresholdForNextLap + 1;
                }
                else
                {
                    totalLockupThresholdForNextLap = initialTotalLapLockupThreshold;
                }
                if (warnedOnWheelspinForLap)
                {
                    totalWheelspinThresholdForNextLap = totalWheelspinThresholdForNextLap + 1;
                }
                else
                {
                    totalWheelspinThresholdForNextLap = initialTotalWheelspinThreshold;
                }
                warnedOnLockingForLap = false;
                warnedOnWheelspinForLap = false;
            }
            if (previousGameState != null && currentGameState.Ticks > previousGameState.Ticks)
            {
                addLockingAndSpinningData(currentGameState.TyreData, previousGameState.Ticks, currentGameState.Ticks);
            }

            if (currentGameState.Now > nextLockingAndSpinningCheck)
            {
                if (enableBrakeLockWarnings)
                {
                    checkLocking();
                }
                if (enableWheelSpinWarnings)
                {
                    checkWheelSpinning();
                }
                nextLockingAndSpinningCheck = currentGameState.Now.Add(lockingAndSpinningCheckInterval);
            }

            if (currentGameState.TyreData.TireWearActive)
            {
                leftFrontWearPercent = currentGameState.TyreData.FrontLeftPercentWear;
                leftRearWearPercent = currentGameState.TyreData.RearLeftPercentWear;
                rightFrontWearPercent = currentGameState.TyreData.FrontRightPercentWear;
                rightRearWearPercent = currentGameState.TyreData.RearRightPercentWear;

                currentTyreConditionStatus = currentGameState.TyreData.TyreConditionStatus;
                currentTyreTempStatus = currentGameState.TyreData.TyreTempStatus;
                if (isBrakeTempPeakForLap(currentGameState.TyreData.LeftFrontBrakeTemp,
                    currentGameState.TyreData.RightFrontBrakeTemp, currentGameState.TyreData.LeftRearBrakeTemp,
                    currentGameState.TyreData.RightRearBrakeTemp))
                {
                    currentBrakeTempStatus = currentGameState.TyreData.BrakeTempStatus;
                }

                completedLaps = currentGameState.SessionData.CompletedLaps;
                lapsInSession = currentGameState.SessionData.SessionNumberOfLaps;
                timeInSession = currentGameState.SessionData.SessionRunTime;
                timeElapsed = currentGameState.SessionData.SessionRunningTime;

                if (currentGameState.PitData.InPitlane && !currentGameState.SessionData.LeaderHasFinishedRace)
                {
                    if (currentGameState.SessionData.SessionType == SessionType.Race && enableTyreWearWarnings && !reportedTyreWearForCurrentPitEntry)
                    {
                        //reportCurrentTyreConditionStatus(false, true);
                        // sounds shit...
                        reportedTyreWearForCurrentPitEntry = true;
                    }
                }
                else
                {
                    reportedTyreWearForCurrentPitEntry = false;
                }
                if (currentGameState.SessionData.IsNewLap && !currentGameState.PitData.InPitlane && enableTyreWearWarnings && !currentGameState.SessionData.LeaderHasFinishedRace)
                {
                    reportCurrentTyreConditionStatus(false, false);
                }
                if (!currentGameState.PitData.InPitlane && !reportedEstimatedTimeLeft && enableTyreWearWarnings && !currentGameState.SessionData.LeaderHasFinishedRace)
                {
                    reportEstimatedTyreLife(33, false);
                }
                // if the tyre wear has actually decreased, reset the 'reportdEstimatedTyreWear flag - assume this means the tyres have been changed
                if (previousGameState != null && (currentGameState.TyreData.FrontLeftPercentWear < previousGameState.TyreData.FrontLeftPercentWear ||
                    currentGameState.TyreData.FrontRightPercentWear < previousGameState.TyreData.FrontRightPercentWear ||
                    currentGameState.TyreData.RearRightPercentWear < previousGameState.TyreData.RearRightPercentWear ||
                    currentGameState.TyreData.RearLeftPercentWear < previousGameState.TyreData.RearLeftPercentWear))
                {
                    reportedEstimatedTimeLeft = true;
                }

                if (enableTyreTempWarnings && !currentGameState.SessionData.LeaderHasFinishedRace &&
                    !currentGameState.PitData.InPitlane &&
                    currentGameState.SessionData.CompletedLaps >= lapsIntoSessionBeforeTempMessage && currentGameState.SessionData.IsNewLap)
                {
                    reportCurrentTyreTempStatus(false);
                }
                if (!currentGameState.SessionData.LeaderHasFinishedRace &&
                     ((checkBrakesAtSector == 1 && currentGameState.SessionData.IsNewLap) ||
                     ((currentGameState.SessionData.IsNewSector && currentGameState.SessionData.SectorNumber == checkBrakesAtSector))))
                {
                    if (!currentGameState.PitData.InPitlane && currentGameState.SessionData.CompletedLaps >= lapsIntoSessionBeforeTempMessage)
                    {
                        if (enableBrakeTempWarnings)
                        {
                            reportCurrentBrakeTempStatus(false);
                        }
                    }
                    peakBrakeTempForLap = 0;
                }
            }
        }
Пример #7
0
 public override void clearState()
 {
     reportedTyreWearForCurrentPitEntry = false;
     reportedEstimatedTimeLeft = false;
     leftFrontWearPercent = 0;
     leftRearWearPercent = 0;
     rightFrontWearPercent = 0;
     rightRearWearPercent = 0;
     completedLaps = 0;
     lapsInSession = 0;
     timeInSession = 0;
     timeElapsed = 0;
     currentTyreConditionStatus = new CornerData();
     currentTyreTempStatus = new CornerData();
     currentBrakeTempStatus = new CornerData();
     lastTyreTempMessage = null;
     lastBrakeTempMessage = null;
     lastTyreConditionMessage = null;
     peakBrakeTempForLap = 0;
     timeLeftFrontIsLockedForLap = 0;
     timeRightFrontIsLockedForLap = 0;
     timeLeftRearIsLockedForLap = 0;
     timeRightRearIsLockedForLap = 0;
     timeLeftFrontIsSpinningForLap = 0;
     timeRightFrontIsSpinningForLap = 0;
     timeLeftRearIsSpinningForLap = 0;
     timeRightRearIsSpinningForLap = 0;
     totalLockupThresholdForNextLap = initialTotalLapLockupThreshold;
     totalWheelspinThresholdForNextLap = initialTotalWheelspinThreshold;
     warnedOnLockingForLap = false;
     warnedOnWheelspinForLap = false;
     nextLockingAndSpinningCheck = DateTime.MinValue;
 }