public override void clearState()
 {
     lastRainReport = DateTime.MinValue;
     lastAirTempReport = DateTime.MaxValue;
     lastTrackTempReport = DateTime.MaxValue;
     airTempAtLastReport = float.MinValue;
     trackTempAtLastReport = float.MinValue;
     rainAtLastReport = float.MinValue;
     currentConditions = null;
 }
 protected override void triggerInternal(GameStateData previousGameState, GameStateData currentGameState)
 {
     currentConditions = currentGameState.Conditions.getMostRecentConditions();
     if (currentConditions != null && enableTrackAndAirTempReports)
     {
         if (airTempAtLastReport == float.MinValue)
         {
             airTempAtLastReport = currentConditions.AmbientTemperature;
             trackTempAtLastReport = currentConditions.TrackTemperature;
             rainAtLastReport = currentConditions.RainDensity;
             lastRainReport = currentGameState.Now;
             lastTrackTempReport = currentGameState.Now;
             lastAirTempReport = currentGameState.Now;
         }
         else
         {
             Boolean canReportAirChange = currentGameState.Now > lastAirTempReport.Add(AirTemperatureReportMaxFrequency);
             Boolean canReportTrackChange = currentGameState.Now > lastTrackTempReport.Add(TrackTemperatureReportMaxFrequency);
             Boolean reportedCombinedTemps = false;
             if (canReportAirChange || canReportTrackChange)
             {
                 if (currentConditions.TrackTemperature > trackTempAtLastReport + minTrackTempDeltaToReport && currentConditions.AmbientTemperature > airTempAtLastReport + minAirTempDeltaToReport)
                 {
                     airTempAtLastReport = currentConditions.AmbientTemperature;
                     trackTempAtLastReport = currentConditions.TrackTemperature;
                     lastAirTempReport = currentGameState.Now;
                     lastTrackTempReport = currentGameState.Now;
                     // do the reporting
                     audioPlayer.queueClip(new QueuedMessage("conditionsAirAndTrackIncreasing1", MessageContents
                         (folderAirAndTrackTempIncreasing, folderAirTempIsNow, QueuedMessage.folderNameNumbersStub + Math.Round(currentConditions.AmbientTemperature),
                         folderTrackTempIsNow, QueuedMessage.folderNameNumbersStub + Math.Round(currentConditions.TrackTemperature), folderCelsius), 0, this));
                     reportedCombinedTemps = true;
                 }
                 else if (currentConditions.TrackTemperature < trackTempAtLastReport - minTrackTempDeltaToReport && currentConditions.AmbientTemperature < airTempAtLastReport - minAirTempDeltaToReport)
                 {
                     airTempAtLastReport = currentConditions.AmbientTemperature;
                     trackTempAtLastReport = currentConditions.TrackTemperature;
                     lastAirTempReport = currentGameState.Now;
                     lastTrackTempReport = currentGameState.Now;
                     // do the reporting
                     audioPlayer.queueClip(new QueuedMessage("conditionsAirAndTrackDecreasing1", MessageContents
                         (folderAirAndTrackTempDecreasing, folderAirTempIsNow, QueuedMessage.folderNameNumbersStub + Math.Round(currentConditions.AmbientTemperature),
                         folderTrackTempIsNow, QueuedMessage.folderNameNumbersStub + Math.Round(currentConditions.TrackTemperature), folderCelsius), 0, this));
                     reportedCombinedTemps = true;
                 }
             }
             if (!reportedCombinedTemps && canReportAirChange)
             {
                 if (currentConditions.AmbientTemperature > airTempAtLastReport + minAirTempDeltaToReport)
                 {
                     airTempAtLastReport = currentConditions.AmbientTemperature;
                     lastAirTempReport = currentGameState.Now;
                     // do the reporting
                     audioPlayer.queueClip(new QueuedMessage("conditionsAirIncreasing", MessageContents
                         (folderAirTempIncreasing, QueuedMessage.folderNameNumbersStub + Math.Round(currentConditions.AmbientTemperature), folderCelsius), 0, this));
                 }
                 else if (currentConditions.AmbientTemperature < airTempAtLastReport - minAirTempDeltaToReport)
                 {
                     airTempAtLastReport = currentConditions.AmbientTemperature;
                     lastAirTempReport = currentGameState.Now;
                     // do the reporting
                     audioPlayer.queueClip(new QueuedMessage("conditionsAirDecreasing", MessageContents
                         (folderAirTempDecreasing, QueuedMessage.folderNameNumbersStub + Math.Round(currentConditions.AmbientTemperature), folderCelsius), 0, this));
                 }
             }
             if (!reportedCombinedTemps && canReportTrackChange)
             {
                 if (currentConditions.TrackTemperature > trackTempAtLastReport + minTrackTempDeltaToReport)
                 {
                     trackTempAtLastReport = currentConditions.TrackTemperature;
                     lastTrackTempReport = currentGameState.Now;
                     // do the reporting
                     audioPlayer.queueClip(new QueuedMessage("conditionsTrackIncreasing", MessageContents
                         (folderTrackTempIncreasing, QueuedMessage.folderNameNumbersStub + Math.Round(currentConditions.TrackTemperature), folderCelsius), 0, this));
                 }
                 else if (currentConditions.TrackTemperature < trackTempAtLastReport - minTrackTempDeltaToReport)
                 {
                     trackTempAtLastReport = currentConditions.TrackTemperature;
                     lastTrackTempReport = currentGameState.Now;
                     // do the reporting
                     audioPlayer.queueClip(new QueuedMessage("conditionsTrackDecreasing", MessageContents
                         (folderTrackTempDecreasing, QueuedMessage.folderNameNumbersStub + Math.Round(currentConditions.TrackTemperature), folderCelsius), 0, this));
                 }
             }
             if (currentGameState.Now > lastRainReport.Add(RainReportMaxFrequency))
             {
                 // TODO: the implementation is coupled to the PCars mRainDensity value, which is 0 or 1
                 if (currentConditions.RainDensity == 0 && rainAtLastReport == 1)
                 {
                     rainAtLastReport = currentConditions.RainDensity;
                     lastRainReport = currentGameState.Now;
                     audioPlayer.queueClip(new QueuedMessage(folderStoppedRaining, 0, this));
                 }
                 else if (currentConditions.RainDensity == 1 && rainAtLastReport == 0)
                 {
                     rainAtLastReport = currentConditions.RainDensity;
                     lastRainReport = currentGameState.Now;
                     audioPlayer.queueClip(new QueuedMessage(folderSeeingSomeRain, 0, this));
                 }
             }
         }
     }
 }