1681-engine / index / FlowField
Interface: FlowField ​
Defined in: src/nav/flowField.ts:8
Which way to step from every tile to reach the nearest goal: one search for a whole crowd. A hundred monsters chasing one player cost one flow field a re-plan, where a hundred findPaths would cost a hundred searches.
Properties ​
costs ​
readonly costs: Float32Array;Defined in: src/nav/flowField.ts:12
Walking cost from each tile (row-major) to its nearest goal, Infinity where none can be reached.
height ​
readonly height: number;Defined in: src/nav/flowField.ts:10
steps ​
readonly steps: Int8Array;Defined in: src/nav/flowField.ts:14
The step to take from each tile, an index into NAV_STEPS; -1 on a goal and where nothing is reached.
width ​
readonly width: number;Defined in: src/nav/flowField.ts:9
Methods ​
costAt() ​
costAt(tx, ty): number;Defined in: src/nav/flowField.ts:18
The cost from (tx, ty) to its nearest goal (Infinity out of reach or outside the grid).
Parameters ​
| Parameter | Type |
|---|---|
tx | number |
ty | number |
Returns ​
number
stepAt() ​
stepAt(tx, ty): readonly [number, number] | null;Defined in: src/nav/flowField.ts:16
The step from tile (tx, ty) as [dx, dy], or null on a goal, a wall, outside the grid or out of reach.
Parameters ​
| Parameter | Type |
|---|---|
tx | number |
ty | number |
Returns ​
readonly [number, number] | null