Skip to content

TileTurns

namespace Griff.Scenes;
public static class TileTurns

Turning and flipping a TileTurn further, and what it does to points and directions.

public static Vector2 Apply(TileTurn turn, Vector2 point)

Where point (in a tile’s own space: its middle at 0, 0, x right and y up) ends up when the tile is turned by turn. A direction too: a belt drawn moving right, (1, 0), turned by Turn90 moves down, (0, -1), the world’s way (one row further down the grid).

public static TileTurn Corner(ValueTuple<int, int> in, ValueTuple<int, int> out)

The turn that lays a corner tile drawn coming in moving right and going out moving down (joining its left side to its bottom, as a belt turning clockwise does) so it comes in moving in and goes out moving out (x right, y up): turned for a clockwise corner, mirrored for an anticlockwise one. Ways that don’t make a corner (straight on, or back) point it as Pointing does out.

public static TileTurn FlippedX(TileTurn turn)

turn then mirrored left to right, as it looks: a belt pointing right points left after.

public static TileTurn FlippedY(TileTurn turn)

turn then mirrored top to bottom, as it looks: a belt pointing down points up after.

public static bool IsFlipped(TileTurn turn)

True if it mirrors the tile (left to right, before turning it).

public static Matrix4x4 Matrix(TileTurn turn)

The transform of a tile’s picture (round its middle, y up) that turns it by turn.

public static TileTurn Pointing(int wayX, int wayY)

The turn that points a tile drawn pointing right (a belt moving right, an arrow) the way (wayX, wayY), x right and y up: None for (1, 0), Turn90 for down (0, -1), Turn180 for left and Turn270 for up. Any other way is taken along its longer axis.

public static int Quarters(TileTurn turn)

How many quarter turns clockwise it makes, 0 to 3, after any flip.

public static TileTurn Turned(TileTurn turn, int quarters = 1)

turn turned quarters more quarter turns clockwise (negative for anticlockwise), e.g. TileTurn.Turn90.Turned() is Turn180.