Highlight selected tunnels' connection in green (REQ-BLD-TUNNEL-SELECT-HIGHLIGHT)

While a Tunnel Entry or Exit (building or construction site) is selected,
mark its connection green in the game world — the entry tile, exit tile,
and tiles between — reusing the tunnel_preview color from the placement
preview. Unpaired tunnels show no green.

- Add core findTunnelPartner(): the matching end of an existing tunnel
  tile, reusing firstTunnelFacing so the pairing scan stays single-sourced;
  unit-tested in TunnelCompletionTest.
- GameWorldView: extract the built+site tunnel index into
  collectTunnelTiles() (shared with updateTunnelGhost) and add
  drawSelectedTunnelConnections(), called from drawOverlays. Tiles are
  deduped via a set so a connection selected from both ends fills once.
- Also commits the REQ-BLD-TUNNEL-SELECT-HIGHLIGHT requirement text.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y7N59FsLA5e2kuVdqe4Uhc
This commit is contained in:
2026-07-21 19:32:51 +02:00
parent 9a21506b5c
commit 3ac3d8a6e6
6 changed files with 220 additions and 12 deletions

View File

@@ -154,6 +154,7 @@ Modules in `modules.toml` define a `surface_mask` — a list of strings that des
- Pairing is one-to-one: each Tunnel Entry pairs with at most one Tunnel Exit, and vice versa. A Tunnel Exit is claimed by the nearest Tunnel Entry that can validly reach it; all other entries for which it would otherwise qualify are unpaired.
- When one end of a pair is demolished, the pair is dissolved and any items currently in transit are discarded.
- REQ-BLD-TUNNEL-TRANSIT: **Tunnel transit.** Items inside a tunnel are not rendered (they travel invisibly). Transit time equals the tile-coordinate distance between entry and exit divided by `world.toml [world].belt_speed_tiles_per_second`, matching the time a chain of belt tiles of equivalent length would take. Multiple items may be in transit simultaneously, spaced as they would be on a belt chain of the same length. Clearing a tunnel entry or exit tile (REQ-UI-BELT-CLEAR) also discards all items currently in transit through that tunnel.
- REQ-BLD-TUNNEL-SELECT-HIGHLIGHT: **Selected-tunnel connection highlight.** While a Tunnel Entry or Tunnel Exit — operational building or construction site — is part of the current selection (single selection or multi-selection, REQ-UI-MULTI-SELECT), its tunnel connection is marked green in the game world, using the same `visuals.toml [overlays].tunnel_preview` green as the placement connection preview (REQ-BLD-TUNNEL-MODE). The matching end is found by applying the pairing scan of REQ-BLD-TUNNEL-PAIR over both built tunnels **and** construction-site tunnels (site-inclusive, matching the placement preview): for a selected entry, the first same-direction tunnel within `tunnel_max_distance` along its facing direction, if it is a Tunnel Exit; for a selected exit, the first same-direction tunnel within `tunnel_max_distance` opposite its facing direction, if it is a Tunnel Entry. When a matching end is found, the entry tile, the exit tile, and every tile strictly between them (along the tunnel's straight run) are marked green. A selected tunnel with no matching end shows no green highlight (it still receives the normal selection outline). In multi-selection each selected tunnel end that has a matching end contributes its connection, and a given connection is shown whenever either of its ends is selected. The highlight is presentation-only and has no effect on the simulation.
## Material Transport & Buffers