PhysicsAPI reference
Class TileGrid
Namespace: MicroEngine.World
Assembly: MicroEngine.Physics.Tiles.dll
Guide: Tile maps and collision
A collision grid backed by a TileLayer and a per-id flag table. Cells outside the map use OutsideFlags (solid by default, so levels are closed).
public sealed class TileGrid : ICollisionGridInheritance
Implements
Constructors
TileGrid(TileLayer, int, IReadOnlyDictionary<int, TileFlags>)
Creates a grid; ids missing from flags have no flags (empty).
public TileGrid(TileLayer layer, int tileSize, IReadOnlyDictionary<int, TileFlags> flags)Parameters
layer TileLayer
The tile ids.
tileSize int
Tile size in pixels; must be positive.
flags IReadOnlyDictionary<int, TileFlags>
Flags per tile id; copied.
Exceptions
tileSize is not positive.
Properties
Layer
The tile ids the grid reads. Changing a tile in the layer changes collisions at once.
public TileLayer Layer { get; }Property Value
OutsideFlags
Flags of every cell outside the map when OutsideRule gives none (solid by default).
public TileFlags OutsideFlags { get; set; }Property Value
OutsideRule
Optional override for open edges, e.g. a platformer’s bottom pit must not be solid.
public Func<int, int, TileFlags?>? OutsideRule { get; set; }Property Value
PixelHeight
Height of the map in pixels.
public int PixelHeight { get; }Property Value
PixelWidth
Width of the map in pixels.
public int PixelWidth { get; }Property Value
TileSize
Size of a square tile in pixels.
public int TileSize { get; }Property Value
Methods
FlagsAt(int, int)
The flags of the tile at (tileX, tileY); outside the map, OutsideRule or OutsideFlags.
public TileFlags FlagsAt(int tileX, int tileY)Parameters
tileX int
tileY int
Returns
SetFlags(int, TileFlags)
Sets the flags of every tile with id id.
public void SetFlags(int id, TileFlags flags)Parameters
id int
flags TileFlags