Ejemplo n.º 1
0
        public static RailPlan Load(string path, Dictionary <Guid, TrackBase> trackDict)
        {
            RailPlan railPlan = BaseProject.Load <RailPlan>(path);

            // link tracks
            foreach (RailBase item in railPlan.Rails)
            {
                if (item is RailItem railItem)
                {
                    // set track
                    railItem.Track = trackDict[railItem.TrackId];
                    // set dock points
                    railItem.DockPoints.ForEach((railDockPoint, index) =>
                    {
                        railDockPoint.Update(railItem, railItem.Track.DockPoints[index]);
                    });
                }
            }
            // link dock points
            var list = railPlan.Rails.SelectMany(r => r.DockPoints).Where(dp => dp.DockedWithId != Guid.Empty).ToList();

            foreach (RailDockPoint dp in list)
            {
                RailDockPoint x = list.Single(i => i.Id == dp.DockedWithId);
                x.Dock(dp);
            }
            return(railPlan);
        }
Ejemplo n.º 2
0
 public static void Bind(RailPlan railPlan, TrackType trackType, RailDockPoint from, RailDockPoint to)
 {
     new RailBinder()
     {
         railPlan = railPlan, trackType = trackType, from = from, to = to
     }.Bind();
 }
Ejemplo n.º 3
0
        public RailPlan Clone()
        {
            // clone RailPlan with rails tree
            var clone = new RailPlan()
            {
                PlatePoints = this.PlatePoints.ToList(),
                Layers      = this.Layers.Select(l => l.Clone()).ToList(),
                Rails       = this.Rails.Select(l => l.Clone()).ToList()
            };

            // clone dock point links
            RailDockPoint.CloneDockPointLinks();
            return(clone);
        }