From 1d80965d24e14a2c462e714ab01c1ada64848a1a Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Tue, 9 Mar 2021 19:06:06 +0100 Subject: [PATCH] allow removing a tile using the new SetTile methd --- MLEM.Extended/Tiled/TiledExtensions.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/MLEM.Extended/Tiled/TiledExtensions.cs b/MLEM.Extended/Tiled/TiledExtensions.cs index 77bffec..706c1eb 100644 --- a/MLEM.Extended/Tiled/TiledExtensions.cs +++ b/MLEM.Extended/Tiled/TiledExtensions.cs @@ -190,16 +190,17 @@ namespace MLEM.Extended.Tiled { } /// - /// Sets the tiled map tile at the given location to the given tile from the given tileset + /// Sets the tiled map tile at the given location to the given tile from the given tileset. + /// If the passed or is null, the tile at the location is removed instead. /// /// The map /// The name of the layer /// The x coordinate /// The y coordinate - /// The tileset to useR - /// The tile to place, from the given tileset + /// The tileset to use, or null to remove the tile + /// The tile to place, from the given tileset, or null to remove the tile public static void SetTile(this TiledMap map, string layerName, int x, int y, TiledMapTileset tileset, TiledMapTilesetTile tile) { - map.SetTile(layerName, x, y, tile.GetGlobalIdentifier(tileset, map)); + map.SetTile(layerName, x, y, tileset != null && tile != null ? tile.GetGlobalIdentifier(tileset, map) : 0); } ///