Re-path when a placed building cuts an in-flight path #83

Closed
opened 2026-09-07 20:56:33 +01:00 by liamjd · 1 comment
Owner

Part of milestone #4. Depends on #56 and #80. Filed now because #56's 'things that will bite' section is the only place this is written down.

A path is a snapshot PackedVector3Array. Once #56 blocks a building's cells in the A* graph, a pawn already walking through those cells still follows its old waypoints straight through the new wall.

Design:

  • The controller that issues paths (see the move command issue) connects to GameState.building_placed. For each moving pawn, if any remaining waypoint's cell is in building.cells(), re-path from the pawn's current cell to the original destination.
  • If the re-path is empty (the building sealed the only route), stop the pawn and flash it red, the same feedback as an unreachable command.
  • Cheap check first: compare waypoint cells against the footprint's cell set (a Dictionary-as-set, the house pattern), and only call find_path() for pawns actually affected.
  • Also handle building_removed: nothing needs to happen, but note in code why (a removed building only opens routes; existing paths stay valid).

AC:

  • Unit test with a flat TerrainGrid, a Buildings registry and a pawn mid-path: placing a building across the path replaces it with one that avoids the footprint; placing one that seals the route stops the pawn.
  • Headed check: drop a building in front of a walking pawn and watch it route around.
Part of milestone #4. Depends on #56 and #80. Filed now because #56's 'things that will bite' section is the only place this is written down. A path is a snapshot `PackedVector3Array`. Once #56 blocks a building's cells in the A* graph, a pawn already walking through those cells still follows its old waypoints straight through the new wall. Design: - The controller that issues paths (see the move command issue) connects to `GameState.building_placed`. For each moving pawn, if any remaining waypoint's cell is in `building.cells()`, re-path from the pawn's current cell to the original destination. - If the re-path is empty (the building sealed the only route), stop the pawn and flash it red, the same feedback as an unreachable command. - Cheap check first: compare waypoint cells against the footprint's cell set (a Dictionary-as-set, the house pattern), and only call `find_path()` for pawns actually affected. - Also handle `building_removed`: nothing needs to happen, but note in code why (a removed building only opens routes; existing paths stay valid). AC: - Unit test with a flat `TerrainGrid`, a `Buildings` registry and a pawn mid-path: placing a building across the path replaces it with one that avoids the footprint; placing one that seals the route stops the pawn. - Headed check: drop a building in front of a walking pawn and watch it route around.
Author
Owner

Flashing red will be implemented in issue #100.

Flashing red will be implemented in issue #100.
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
liamjd/UntitledColonyBuilder#83
No description provided.