Esempio n. 1
0
        /// <summary>
        /// The activeTrackLocation needs to be between two nodes on the track, if it is to be valid.
        /// Here we find whether indeed it is.
        /// </summary>
        /// <param name="drawnPathData">The data structure with the information on the drawn path</param>
        /// <param name="trackNodeIndex">The index of the track node</param>
        /// <returns>The node that will be before a possible new node on the track</returns>
        TrainpathNode FindPrevNodeOfActiveTrack(DrawnPathData drawnPathData, int trackNodeIndex)
        {
            Collection <TrainpathNode> nodesOnTrack = drawnPathData.NodesOnTrack(trackNodeIndex);

            // We are given a set of nodes. We know that a part of the path was drawn following those nodes
            // All of these parts are on the same track.
            // The nodes are ordered in pairs.
            for (int i = nodesOnTrack.Count - 1; i > 0; i -= 2)
            {
                if (activeTrackLocation.IsBetween(nodesOnTrack[i - 1], nodesOnTrack[i]))
                {
                    return(nodesOnTrack[i - 1]);
                }
            }
            return(null);
        }
Esempio n. 2
0
        private List <string> StationNamesBetweenNodes(TrainpathNode firstNode, TrainpathNode secondNode)
        {
            var stationNames = new List <string>();
            int tvnIndex     = firstNode.NextMainTvnIndex;

            if (tvnIndex < 0)
            {
                return(stationNames);
            }

            TrackNode    tn  = trackDB.TrackNodes[tvnIndex];
            TrVectorNode tvn = tn.TrVectorNode;

            if (tvn == null)
            {
                return(stationNames);
            }
            if (tvn.TrItemRefs == null)
            {
                return(stationNames);
            }

            foreach (int trackItemIndex in tvn.TrItemRefs)
            {
                TrItem trItem = trackDB.TrItemTable[trackItemIndex];
                if (trItem.ItemType == TrItem.trItemType.trPLATFORM)
                {
                    var traveller = new Traveller(tsectionDat, trackDB.TrackNodes, tn,
                                                  trItem.TileX, trItem.TileZ, trItem.X, trItem.Z, Traveller.TravellerDirection.Forward);
                    if (traveller != null)
                    {
                        var platformNode = new TrainpathVectorNode(firstNode, traveller);
                        if (platformNode.IsBetween(firstNode, secondNode))
                        {
                            PlatformItem platform = trItem as PlatformItem;
                            stationNames.Add(platform.Station);
                        }
                    }
                }
            }

            return(stationNames);
        }
Esempio n. 3
0
        private List <string> StationNamesBetweenNodes(TrainpathNode firstNode, TrainpathNode secondNode)
        {
            var stationNames = new List <string>();
            int tvnIndex     = firstNode.NextMainTvnIndex;

            if (tvnIndex < 0)
            {
                return(stationNames);
            }

            TrackVectorNode tvn = trackDB.TrackNodes[tvnIndex] as TrackVectorNode;

            if (tvn == null)
            {
                return(stationNames);
            }
            if (tvn.TrackItemIndices == null)
            {
                return(stationNames);
            }

            foreach (int trackItemIndex in tvn.TrackItemIndices)
            {
                TrackItem trItem = trackDB.TrackItems[trackItemIndex];
                if (trItem is PlatformItem)
                {
                    var traveller = new Traveller(tsectionDat, trackDB.TrackNodes, tvn, trItem.Location, Traveller.TravellerDirection.Forward);
                    if (traveller != null)
                    {
                        var platformNode = new TrainpathVectorNode(firstNode, traveller);
                        if (platformNode.IsBetween(firstNode, secondNode))
                        {
                            PlatformItem platform = trItem as PlatformItem;
                            stationNames.Add(platform.Station);
                        }
                    }
                }
            }

            return(stationNames);
        }