Thread nodes under a card stacked above theirs are hidden

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
RobinFiredrake 2026-11-11 08:20:30 -06:00
parent 4f0d2e2c4e
commit 2d247e34b4
2 changed files with 43 additions and 2 deletions

View file

@ -10,9 +10,27 @@ func _init() -> void:
return
await _test_ranged_target()
await _test_plain_target()
await _test_ports_under_cards()
finish()
## A card dragged over another hides the lower card's thread nodes it covers.
func _test_ports_under_cards() -> void:
var low := main.card_for("road")
var top := main.card_for("monsters")
top.position = low.position + Vector2(-20, 0)
top.get_parent().move_child(top, -1)
await _frames()
var ports := main.board.ports
ports._note_stack()
_check(ports._covered(low.inlet_point(), low.get_index()), "the covered card's inlet is hidden")
_check(not ports._covered(top.inlet_point(), top.get_index()), "the top card's inlet still shows")
low.get_parent().move_child(low, -1)
await _frames()
ports._note_stack()
_check(not ports._covered(low.inlet_point(), low.get_index()), "raised again, its inlet shows")
func _parts(to: String) -> Dictionary:
return main.inspector.pipe_parts.get(to, {})

View file

@ -15,6 +15,8 @@ var _drawn_rev := -1
var _drawn_hover := -1
var _drawn_mode := -1
var _drawn_far := false
## [stack index, rect] of each visible card, for hiding ports under other cards.
var _stack: Array = []
func _init() -> void:
@ -68,12 +70,14 @@ func _draw() -> void:
return
var build := main.mode == Main.Mode.BUILD
var mouse := get_local_mouse_position()
_note_stack()
for t in main.data.tables:
var card := main.card_for(t.id)
if card == null or not card.is_inside_tree() or not card.visible:
continue
var below := card.get_index()
# Variable cards are never rolled, so nothing pipes into them.
if t.kind != RollTable.KIND_VARIABLE:
if t.kind != RollTable.KIND_VARIABLE and not _covered(card.inlet_point(), below):
_port(card.inlet_point(), Style.THREAD, Style.THREAD_DARK, 1.0)
for e in t.entries:
if not card.rows.has(e.id):
@ -85,6 +89,8 @@ func _draw() -> void:
if not build and not on:
continue
var pos: Vector2 = a["pos"]
if _covered(pos, below):
continue
var fill := Style.THREAD if on else Style.CARD
var ring := Style.THREAD_DARK
var s := 1.0
@ -100,7 +106,7 @@ func _draw() -> void:
if card.more_row != null:
var m := card.anchor_for("")
var on_hidden := card.hidden_has_pipes()
if not m.is_empty() and (on_hidden or build):
if not m.is_empty() and (on_hidden or build) and not _covered(m["pos"], below):
_port(m["pos"], Style.THREAD if on_hidden else Style.CARD, Style.THREAD_DARK, 1.0)
# Collapsed groups: an inlet, and an outlet wherever member pipes leave.
for g in main.data.groups:
@ -118,6 +124,23 @@ func _draw() -> void:
_draw_ghost(PipeLayer.curve(_ghost_from, _ghost_to))
## Remembers where each visible card sits and how high it is stacked.
func _note_stack() -> void:
_stack.clear()
for c in main.board.cards.get_children():
var tc := c as TableCard
if tc and tc.visible:
_stack.append([tc.get_index(), Rect2(tc.position, tc.size)])
## True when a card stacked above index `below` covers the point.
func _covered(pos: Vector2, below: int) -> bool:
for s: Array in _stack:
if int(s[0]) > below and (s[1] as Rect2).has_point(pos):
return true
return false
func _port(pos: Vector2, fill: Color, ring: Color, s: float) -> void:
draw_circle(pos, 8.0 * s, ring)
draw_circle(pos, 5.0 * s, fill)