Inspect tooltip: tree canopy + furniture-over-floor priority

Two playtest gaps reported:

* Hovering on a tree showed nothing — trees anchor to the trunk tile but
  the canopy sprite rises ~4 tiles upward. Now any hover within the
  vertical band [trunk.y - 4, trunk.y] resolves to the tree.

* Hovering inside the cabin always said "Wood floor" — both floor and
  furniture register in World.build_queue, and the floor was found
  first. Now we two-pass the queue: remember any floor we hit, but keep
  scanning for furniture (bed / crate / workbench / torch / etc.) and
  return that if found. Items on the ground also win over the bare
  floor. Floor only shows when nothing else occupies the tile.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
megaproxy 2026-05-15 19:03:56 +01:00
parent ce61928a54
commit 00f38ffd95

View file

@ -144,24 +144,39 @@ func _describe_tile(tile: Vector2i) -> String:
elif r.get("tile") == tile:
return _describe_rock(r)
# Trees anchor to the trunk tile (bottom) but visually rise up to 4 tiles
# above (canopy). Treat any hover within that vertical band as the tree.
for t in World.trees:
if is_instance_valid(t) and t.get("tile") == tile:
if not is_instance_valid(t):
continue
var tt: Vector2i = t.get("tile")
if tile.x == tt.x and tile.y >= tt.y - 4 and tile.y <= tt.y:
return _describe_tree(t)
# Furniture / build sites at this tile (Wall, Floor, Door, Bed, Crate,
# Workbench, Torch, GraveSlot all live in World.build_queue via _ready).
# Two-pass: above-ground furniture wins over floor, so hovering on a bed
# placed on a wood floor reports the bed, not the floor underneath.
var floor_hit = null
for s in World.build_queue:
if not is_instance_valid(s):
continue
if s.get("tile") == tile:
var d := _describe_build_site(s)
if d != "":
return d
# Items lying on the ground.
if s.get("tile") != tile:
continue
var path: String = s.get_script().resource_path if s.get_script() else ""
if "floor.gd" in path:
floor_hit = s
continue # remember it, but keep scanning for furniture on top
var d := _describe_build_site(s)
if d != "":
return d
# Items take priority over the bare floor too — a wood stack should show
# as "wood ×N", not as the floor it sits on.
for it in World.items:
if is_instance_valid(it) and it.get("tile") == tile:
return _describe_item(it)
if floor_hit != null:
return _describe_build_site(floor_hit)
# Grave markers (permanent, not in build_queue once converted).
for gm in World.grave_markers: