Let the player see where a unit can walk #20
No reviewers
Labels
No labels
area/ai
area/build
area/character
area/combat
area/data
area/docs
area/game
area/net
area/ui
area/world
size
l
size
m
size
s
type
bug
type
design
type
feature
type
refactor
type
test
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
icub3d/terra-redux-org!20
Loading…
Reference in a new issue
No description provided.
Delete branch "5-pathfinding-and-movement-range"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Routing lives in
src/world/path.rswith no ECS in sight: aTerrainview over themap plus the columns units occupy,
reachableto flood-fill a movement allowance, androutefor A* to a distant goal. One search body serves both, so the step rules and thetie-break are stated once rather than twice with a chance to disagree.
Determinism is the point of the tie-break. A heap keyed on
(priority, push order, node)breaks ties by discovery order, and a tile is never re-parented by an equal-costrival — so the same start and goal give the identical route, not merely an equal-length
one. That is what replay and PvP need, and what a player who walks the same path twice
expects to see.
Steps cost one and may cross one unit of height (
MAX_STEP). What elevation costs isan M2 question; this is the floor it will be built on.
src/world/movement.rsis the thin ECS layer over that search: left-click selects theunit under the cursor, since the camera already owns right and middle. One flood fill
answers both halves of the overlay — the tiles offered and the route to the one hovered
come from the same search, so a unit can never walk a different way than the line
promised. Three shapes, not three colours, per § Visual Style: a square on the selected
unit's tile, a diamond on each tile it can reach, and a line to the cursor ending in an
arrowhead.
A move can be previewed but not made; executing one is an action, and actions arrive
with resolution (#7).
Verification
cargo fmt --check,cargo clippy --all-targets -- -D warnings, andcargo test(114passing) are clean. There is no display in this environment, so the overlay's appearance
is unverified — when you run it, look at whether the diamonds stop where the movement
allowance says they should, and whether the arrowhead lands on the tile under the cursor
rather than one off it.
Closes #5
🤖 Generated with Claude Code
https://claude.ai/code/session_01TA4hJHkRSU3XBxZYtMKXdh