fix(client): decode tile_kind and fix entity alignment (#412)
Protocol decoder now reads tile_kind from VisibleTile and maps it to the client's tile type string (floor/wall/door/object). GameState falls back to visible_tiles when the test-mode tiles array is absent, enabling live server tile rendering. Fix entity-to-tile alignment: server sends tile-center render coords (tile 16 -> 16.5) but entity renderer was using raw floats, placing entities half a tile off. Now floors the coords to get the tile index. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -43,8 +43,16 @@ func apply_snapshot(snapshot: Dictionary) -> void:
|
||||
push_warning("GameState: no Player entity found in %d entities" % [
|
||||
visible_entities.size()])
|
||||
|
||||
# Tiles for rendering: test mode sends "tiles", live server sends tile data in "visible_tiles"
|
||||
if snapshot.has("tiles"):
|
||||
visible_tiles = snapshot.tiles
|
||||
elif snapshot.has("visible_tiles") and snapshot.visible_tiles is Array and snapshot.visible_tiles.size() > 0:
|
||||
# Live server: visible_tiles now includes type from tile_kind field
|
||||
var has_type := false
|
||||
if snapshot.visible_tiles.size() > 0 and snapshot.visible_tiles[0] is Dictionary:
|
||||
has_type = snapshot.visible_tiles[0].has("type")
|
||||
if has_type:
|
||||
visible_tiles = snapshot.visible_tiles
|
||||
|
||||
if snapshot.has("visible_positions"):
|
||||
visible_positions.clear()
|
||||
|
||||
Reference in New Issue
Block a user