How can I access the subtiles of an autotile in GDScript?

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

I have a class inherited from TileSet and am trying to implement the _forward_subtile_selection method. For the most part I am trying to imitate the way the engine performs subtile selection but with a few modifications. I’m looking at the engine code, specifically TileSet::autotile_get_subtile_for_bitmask.

That method iterates through the subtiles using this loop:

for (Map<Vector2, uint32_t>::Element *E = tile_map[p_id].autotile_data.flags.front(); E; E = E->next())

(See tile_set.cpp line 639 on branch 3.2)

I’m trying to find a way to similarly iterate through the subtiles, but they don’t appear to be exposed to GDScript. It DOES provide the method TileSet.autotile_get_bitmask, and I’ve considered manually incrementing a Vector2 and using that method to get the bitmask from each subtile, but then my problem is that I can’t find any method which provides me with the bounds of the autotile on the tileset in order to iterate within.

Is there something obvious that I’m missing? It seems very difficult to implement a method to select a subtile without there being access to the subtiles.

I’d like, if possible, to be able to do this without needing to modify the engine or to create a plugin or module.

Thanks for any help!

but then my problem is that I can’t find any method which provides me with the bounds of the autotile on the tileset in order to iterate within.

So you’re looking for the dimensions in x- and y-direction of the autotile-atlas? If so, check out my answer over here.

njamster | 2020-04-10 11:01

:bust_in_silhouette: Reply From: Linky

How does _forward_subtile_selection works, at all? This is lacking documentation. :confused:

Maybe you can open an issue on GitHub about it?

exuin | 2021-03-06 18:20