mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 04:53:29 +01:00
some tiled sanity checks
This commit is contained in:
parent
d610899b7d
commit
dbe02645f1
1 changed files with 6 additions and 2 deletions
|
@ -39,18 +39,22 @@ namespace MLEM.Extended.Tiled {
|
|||
}
|
||||
|
||||
public static TiledMapTilesetTile GetTilesetTile(this TiledMapTileset tileset, TiledMapTile tile, TiledMap map) {
|
||||
if (tile.IsBlank)
|
||||
return null;
|
||||
var localId = tile.GetLocalIdentifier(tileset, map);
|
||||
return tileset.Tiles.FirstOrDefault(t => t.LocalTileIdentifier == localId);
|
||||
}
|
||||
|
||||
public static TiledMapTilesetTile GetTilesetTile(this TiledMapTile tile, TiledMap map) {
|
||||
if (tile.IsBlank)
|
||||
return null;
|
||||
var tileset = tile.GetTileset(map);
|
||||
return tileset.GetTilesetTile(tile, map);
|
||||
return tileset?.GetTilesetTile(tile, map);
|
||||
}
|
||||
|
||||
public static TiledMapTile GetTile(this TiledMap map, string layerName, int x, int y) {
|
||||
var layer = map.GetLayer<TiledMapTileLayer>(layerName);
|
||||
return layer != null ? layer.GetTile((ushort) x, (ushort) y) : new TiledMapTile(0, (ushort) x, (ushort) y);
|
||||
return layer != null ? layer.GetTile((ushort) x, (ushort) y) : default;
|
||||
}
|
||||
|
||||
public static RectangleF GetArea(this TiledMapObject obj, TiledMap map, Vector2 position) {
|
||||
|
|
Loading…
Reference in a new issue