entity.TileRect points to wrong tileset region when using Tile Property
Ok, so I have a tile setup which looks like this:
The entiy in question is a switch, its sprite is the close switch (red). As long as I had it only that way, it rendered in the game as expected. However, then I added a Tile Property, as can be seen in the screenshot. In the game I load both sprites into different variables, but BOTH now point the SAME region in the tileset. When I render both sprites in the game it looks like this:
When I dump the entity.TileRect without the tile property, I get:
2024-03-31T07:20.13 CEST DEBUG: LOAD TILE /home/scip/dev/openquell/game/levels.go: 188
isdoor: false
isswitch: true
name: Switch
tileid: 7d975370-d7b0-11ee-9add-971995295000
tilerect:
x: 96 <==
y: 160 <==
w: 32
h: 32
tilesetuid: 57
With the property I get:
2024-03-31T07:17.01 CEST DEBUG: LOAD TILE /home/scip/dev/openquell/game/levels.go: 188
isdoor: false
isswitch: true
name: Switch
tileid: 7d975370-d7b0-11ee-9add-971995295000
tilerect:
x: 96 <==
y: 192 <==
w: 32
h: 32
tilesetuid: 57
tileref: 81e502b0-d7b0-11ee-9add-6193c766edeb
togglerect:
x: 96 <== This is the location of the tile property sprite
y: 192 <==
w: 32
h: 32
This is the tileset:
However, I managed to "fix" this behavior by customizing the Display Setting of the property. By default it's value is Replace entity tile. When I set it like so:
then everything works as expected.
Please correct me if I'm wrong, but in my opinion this is a bug: ldtkgo should not consider the display settings. I think these are meant for the LDTK UI only, not for the resulting game. Now that I know how to circumvent this, it's no real problem. But it took me a while to find.