mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 04:53:29 +01:00
tiled sanity check
This commit is contained in:
parent
e75f87f4be
commit
2bd62ee09d
1 changed files with 5 additions and 1 deletions
|
@ -58,7 +58,7 @@ namespace MLEM.Extended.Tiled {
|
|||
}
|
||||
|
||||
public static TiledMapTile GetTile(this TiledMapTileLayer layer, int x, int y) {
|
||||
return layer.GetTile((ushort) x, (ushort) y);
|
||||
return !layer.IsInBounds(x, y) ? default : layer.GetTile((ushort) x, (ushort) y);
|
||||
}
|
||||
|
||||
public static RectangleF GetArea(this TiledMapObject obj, TiledMap map, Vector2? position = null) {
|
||||
|
@ -71,5 +71,9 @@ namespace MLEM.Extended.Tiled {
|
|||
return new Vector2(map.TileWidth, map.TileHeight);
|
||||
}
|
||||
|
||||
public static bool IsInBounds(this TiledMapTileLayer layer, int x, int y) {
|
||||
return x >= 0 && y >= 0 && x < layer.Width && y < layer.Height;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue