This repository has been archived on 2023-04-11. You can view files and clone it, but cannot push or open issues or pull requests.
dungeon-crawler-demo/scripts/Extenstions/TilemapExtensions.cs
2020-10-26 00:50:16 -04:00

16 lines
528 B
C#

using Godot;
namespace Godot
{
public static class TilemapExtensions
{
/// <summary>method <c>IsValidMapPosition</c> returns a bool of whether a location in a tilemap has no colliders.</summary>
public static bool IsValidMapPosition(this TileMap tileMap, Vector2 position)
{
int tile_id = tileMap.GetCell((int)position.x, (int)position.y);
if(tile_id >= 0)
return tileMap.TileSet.TileGetShapeCount(tile_id) == 0;
return true;
}
}
}