Skip to content

LineTiles

namespace Griff.Scenes;
public sealed class LineTiles : Component

The tiles a line laid on this tilemap is drawn with: a straight piece and a corner, each drawn once and turned to follow the line (see TileTurn), and if you like, pieces for its two ends. A LineTool lays them in the game, and the editor’s Line tool (L, with the tilemap selected) paints with them, so belts, pipes, rails or wires go down by dragging.

Draw the straight piece running left to right, pointing right (the way the line runs), and the corner coming in from the left, moving right, and going out at the bottom, moving down: a clockwise turn. Turning the other way, it’s laid mirrored.

This is a component: its saved properties are on its component page.

public int CornerTile { get; set; }

The corner piece, drawn coming in from the left and going out at the bottom. None lays the straight piece at corners too.

public int EndTile { get; set; }

The piece for a line’s last cell, drawn with the line coming in from the left. None lays the straight piece.

public int JoinTile { get; set; }

The piece for a straight cell another line runs into from the side (a merge), drawn pointing right with the other line coming in from the bottom. None leaves the straight piece there.

public bool Joins { get; set; }

True for the editor’s Line tool to join a line onto these pieces already on the map, as a LineTool with Joins does: dragged from a line’s end it carries it on (the old end becomes a straight piece or a corner), ended on a line’s side it merges in (that cell stays, with the JoinTile), and dragged out of a line’s side it splits off (that cell stays, with the SplitTile). Unticked, a line is painted on its own, over what’s there.

public int SplitTile { get; set; }

The piece for a straight cell another line leaves from the side (a split), drawn pointing right with the other line going out at the bottom. None leaves the straight piece there.

public int StartTile { get; set; }

The piece for a line’s first cell, drawn pointing right, the way the line leaves it. None lays the straight piece.

public int StraightTile { get; set; }

The straight piece, drawn pointing right. None lays no tiles (the editor’s Line tool then paints the brush’s tile).

public static LineTiles? For(Tilemap? map)

The Line Tiles that go with map: on its own entity, or on the map it’s a layer of.

public IReadOnlyList<LineCell> Join(IReadOnlyList<LineCell> line, Tilemap? map = null)

line joined onto the lines of these pieces already on map (its own tilemap if not given), as Join joins it, reading each line’s way from its pieces.

public IReadOnlyList<ValueTuple<int, int, int, TileTurn>> JoinedPieces(IReadOnlyList<LineCell> line, Tilemap? map = null)

The pieces already on map (its own tilemap if not given) that change when the joined line is laid, as they’ll be: an old end it carries on becomes a straight piece, the start of a line it runs into a straight piece or a corner, a straight piece it merges into its JoinTile and one it splits off its SplitTile. Worked out before the line is laid.

public void Lay(IReadOnlyList<LineCell> line)

Lays line’s cells that fit on its tilemap (cells of this map), each with its tile turned to follow the line. Cells left of or above the grid are skipped; the grid grows right and down to fit. A line joined onto those already there (see Join) leaves the cells it merges into or splits off, and turns the pieces it joins into those of a joined line (see JoinedPieces).

public ValueTuple<int, TileTurn> TileFor(IReadOnlyList<LineCell> line, int index)

The tile, and its turn, for cell index of line: the corner at a corner, the start and end pieces at its ends (a line of more than one cell, unless that end joins a line already there), else the straight piece; -1 for the tile if it has none.

public ValueTuple<int, int>? WayOf(int x, int y, Tilemap? map = null)

The way the line runs through the piece in cell (x, y) of map (its own tilemap if not given), x right and y up, or null if it holds none of these pieces.