public override void respond(string voiceMessage) { Boolean fromStatusRequest = SpeechRecogniser.ResultContains(voiceMessage, SpeechRecogniser.CAR_STATUS) || SpeechRecogniser.ResultContains(voiceMessage, SpeechRecogniser.STATUS); Boolean gotData = false; if (engineData != null) { gotData = true; EngineStatus currentEngineStatus = engineData.getEngineStatusFromCurrent(maxSafeWaterTemp, maxSafeOilTemp); if (currentEngineStatus.HasFlag(EngineStatus.ALL_CLEAR)) { lastStatusMessage = currentEngineStatus; if (!fromStatusRequest) { audioPlayer.playMessageImmediately(new QueuedMessage(folderAllClear, 0)); } } else if (currentEngineStatus.HasFlag(EngineStatus.HOT_OIL) && currentEngineStatus.HasFlag(EngineStatus.HOT_WATER)) { lastStatusMessage = currentEngineStatus; audioPlayer.playMessageImmediately(new QueuedMessage(folderHotOilAndWater, 0)); } else if (currentEngineStatus.HasFlag(EngineStatus.HOT_OIL)) { // don't play this if the last message was about hot oil *and* water - wait for 'all clear' if (!lastStatusMessage.HasFlag(EngineStatus.HOT_OIL) && !lastStatusMessage.HasFlag(EngineStatus.HOT_WATER)) { lastStatusMessage = currentEngineStatus; audioPlayer.playMessageImmediately(new QueuedMessage(folderHotOil, 0)); } } else if (currentEngineStatus.HasFlag(EngineStatus.HOT_WATER)) { // don't play this if the last message was about hot oil *and* water - wait for 'all clear' if (!lastStatusMessage.HasFlag(EngineStatus.HOT_OIL) && !lastStatusMessage.HasFlag(EngineStatus.HOT_WATER)) { lastStatusMessage = currentEngineStatus; audioPlayer.playMessageImmediately(new QueuedMessage(folderHotWater, 0)); } } } if (!gotData && !fromStatusRequest) { audioPlayer.playMessageImmediately(new QueuedMessage(AudioPlayer.folderNoData, 0)); } }
override protected void triggerInternal(GameStateData previousGameState, GameStateData currentGameState) { if (engineData == null) { clearState(); } if (maxSafeWaterTemp == 0) { maxSafeWaterTemp = currentGameState.carClass.maxSafeWaterTemp; } if (maxSafeOilTemp == 0) { maxSafeOilTemp = currentGameState.carClass.maxSafeOilTemp; } // immediately warn about oil pressure / fuel pressure / stalled: if (currentGameState.SessionData.SessionRunningTime > 30) { if (currentGameState.CarDamageData.OverallEngineDamage < DamageLevel.DESTROYED && !currentGameState.PitData.InPitlane && currentGameState.EngineData.EngineStalledWarning && currentGameState.Now > nextStalledCheck && currentGameState.PositionAndMotionData.CarSpeed < 5) { // Play stalled warning straight away audioPlayer.playMessageImmediately(new QueuedMessage(folderStalled, 3)); // don't re-check stalled warning for a couple of minutes. nextStalledCheck = currentGameState.Now.Add(TimeSpan.FromMinutes(2)); // move the oil and fuel pressure checks out a bit to allow it to settle nextOilPressureCheck = currentGameState.Now.Add(TimeSpan.FromSeconds(20)); nextFuelPressureCheck = currentGameState.Now.Add(TimeSpan.FromSeconds(20)); } else { // don't check oil or fuel pressure if we're stalled if (currentGameState.EngineData.EngineOilPressureWarning && currentGameState.Now > nextOilPressureCheck) { audioPlayer.playMessage(new QueuedMessage(folderLowOilPressure, 7, abstractEvent: this, priority: 10)); // don't re-check oil pressure for a couple of minutes nextOilPressureCheck = currentGameState.Now.Add(TimeSpan.FromMinutes(2)); } if (currentGameState.EngineData.EngineFuelPressureWarning && currentGameState.Now > nextFuelPressureCheck) { audioPlayer.playMessage(new QueuedMessage(folderLowFuelPressure, 7, abstractEvent: this, priority: 10)); // don't re-check fuel pressure for a couple of minutes nextFuelPressureCheck = currentGameState.Now.Add(TimeSpan.FromMinutes(2)); } } } if (currentGameState.SessionData.SessionRunningTime > 60 * currentGameState.EngineData.MinutesIntoSessionBeforeMonitoring) { engineData.addSample(currentGameState.EngineData.EngineOilTemp, currentGameState.EngineData.EngineWaterTemp, currentGameState.EngineData.EngineOilPressure, currentGameState.EngineData.EngineOilPressureWarning, currentGameState.EngineData.EngineFuelPressureWarning, currentGameState.EngineData.EngineWaterTempWarning, currentGameState.EngineData.EngineStalledWarning); // check temperatures every minute: if (currentGameState.SessionData.SessionRunningTime > gameTimeAtLastStatusCheck + statusMonitorWindowLength) { EngineStatus currentEngineStatus = engineData.getEngineStatusFromAverage(maxSafeWaterTemp, maxSafeOilTemp, currentGameState.EngineData.EngineWaterTemp); if (currentEngineStatus != lastStatusMessage) { if (currentEngineStatus.HasFlag(EngineStatus.ALL_CLEAR)) { lastStatusMessage = currentEngineStatus; audioPlayer.playMessage(new QueuedMessage(folderAllClear, 10, abstractEvent: this, priority: 5)); } else if (currentEngineStatus.HasFlag(EngineStatus.HOT_OIL) && currentEngineStatus.HasFlag(EngineStatus.HOT_WATER)) { lastStatusMessage = currentEngineStatus; audioPlayer.playMessage(new QueuedMessage(folderHotOilAndWater, 10, abstractEvent: this, priority: 10)); } if (currentEngineStatus.HasFlag(EngineStatus.HOT_OIL)) { // don't play this if the last message was about hot oil *and* water - wait for 'all clear' if (!lastStatusMessage.HasFlag(EngineStatus.HOT_OIL) && !lastStatusMessage.HasFlag(EngineStatus.HOT_WATER)) { lastStatusMessage = currentEngineStatus; audioPlayer.playMessage(new QueuedMessage(folderHotOil, 10, abstractEvent: this, priority: 10)); } } if (currentEngineStatus.HasFlag(EngineStatus.HOT_WATER)) { // don't play this if the last message was about hot oil *and* water - wait for 'all clear' if (!lastStatusMessage.HasFlag(EngineStatus.HOT_OIL) && !lastStatusMessage.HasFlag(EngineStatus.HOT_WATER)) { lastStatusMessage = currentEngineStatus; audioPlayer.playMessage(new QueuedMessage(folderHotWater, 10, abstractEvent: this, priority: 10)); } } } gameTimeAtLastStatusCheck = currentGameState.SessionData.SessionRunningTime; engineData = new EngineData(); } } }