/// <summary> /// Add an additional node, from the current last node along the next TrackNodeVector (given by index) /// The added node will always be a junction node. /// </summary> /// <param name="lastNode">Currently last node of path</param> /// <param name="nextTvnIndex">TrackNodeVector index along which to place the track</param> /// <param name="isMainPath">Are we adding a node on the main path (alternative is passing path)</param> /// <returns>The newly created junction path node</returns> TrainpathJunctionNode AddAdditionalJunctionNode(TrainpathNode lastNode, int nextTvnIndex, bool isMainPath) { // we add a new activeNodeAsJunction TrainpathJunctionNode newNode = new TrainpathJunctionNode(lastNode); if (TrackExtensions.TrackNode(nextTvnIndex) == null) { return(null); // apparently there is some issue in the track. } newNode.JunctionIndex = lastNode.GetNextJunctionIndex(nextTvnIndex); newNode.SetLocationFromTrackNode(); // simple linking newNode.PrevNode = lastNode; if (isMainPath) { lastNode.NextMainTvnIndex = nextTvnIndex; lastNode.NextMainNode = newNode; } else { lastNode.NextSidingTvnIndex = nextTvnIndex; lastNode.NextSidingNode = newNode; } newNode.SetFacingPoint(); newNode.DetermineOrientation(lastNode, nextTvnIndex); NetNodesAdded++; return(newNode); }
/// <summary> /// For all the junction nodes, set whether it is a facing point or not /// </summary> /// <param name="Nodes">The list of path nodes that now need to be linked</param> static private void SetFacingPoints(List <TrainpathNode> Nodes) { // It is just a convenience to use the list of Nodes. // In principle this can be done without the list by following the path for (int i = 0; i < Nodes.Count; i++) { TrainpathJunctionNode node = Nodes[i] as TrainpathJunctionNode; if (node == null) { continue; } node.SetFacingPoint(); } }