LineDrag
namespace Griff.Scenes;
public sealed class LineDragA line dragged on a grid from one cell to another, and the rule that lays it: straight along one axis, then (with Corners) round one corner and along the other, each cell pointing on to the next. Which axis comes first is FirstLeg’s, and SwapCorner turns it the other way round. A LineTool lays lines this way in a game, and the editor’s Line tool paints tiles the same way.
Properties
Section titled “Properties”AcrossFirst
Section titled “AcrossFirst”public bool AcrossFirst { get; }True if the line runs along the row first (then up or down the column), false if along the column first.
Corners
Section titled “Corners”public bool Corners { get; }True to turn a corner to reach To; false keeps it straight, along the way it’s dragged further.
public ValueTuple<int, int> End { get; }The line’s last cell: To, or without Corners, as far as it goes along one axis.
FirstLeg
Section titled “FirstLeg”public LineFirstLeg FirstLeg { get; }Which leg comes first.
public ValueTuple<int, int> From { get; }The cell it started on: the line’s first.
IsSingle
Section titled “IsSingle”public bool IsSingle { get; }True while it’s still on the cell it started on: a single cell.
public ValueTuple<int, int> To { get; }The cell it’s dragged to now.
Methods
Section titled “Methods”public IReadOnlyList<LineCell> Cells(ValueTuple<int, int>? single = default)The line’s cells from From to End. A single cell points single (right if not given); the last of a longer line carries on the way the one before it does.
public static IReadOnlyList<LineCell> Join(IReadOnlyList<LineCell> line, Func<ValueTuple<int, int>, ValueTuple<int, int>?> wayAt)line joined onto the lines already laid, whose ways wayAt gives (null for a cell with none): dragged from a line’s end (or the cell it runs into) its first cell Continues it, coming in the way that line does; dragged out of a line’s side, that cell Splits, keeping its way; ended on a line, that cell is a Merge (it keeps its way, and the cell before it points into it); and a last cell pointing into a line Feeds it. Cells it crosses in between are laid over and turned, as without joins.
MoveTo
Section titled “MoveTo”public bool MoveTo(ValueTuple<int, int> cell)Drags it to cell: true if the line changed.
public static IReadOnlyList<LineCell> Path(ValueTuple<int, int> from, ValueTuple<int, int> to, bool acrossFirst = true, ValueTuple<int, int>? lastWay = default)The cells of a line from from to to: along the row first, then up or down the column (or the column first, with acrossFirst false), each pointing on to the next. The last carries on the way the one before it does, or turns to lastWay (a single cell points that way, or right).
StepOf
Section titled “StepOf”public static ValueTuple<int, int> StepOf(LineWay way)The way (x right, y up) a LineWay points.
SwapCorner
Section titled “SwapCorner”public void SwapCorner()Turns the corner the other way round: along the column first instead of the row, or the other way (what R does while dragging).