QtCraft API C++ classes QML types Handbook

QcVillagerRoads Class

Long walks through a village (decision E-411): a path search covers only 64 x 64 cells around the walker (QcPathWindow, decision E-400), so a villager whose goal lies farther first walks to the cell of the village's roads that brings it closest to the goal along the roads, and from there on (legs). More...

Header: #include <server/villages/QcVillagerRoads.h>

Public Functions

std::optional<QcBlockPos> nextLeg(const QcVillagePlan &plan, QcBlockPos from, QcBlockPos to)
qint64 planned() const
std::optional<QcBlockPos> wayOutOfWater(const QcVillagePlan &plan, QcBlockPos from)

Static Public Members

const int legHeight
const int legReach
const int maxGraphs

Detailed Description

The roads are a coarse graph: the cells above the road, branch road and doorstep cells and the boardwalks and jetties of the plan (QcVillagePlan), each joined to its eight neighbours at most one block higher or lower; the distance along them comes from a breadth-first search from the road cell nearest the goal. The graphs of the villages last used are kept.

Member Function Documentation

std::optional<QcBlockPos> QcVillagerRoads::nextLeg(const QcVillagePlan &plan, QcBlockPos from, QcBlockPos to)

Returns the next leg from from towards to in the village of plan: the stand cell on its roads to walk to first. None when to lies within legReach or the roads bring the walker no closer.

qint64 QcVillagerRoads::planned() const

Returns the legs planned since the start (tests, measurements).

std::optional<QcBlockPos> QcVillagerRoads::wayOutOfWater(const QcVillagePlan &plan, QcBlockPos from)

Returns the way out of the water in the village of plan for a villager at from that found no path from there (fallen off a boardwalk, under its own house): the nearest road cell on land (not a boardwalk or jetty) within legHeight above or below. None without one.

Member Variable Documentation

const int QcVillagerRoads::legHeight

Road cells farther than this above or below the walker are no leg.

const int QcVillagerRoads::legReach

Goals within this many cells (on both horizontal axes) are walked to directly.

const int QcVillagerRoads::maxGraphs

Road graphs of villages kept at most; the least recently used goes.