Open ShawkMusic opened 2 years ago
I think TileMap metadata has already been added in the new TileMap editor in the master
branch.
Yep, this is missing only in GridMap.
Yep, this is missing only in GridMap.
should the proposal be renamed then?
custom values to each individual cell in a Tilemap/gridmap
This proposal seems to suggest metadata on a cell-by-cell basis, but if memory serves me right, the metadata in the reworked TileMap is on a tile-by-tile basis.
https://godotengine.org/article/tiles-editor-progress-3
"As it was quite a requested feature, TileSet now support custom data layers. Each custom data layer can be assigned a type and a name. Once this is done, each tile of the TileSet can be assigned a value for each custom data layer."
Well, you can have an empty tile with custom data and paint it over cells that you want to use this data. If you put it on a separate layer, it's very easy to work with (edit, retrieve etc.).
As an alternative solution to this proposal, there's a special VariantMap
class in Goost which allows to encode data in 2D. It can be saved as a general-purpose resource with whatever Variant
data in each cell, unfortunately it does not have ability to conveniently edit such data yet (I think it makes sense for VariantMap
's editor plugin to be similar to what's proposed in #13, which actually solves a lot of use cases).
Other than that, I approve this proposal in general.
Describe the project you are working on
A game with a tile/gridmap node
Describe the problem or limitation you are having in your project
I want to make variants of blocks, water to have "strength" levels (the further it flows, the closer it gets to 0), chests to have arrays with what items are stored in it and where, and more.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Add the ability to add custom values to each individual cell in a Tilemap/gridmap
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
In the editor, underneath the place where you choose what tile to draw, there could be a menu where you can add custom values to the cell. You would give it a name (that will be used to refer to it in the dictionary) and a value. This would be stored in a dictionary (similar to adding Extra Call Arguments when connecting a signal) These values would be added to the nodes you paint. It would be similar to pressing the flip/rotate buttons above the tiles.
In code, there would be new methods:
Dictionary get_cell_dictionary(x, y, [z if in 3d]) const Returns the dictionary of the given cell.
Dictionary set_cell_dictionary(x, y, [z if in 3d], dictionary) const Sets the dictionary of the given cell.
If this enhancement will not be used often, can it be worked around with a few lines of script?
Yes, but I've needed to do this for nearly every tile/gridmap based game so I think it's worthy of being in core
Is there a reason why this should be core and not an add-on in the asset library?
I've needed to do this for nearly every tile/gridmap based game so I think it's worthy of being in core