Tilemap Class
Definition
Namespace: Brine2D.Tilemap
Inheritance System.Object → Tilemap
| Properties | |
|---|---|
| BackgroundColor | Background color from Tiled's Map Properties. Defaults to Transparent. |
| ImageLayers | Image layers in document order. Not rendered automatically — load and draw them via ImagePath and the layer's parallax/offset properties. |
| ObjectLayerProperties | Custom properties per object layer, keyed by layer name. Duplicate layer names merge with last-write-wins per key. |
| ObjectLayers | Objects from all object layers, keyed by layer name. |
| ObjectLayerVisibility | Effective visibility per object layer, accounting for parent group visibility. A missing key means visible; false means the layer or an ancestor was hidden. |
| Properties | Map-level custom properties from Tiled \(e\.g\. "music", "level\_name"\). |
| Tilesets | All tilesets used by this map, sorted by FirstGid ascending. |
| Methods | |
|---|---|
| AddImageLayer\(TilemapImageLayer\) | Adds an image layer and keeps the list sorted by ZOrder. |
| AddTileset\(Tileset\) | Adds a tileset and keeps the list sorted by FirstGid. |
| GenerateCollisionRects\(string\) | Returns world-space rects for all solid tiles on the layer. Requires both HasCollision and IsSolid. Parallax is not applied — collision layers should use the default parallax of 1.0. |
| GenerateOneWayPlatformRects\(string\) | Returns world-space rects for all one-way platform tiles on the layer. Requires both HasCollision and IsOneWayPlatform. Parallax is not applied. |
| GetAllLayers\(string\) | Returns every layer with the given name. Unlike Brine2D.Tilemap.Tilemap.GetLayer\(System\.String\), this returns all matches so duplicate-named layers are all accessible. |
| GetObjectById\(int\) | Searches all object layers for the object with the given ID. IDs are unique per map in Tiled. |
| MergeCollisionRects\(string\) | Like GenerateCollisionRects\(string\) but merges adjacent solid tiles into larger rectangles \(greedy horizontal then vertical\) to avoid seams in the physics solver. |
| MergeOneWayPlatformRects\(string\) | Like GenerateOneWayPlatformRects\(string\) but merges adjacent tiles into larger rectangles. |
| ResolveTileset\(int\) | Returns the tileset that owns the given GID, or null. Tilesets must be sorted by FirstGid ascending \(guaranteed by [AddTileset\(Tileset\)](AddTileset(Tileset).md 'Brine2D.Tilemap.Tilemap.AddTileset\(Brine2D\.Tilemap\.Tileset\)')). |
| TileToWorld\(int, int, TilemapLayer\) | Converts tile coordinates to world-space, accounting for the layer's pixel offset. Does not account for parallax — use the camera overload for parallax layers. |
| TileToWorld\(int, int, TilemapLayer, Vector2\) | Converts tile coordinates to world-space, accounting for layer offset and parallax. Inverse of WorldToTile\(float, float, TilemapLayer, Vector2\). |
| WorldToTile\(float, float, TilemapLayer\) | Converts a world position to tile coordinates, accounting for the layer's pixel offset. Does not account for parallax — use the camera overload for parallax layers. |
| WorldToTile\(float, float, TilemapLayer, Vector2\) | Converts a world position to tile coordinates, accounting for layer offset and parallax. Exact inverse of the renderer's tile placement. |