// METHOD: StationController //-------------------------------------------------------------------------------------- /// <summary> /// Control the train announcements and doors /// </summary> //-------------------------------------------------------------------------------------- private void StationController() { // If the train controller receives a transponder input, announce the next station if (!m_approachingStation && m_currentBlock.HasTransponder && m_currentBlock.Transponder.DistanceToStation == 1) { m_approachingStation = true; m_myTrain.SetAnnouncement(m_currentBlock.Transponder.StationName); } // If the train has arrived at the station, open the doors and load and unload passengers if (m_approachingStation && m_currentState.Speed == 0 && m_currentBlock.HasTransponder && m_currentBlock.Transponder.DistanceToStation == 0) { m_atStation = true; m_approachingStation = false; m_myTrain.SetDoors(TrainState.Door.Open); m_arrivalTime = m_timePassed; // Simulate passengers getting on and off at the station m_currentState.Passengers = m_passengerGenerator.Next(0, 222); // Fire an event to let the CTC know the train has arrived at a station if (TrainAtStation != null) { TrainAtStation(this, m_currentBlock.Transponder.StationName); } } // If the train is at the station and the dwell time is up, leave the station if (m_atStation && m_timePassed >= m_nextStationInfo.TimeToStationMinutes * 60 && m_timePassed - m_arrivalTime >= 60) { LeaveStation(); } }