/// <summary> /// Creates a new train on the track /// /// </summary> /// <param name="initialBlock">Starting block of the train</param> /// <param name="name">Name of the train</param> public void SpawnNewTrain(TrackBlock initialBlock, string name) { if (initialBlock != null) { if (initialBlock.HasTransponder) { string start = initialBlock.Transponder.StationName; if (m_startingDirections.ContainsKey(start)) { m_log.LogInfoFormat("Spawning new train \"{0}\" at start {1}", name, start); //Create the new train and train controller ITrain train = new Train.Train(name, initialBlock, m_startingDirections[start]); ITrainController trainController = new TrainController(train); m_trainList.Add(trainController); //Set the train schedule if (start == Constants.REDYARD) { m_log.LogInfoFormat("Setting schedule of {0} to red line", name); trainController.SetSchedule(CTCController.GetCTCController().GetRedlineSchedule()); } else if (start == Constants.GREENYARDOUT) { m_log.LogInfoFormat("Setting schedule of {0} to green line", name); trainController.SetSchedule(CTCController.GetCTCController().GetGreenlineSchedule()); } } } } }