Пример #1
0
        /// <summary>
        /// Actually create the path by linking nodes following the stored linking tvns.
        /// </summary>
        /// <param name="modificationTools">The tool set that is used to actually modify the path</param>
        /// <param name="isMainPath">Do we add the node to the main path or not</param>
        /// <param name="isFromNodeDirectionOK">Set this to true when the FromNode has already been set to correct orientation elsewhere</param>
        public void CreateFoundConnection(ModificationTools modificationTools, bool isMainPath, bool isFromNodeDirectionOK)
        {
            ConnectableNode autoConnectToNode = autoConnectToNodeOptions.ActualReconnectNode;


            if (FromNodeNeedsReverse && !isFromNodeDirectionOK)
            {
                autoConnectFromNode.ReverseOrientation();
            }
            if (ToNodeNeedsReverse)
            {
                autoConnectToNode.ReverseOrientation();
            }

            if (!autoConnectToNode.IsConnectingForward)
            {
                linkingTvns.Reverse();
                ConnectableNode swap = autoConnectToNode;
                autoConnectToNode   = autoConnectFromNode;
                autoConnectFromNode = swap;
            }


            TrainpathNode currentNode = autoConnectFromNode.OriginalNode;

            if ((currentNode is TrainpathVectorNode) && !sameTrackConnect)
            {   // in case the first node is a vector node (and not a direct connect), go to its junction first
                currentNode = modificationTools.AddAdditionalNode(currentNode, isMainPath);
            }

            //create the new path using the stored Tvns
            foreach (int tvn in linkingTvns)
            {
                currentNode = modificationTools.AddAdditionalNode(currentNode, tvn, isMainPath);
                while (currentNode is TrainpathVectorNode)
                {   // apparently a disambiguity node has been added.
                    currentNode = modificationTools.AddAdditionalNode(currentNode, tvn, isMainPath);
                }
            }

            //make the final connections
            TrainpathNode toNode = autoConnectToNode.OriginalNode;

            modificationTools.StitchTwoPaths(currentNode, toNode, isMainPath);
        }
Пример #2
0
 /// <summary>
 /// Actually create the path by linking nodes following the stored linking tvns.
 /// </summary>
 /// <param name="modificationTools">The tool set that is used to actually modify the path</param>
 /// <param name="isMainPath">Do we add the node to the main path or not</param>
 public void CreateFoundConnection(ModificationTools modificationTools, bool isMainPath)
 {
     CreateFoundConnection(modificationTools, isMainPath, false);
 }