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).
public sealed class TileLayerInheritance
Constructors
TileLayer(int, int)
Creates a layer filled with 0.
public TileLayer(int width, int height)Parameters
width int
height int
Exceptions
width or height is not positive.
Properties
Height
Height in tiles.
public int Height { get; }Property Value
Width
Width in tiles.
public int Width { get; }Property Value
this[int, int]
The tile id at (x, y), in tiles. Reading outside returns 0; writing outside does nothing.
public int this[int x, int y] { get; set; }Property Value
Methods
Find(IReadOnlyList<string>, char)
Finds every cell whose source character is marker (for spawning entities).
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.
public int Get(int x, int y, int outside = 0)Parameters
x int
y int
outside int
Returns
InBounds(int, int)
Whether tile (x, y) is inside the layer.
public bool InBounds(int x, int y)Parameters
x int
y int
Returns
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.
public static TileLayer Parse(IReadOnlyList<string> rows, IReadOnlyDictionary<char, int> legend)Parameters
rows IReadOnlyList<string>
legend IReadOnlyDictionary<char, int>