From 84e1958b4e8bcc6740d4957d112fc78da2051f09 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Tue, 24 Sep 2019 12:26:38 +0200 Subject: [PATCH] add a tiled method that doesn't require ushort casts to get tiles --- MLEM.Extended/Tiled/IndividualTiledMapRenderer.cs | 2 +- MLEM.Extended/Tiled/TiledExtensions.cs | 6 +++++- MLEM.Extended/Tiled/TiledMapCollisions.cs | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/MLEM.Extended/Tiled/IndividualTiledMapRenderer.cs b/MLEM.Extended/Tiled/IndividualTiledMapRenderer.cs index 9307fa9..e1693ad 100644 --- a/MLEM.Extended/Tiled/IndividualTiledMapRenderer.cs +++ b/MLEM.Extended/Tiled/IndividualTiledMapRenderer.cs @@ -33,7 +33,7 @@ namespace MLEM.Extended.Tiled { public void UpdateDrawInfo(int layerIndex, int x, int y) { var layer = this.map.TileLayers[layerIndex]; - var tile = layer.GetTile((ushort) x, (ushort) y); + var tile = layer.GetTile(x, y); if (tile.IsBlank) return; var tileset = tile.GetTileset(this.map); diff --git a/MLEM.Extended/Tiled/TiledExtensions.cs b/MLEM.Extended/Tiled/TiledExtensions.cs index a8c09cb..a15d871 100644 --- a/MLEM.Extended/Tiled/TiledExtensions.cs +++ b/MLEM.Extended/Tiled/TiledExtensions.cs @@ -54,7 +54,11 @@ namespace MLEM.Extended.Tiled { public static TiledMapTile GetTile(this TiledMap map, string layerName, int x, int y) { var layer = map.GetLayer(layerName); - return layer != null ? layer.GetTile((ushort) x, (ushort) y) : default; + return layer != null ? layer.GetTile(x, y) : default; + } + + public static TiledMapTile GetTile(this TiledMapTileLayer layer, int x, int y) { + return layer.GetTile((ushort) x, (ushort) y); } public static RectangleF GetArea(this TiledMapObject obj, TiledMap map, Vector2 position) { diff --git a/MLEM.Extended/Tiled/TiledMapCollisions.cs b/MLEM.Extended/Tiled/TiledMapCollisions.cs index 559c72c..c5daa76 100644 --- a/MLEM.Extended/Tiled/TiledMapCollisions.cs +++ b/MLEM.Extended/Tiled/TiledMapCollisions.cs @@ -32,7 +32,7 @@ namespace MLEM.Extended.Tiled { public void UpdateCollisionInfo(int layerIndex, int x, int y) { var layer = this.map.TileLayers[layerIndex]; - var tile = layer.GetTile((ushort) x, (ushort) y); + var tile = layer.GetTile(x, y); if (tile.IsBlank) return; var tilesetTile = tile.GetTilesetTile(this.map);