Tiles of different sizes on TileMap

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ateff

Let’s say there is a TileMap, the cell size is 32x32.
TileMap has a one-cell tile (32x32) and a four-cell tile (64x64).
If you call the get_used_cells () method, then for a 64x64 tile it will return only one cell, instead of four.
Is there a ready-made way to get a complete list of used cells, taking into account the size of the tile?

Тайлы разного размера на TileMap
Допустим, есть TileMap, размер ячейки равен 32х32.
У TileMap есть тайл размером в одну ячеку (32х32) и тайл размером в четыре ячейки (64х64).
Если вызвать метод get_used_cells(), то для тайла 64х64 он вернет только одну ячеку, вместо четырёх.
Есть ли готовый способ получить полный список используемых ячеек с учётом размеров тайла?

:bust_in_silhouette: Reply From: KohuGaly

Not really. From the point of view of tilemap, the 2x2 tiles are just regular 1x1 tiles with texture spilling into neighboring tiles. There is no build in concept of tiles that span multiple cells. You can keep a list of which tile indices are actually 2x2 and make a custom get_used_cells()method that adds the missing cells. For example like this:

var list_of_2x2_tiles = [1, 5, 8 ] #contains tile indices of 2x2 tiles
func get_used_cells_incl_2x2() 
     var used_cells = get_used_cells()
     for id in list_of_2x2_tiles:
         for cell in get_used_cells_by_id(id):
             #assuming the tile is top-left corner
             used_cells.push_back(cell + Vector(1,0))
             used_cells.push_back(cell + Vector(0,1))
             used_cells.push_back(cell + Vector(1,1))
    return used_cells

Thanks, I did something like this)
It’s a bit sad that there is no built-in method (

ateff | 2020-12-28 03:12