Builds a FlowField over map in one call.
map
Convenience for one-off fields. When the destination changes every turn or every frame, construct a FlowField once and call FlowField.compute on it instead — that path reuses its buffers.
FlowField
const field = computeFlowField(offsetToHex(goalCol, goalRow), moveCost, map);for (const unit of army) { const path = field.path(offsetToHex(unit.col, unit.row)); if (path && path.length > 1) unit.travel(path);} Copy
const field = computeFlowField(offsetToHex(goalCol, goalRow), moveCost, map);for (const unit of army) { const path = field.path(offsetToHex(unit.col, unit.row)); if (path && path.length > 1) unit.travel(path);}
Builds a FlowField over
mapin one call.Convenience for one-off fields. When the destination changes every turn or every frame, construct a
FlowFieldonce and call FlowField.compute on it instead — that path reuses its buffers.