private void Multiline(int count) { SimulationCell redlines = GetMultiLines(false); using (var trk = game.Track.CreateTrackWriter()) { var owner = (StandardLine)_ownerline; LineChanging(); // owner line doesn't count, but our min bounds is 1 var diff = (count - 1) - redlines.Count; if (diff < 0) { for (int i = 0; i > diff; i--) { trk.RemoveLine(redlines.First()); redlines.RemoveLine(redlines.First().ID); } } else if (diff > 0) { for (int i = 0; i < diff; i++) { var red = new RedLine(owner.Position, owner.Position2, owner.inv) { Multiplier = ((RedLine)owner).Multiplier }; red.CalculateConstants(); trk.AddLine(red); redlines.AddLine(red); } } } game.Track.NotifyTrackChanged(); }
private SimulationCell GetMultiLines(bool includeowner) { SimulationCell multilines = new SimulationCell(); using (var trk = _editor.CreateTrackReader()) { var owner = (StandardLine)_ownerline; var lines = trk.GetLinesInRect(new Utils.DoubleRect(owner.Position, new Vector2d(1, 1)), false); foreach (var line in lines) { if ( line is RedLine stl && owner is RedLine stls && line.Position == owner.Position && line.Position2 == owner.Position2 && (includeowner || line.ID != owner.ID)) { multilines.AddLine(stl); } if ( line is StandardLine stlstd && owner is StandardLine stlstds && line.Position == owner.Position && line.Position2 == owner.Position2 && (includeowner || line.ID != owner.ID)) { multilines.AddLine(stlstd); } } } return(multilines); }
private SimulationCell GetMultiLines(bool includeowner) { if (_ownerline.Type == LineType.Scenery) { return(new SimulationCell()); } SimulationCell redlines = new SimulationCell(); using (var trk = _editor.CreateTrackReader()) { var owner = (StandardLine)_ownerline; var lines = trk.GetLinesInRect(new Utils.DoubleRect(owner.Position, new Vector2d(1, 1)), false); foreach (var red in lines) { if ( red is StandardLine stl && red.Position == owner.Position && red.Position2 == owner.Position2 && (includeowner || red.ID != owner.ID)) { redlines.AddLine(stl); } } } return(redlines); }
/// <summary> /// adds an overlay if it does not already exist for that point /// </summary> /// <returns>true if the overlay was added</returns> public bool AddOverlay(GridPoint point, SimulationCell cell) { if (!Overlay.ContainsKey(point)) { Overlay[point] = cell; return(true); } return(false); }
private void Multiline(int count) { SimulationCell multilines = GetMultiLines(false); using (var trk = _editor.CreateTrackWriter()) { var owner = (StandardLine)_ownerline; MakingChange(); // owner line doesn't count, but our min bounds is 1 var diff = (count - 1) - multilines.Count; if (diff < 0) { for (int i = 0; i > diff; i--) { trk.RemoveLine(multilines.First()); multilines.RemoveLine(multilines.First().ID); } } else if (diff > 0) { if (_ownerline is RedLine redline) { for (int i = 0; i < diff; i++) { var red = new RedLine(owner.Position, owner.Position2, owner.inv) { Multiplier = ((RedLine)owner).Multiplier }; red.CalculateConstants(); trk.AddLine(red); } } else if (_ownerline is StandardLine blueline) { for (int i = 0; i < diff; i++) { var blue = new StandardLine(owner.Position, owner.Position2, owner.inv); blue.CalculateConstants(); trk.AddLine(blue); } } } } _editor.NotifyTrackChanged(); }