Documentation
¶
Overview ¶
Package pathing builds shared flow fields over a grid.Grid.
Rebuild once when walkability changes (build-phase end, tower place/sell). Units sample Direction or Next each tick instead of running A* per agent.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllReachable ¶
AllReachable reports whether every cell in cells is reachable on an already-built flow field.
Types ¶
type Field ¶
type Field struct {
Width int
Height int
ExitX int
ExitY int
// contains filtered or unexported fields
}
Field is a reverse-BFS flow field toward one exit cell.
For each reachable walkable tile, Next points one step closer to the exit. The exit cell points at itself. Unreachable cells have no next step.
func Rebuild ¶
Rebuild computes a flow field from every walkable cell toward (exitX, exitY).
Cost is O(width*height). Call when the map becomes dirty — not every frame.
func (*Field) Direction ¶
Direction returns a unit vector from cell (x, y) toward its next step. At the exit, or when unreachable, ok is false and dx, dy are 0.