Skip to content

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 ​

ts
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 ​

ts
readonly height: number;

Defined in: src/nav/flowField.ts:10


steps ​

ts
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 ​

ts
readonly width: number;

Defined in: src/nav/flowField.ts:9

Methods ​

costAt() ​

ts
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 ​

ParameterType
txnumber
tynumber

Returns ​

number


stepAt() ​

ts
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 ​

ParameterType
txnumber
tynumber

Returns ​

readonly [number, number] | null

Released under the MIT License.