public override RailBase Clone() { var clone = new RailItem() { DebugIndex = globalDebugIndex++, Position = this.Position, Angle = this.Angle, Layer = this.Layer, //DockPoints = this.DockPoints.Select(d => d.Clone()).ToList(), TrackId = this.TrackId, Track = this.Track }; clone.DockPoints = this.DockPoints.Select(d => d.Clone(clone)).ToList(); return(clone); }
public RailGroup(IEnumerable <RailBase> railItems) { this.DebugIndex = globalDebugIndex++; var extDockPoints = railItems.SelectMany(r => r.DockPoints).Where(d => !d.IsDocked || !railItems.Contains(d.DockedWith.RailItem)).ToList(); RailItem firstRailItme = (RailItem)railItems.FirstOrDefault(); this.Layer = firstRailItme.Layer; this.Position = firstRailItme.Position; // set before new RailGroupItem this.Angle = 0.0; railItems.DebugList($"RailGroup Const original rails"); this.Rails = railItems.Cast <RailItem>().ToList(); this.Rails.ForEach(r => r.IsSelected = false); extDockPoints.ForEach(d => d.Group(this)); this.DockPoints = extDockPoints; DebugInfo(); this.IsSelected = true; }