/// <summary> /// Try to find a connection between the current junction and a reconnect junction, along the given TVN /// We do a depth-first search, using the main tracks first. /// The result (the path) is stored in a list of linking tvns. /// </summary> /// <param name="nextTvn">The TVN (Track Vector Node index) that we will take.</param> /// <param name="currentJunctionIndex">Index of the current junction</param> /// <returns>true if a path was found</returns> private bool TryToFindConnectionVia(int currentJunctionIndex, int nextTvn) { if (nextTvn <= 0) { return(false); // something wrong in train database. } int nextJunctionIndex = TrackExtensions.GetNextJunctionIndex(currentJunctionIndex, nextTvn); if (DisAllowedJunctionIndexes.Contains(nextJunctionIndex)) { return(false); } bool nextJunctionIsFacing = (nextTvn == TrackExtensions.TrackNode(nextJunctionIndex).TrailingTvn()); linkingTvns.Add(nextTvn); bool succeeded = TryToFindConnection(nextJunctionIndex, nextJunctionIsFacing); if (!succeeded) { //Pop the index that did not work linkingTvns.RemoveAt(linkingTvns.Count - 1); } return(succeeded); }
/// <summary> /// From the current pathnode and the linking tracknode, fin the junctionIndex of the next junction (or possibly end-point) /// </summary> /// <param name="linkingTrackNodeIndex">The index of the tracknode leaving the node</param> /// <returns>The index of the junction index at the end of the track (as seen from the node)</returns> public override int GetNextJunctionIndex(int linkingTrackNodeIndex) { return(TrackExtensions.GetNextJunctionIndex(this.JunctionIndex, linkingTrackNodeIndex)); }