Skip to content

feat(nav): MovementLink, authored edges the axis auto-connect can't make - #59

Merged
leonardomag31-lab merged 2 commits into
mainfrom
feat/movement-links
Oct 12, 2026
Merged

leonardomag31-lab merged 2 commits into
mainfrom
feat/movement-links

Conversation

@leonardomag31-lab

Copy link
Copy Markdown
Collaborator

Why

The nav graph only links nodes that share an X or a Y (graph.zig autoConnectAxis). Diagonal connections can't be expressed. In flying-platform, the ship's stern has steps drawn at 45° down to the main deck. The demo's opening crew should walk down them from the balloon ferry, but today they have to be teleported (flying-platform-labelle#1031).

What

  • MovementLink { dx, dy }, a new component. Put it on a MovementNode entity to link that node to the node at its world position + (dx, dy).
    • The link is two-way and costs its straight-line length.
    • It's resolved within controller.LINK_TOLERANCE (4 px), because offsets are measured from art.
    • A missing target logs a warning and is skipped.
  • Graph build: the links are added in a second pass in buildGraphIntoState, after every node is in. Graphs rebuild whenever the node set changes, so links follow rebuilds.
  • API:
    • Graph.addLink(a, b): idempotent; returns error.InvalidNode for a self-link or a removed or unknown node.
    • Graph.nearestNodeWithin(pos, tol).
    • PathfinderWith.addLink.
  • MovementLink is exported through Components, so the assembler registers it.
  • No walker or Floyd-Warshall changes. The walker already walks every leg as a straight line.
  • Pruning: a later addNode can't prune a diagonal link. The in-between pruning only drops an edge between two nodes on the new node's own axis.

Testing

  • zig build test and zig build spec pass. New tests:
    • Diagonal link both ways at the Euclidean cost.
    • Idempotent.
    • Rejects self-links and removed nodes.
    • Survives later nodes on either end's row.
    • nearestNodeWithin.
    • A walk across a raised deck → diagonal steps → main deck takes the linked path and arrives.
  • In flying-platform, with this branch as a local: plugin, the stern deck got 4 nodes and one link down the steps. The opening crew walk the deck at y 36, go diagonally down the steps ((95,31) → (116,0)) and carry on along the main deck. graph built: 33 nodes, with no link warnings.

Release

This is additive, so it should ship as 4.1.0. The game PR pins it after release.

🤖 Generated with Claude Code

The graph only links nodes that share an X or a Y, so a diagonal flight
of steps (flying-platform's stern, drawn at 45 degrees down to the main
deck) can't be walked: games had to teleport entities or script
straight-line moveTo hops around the graph.

A MovementLink { dx, dy } on a MovementNode adds a two-way edge to the
node at its world position + (dx, dy), resolved within LINK_TOLERANCE
(4 px) in a second pass once every node is in, costed at its
straight-line length. The walker already walks any leg as a straight
line, and Floyd-Warshall needs nothing new. Graph gains addLink and
nearestNodeWithin; the engine forwards addLink.

A diagonal link can't be pruned by a later addNode: the in-between
pruning only drops edges between two nodes on the new node's own axis.
@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9f59d88d-74ee-420c-bf34-269ac5646013

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

MovementLink is an additive API, so a minor bump.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@leonardomag31-lab
leonardomag31-lab merged commit 2aec3e4 into main Oct 12, 2026
2 checks passed
@leonardomag31-lab
leonardomag31-lab deleted the feat/movement-links branch October 12, 2026 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants