예제 #1
0
 public override void clearState()
 {
     lastStatusMessage = EngineStatus.ALL_CLEAR;
     engineData = new EngineData();
     gameTimeAtLastStatusCheck = 0;
     maxSafeOilTemp = 0;
     maxSafeWaterTemp = 0;
 }
예제 #2
0
        protected override void triggerInternal(GameStateData previousGameState, GameStateData currentGameState)
        {
            if (engineData == null)
            {
                clearState();
            }
            if (maxSafeWaterTemp == 0) {
                maxSafeWaterTemp = currentGameState.carClass.maxSafeWaterTemp;
            }
            if (maxSafeOilTemp == 0) {
                maxSafeOilTemp = currentGameState.carClass.maxSafeOilTemp;
            }
            if (currentGameState.SessionData.SessionRunningTime > 60 * currentGameState.EngineData.MinutesIntoSessionBeforeMonitoring)
            {
                engineData.addSample(currentGameState.EngineData.EngineOilTemp, currentGameState.EngineData.EngineWaterTemp,
                    currentGameState.EngineData.EngineOilPressure);

                if (currentGameState.SessionData.SessionRunningTime > gameTimeAtLastStatusCheck + statusMonitorWindowLength)
                {
                    EngineStatus currentEngineStatus = engineData.getEngineStatusFromAverage(maxSafeWaterTemp, maxSafeOilTemp);
                    if (currentEngineStatus != lastStatusMessage)
                    {
                        switch (currentEngineStatus)
                        {
                            case EngineStatus.ALL_CLEAR:
                                lastStatusMessage = currentEngineStatus;
                                audioPlayer.queueClip(new QueuedMessage(folderAllClear, 0, this));
                                break;
                            case EngineStatus.HOT_OIL:
                                // don't play this if the last message was about hot oil *and* water - wait for 'all clear'
                                if (lastStatusMessage != EngineStatus.HOT_OIL_AND_WATER)
                                {
                                    lastStatusMessage = currentEngineStatus;
                                    audioPlayer.queueClip(new QueuedMessage(folderHotOil, 0, this));
                                }
                                break;
                            case EngineStatus.HOT_WATER:
                                // don't play this if the last message was about hot oil *and* water - wait for 'all clear'
                                if (lastStatusMessage != EngineStatus.HOT_OIL_AND_WATER)
                                {
                                    lastStatusMessage = currentEngineStatus;
                                    audioPlayer.queueClip(new QueuedMessage(folderHotWater, 0, this));
                                }
                                break;
                            case EngineStatus.HOT_OIL_AND_WATER:
                                lastStatusMessage = currentEngineStatus;
                                audioPlayer.queueClip(new QueuedMessage(folderHotOilAndWater, 0, this));
                                break;
                        }
                    }
                    gameTimeAtLastStatusCheck = currentGameState.SessionData.SessionRunningTime;
                    engineData = new EngineData();
                }
            }
        }