Skip to content

PhysicsAPI reference

Class TileLayer

Namespace: MicroEngine.World
Assembly: MicroEngine.Physics.Tiles.dll
Guide: Tile maps and collision

A rectangular grid of integer tile ids (0 conventionally means empty).

C#
public sealed class TileLayer

Inheritance

object ← TileLayer

Constructors

TileLayer(int, int)

Creates a layer filled with 0.

C#
public TileLayer(int width, int height)

Parameters

width int

height int

Exceptions

ArgumentOutOfRangeException

width or height is not positive.

Properties

Height

Height in tiles.

C#
public int Height { get; }

Property Value

int

Width

Width in tiles.

C#
public int Width { get; }

Property Value

int

this[int, int]

The tile id at (x, y), in tiles. Reading outside returns 0; writing outside does nothing.

C#
public int this[int x, int y] { get; set; }

Property Value

int

Methods

Find(IReadOnlyList<string>, char)

Finds every cell whose source character is marker (for spawning entities).

C#
public static IEnumerable<(int X, int Y)> Find(IReadOnlyList<string> rows, char marker)

Parameters

rows IReadOnlyList<string>

marker char

Returns

IEnumerable<(int X, int Y)>

Get(int, int, int)

Out-of-bounds reads return outside so edges can act as walls.

C#
public int Get(int x, int y, int outside = 0)

Parameters

x int

y int

outside int

Returns

int

InBounds(int, int)

Whether tile (x, y) is inside the layer.

C#
public bool InBounds(int x, int y)

Parameters

x int

y int

Returns

bool

Parse(IReadOnlyList<string>, IReadOnlyDictionary<char, int>)

Builds a layer from text rows. Each character is mapped through legend; characters not in the legend become 0. Rows may have different lengths.

C#
public static TileLayer Parse(IReadOnlyList<string> rows, IReadOnlyDictionary<char, int> legend)

Parameters

rows IReadOnlyList<string>

legend IReadOnlyDictionary<char, int>

Returns

TileLayer