1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-25 22:18:34 +01:00

tiled sanity check

This commit is contained in:
Ellpeck 2019-12-06 16:12:57 +01:00
parent e75f87f4be
commit 2bd62ee09d

View file

@ -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;
}
}
}