transformable

class Transformable

Implements a number of functions that allow the parent class to spatially transform its entities and tiles lists. All of the following methods operate in-place, meaning that the original positions and directions of every entity and tile are modified each time they are called.

flip(
direction: 'horizontal' | 'vertical' = 'horizontal',
) None

Flip the blueprint across an axis, if possible. Flipping is done over the x or y axis, depeding on the input direction.

Parameters:
direction: 'horizontal' | 'vertical' = 'horizontal'

The direction to flip by; either "horizontal" or "vertical"

rotate(angle: int)

Rotate the blueprint by angle, if possible. Operates the same as pressing ‘r’ with a blueprint selected.

angle is specified in terms of Direction enum, meaning that a rotation of 4 is 90 degrees clockwise.

Because eight-way rotatable entities exist in a weird gray area, this function behaves like the feature in-game and only rotates on 90 degree intervals. Attempting to rotate the blueprint an odd amount raises an RotationError.

Parameters:
angle: int

The angle to rotate the blueprint by.

Raises:

RotationError – If the rotation is attempted with an odd value.

translate(x: int, y: int) None

Translates all entities and tiles in the blueprint by x and y. Raises RailAlignmentWarning if the parent class contains double-grid-aligned entities and the translation amount is an odd value on either x or y.

Parameters:
x: int

A number indicating how much to translate along x.

y: int

A number indicating how much to translate along y.