QtCraft API C++ classes QML types Handbook

QcVillagerHomes Namespace

Beds and workstations of villagers in the village state (decision E-411): a villager claims a bed and a workstation under its creature's persistent id (holder, QcCreature::uid, decision E-420; QcVillage::Spot::claimedBy) and counts in the village's population. More...

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

Classes

struct Limits
struct Lying

Variables

const int strayReach

Functions

std::optional<QcVec3> besideBed(const QcBlockAccess &world, const QcPathCellTable &cells, QcBlockPos head, QcPathRules rules)
bool claimBed(QcVillage &village, QcVillager &villager, quint64 holder, const QcVec3 &near)
bool claimWorkstation(QcVillage &village, QcVillager &villager, quint64 holder, const QcVillagerSettings &settings, const QcVec3 &near)
int dropLostClaims(QcVillage &village, const QSet<quint64> &present)
QList<QcBlockPos> freeBedsIn(const QcVillage &village, QcChunkPos chunk)
void keepClaims(QcVillage &village, QcVillager &villager, quint64 holder, const QcVillagerSettings &settings)
std::optional<QcVillagerHomes::Lying> lyingIn(const QcBlockAccess &world, QcBlockPos head)
void moveIn(QcVillage &village, QcVillager &villager, quint64 holder, const QcVec3 &near)
void moveOut(QcVillages &villages, QcVillager &villager, quint64 holder, const QcVillagerSettings &settings)
void release(QcVillages &villages, const QcVillager &villager, quint64 holder)
QcVillager settle(QcVillage &village, QcBlockPos bed, quint64 holder, const QcVillagerSettings &settings, quint32 look)

Detailed Description

A claim on a spot that is gone or that someone else holds lapses; a villager that dies frees its claims and leaves the population.

Classes

class Limits

Villagers living in one village and in the world at most (QcServerLimits villagersPerVillage, villagers): no villager spawns beyond them. More...

class Lying

Where and how a villager lies in the bed whose head is at head: on top of it, the head on the pillow, facing the foot (the client lays it on its back, QcAnimator). More...

Variable Documentation

const int QcVillagerHomes::strayReach

A villager holding claims strays at most this far beyond the village's reach (strolls, legs and flight go home); with every chunk of that area loaded, every one of them is in the world.

Function Documentation

std::optional<QcVec3> QcVillagerHomes::besideBed(const QcBlockAccess &world, const QcPathCellTable &cells, QcBlockPos head, QcPathRules rules)

Returns where a body under rules stands beside the bed of world whose head is at head: the cell next to it (around the foot first) that it can stand in (path cells from cells), nearest to the foot; none when the bed is walled in.

bool QcVillagerHomes::claimBed(QcVillage &village, QcVillager &villager, quint64 holder, const QcVec3 &near)

Claims for villager (persistent id holder) the free bed of village nearest to near; returns false when there is none.

bool QcVillagerHomes::claimWorkstation(QcVillage &village, QcVillager &villager, quint64 holder, const QcVillagerSettings &settings, const QcVec3 &near)

Claims for villager (persistent id holder) the free workstation of village nearest to near that its profession works at, or, for an unemployed villager, of any profession's kind in settings (it takes that profession: its look changes). Returns false when there is none.

int QcVillagerHomes::dropLostClaims(QcVillage &village, const QSet<quint64> &present)

Every villager of village is in the world (present, by persistent id): claims under other ids lapse. Returns the number of their holders.

QList<QcBlockPos> QcVillagerHomes::freeBedsIn(const QcVillage &village, QcChunkPos chunk)

Returns the free beds of village whose heads lie in chunk, in the village's order.

void QcVillagerHomes::keepClaims(QcVillage &village, QcVillager &villager, quint64 holder, const QcVillagerSettings &settings)

Drops the claims of villager (persistent id holder) on spots of village that are gone or held by another; one that lost its workstation before it gained any experience becomes unemployed again (its look changes, settings).

std::optional<QcVillagerHomes::Lying> QcVillagerHomes::lyingIn(const QcBlockAccess &world, QcBlockPos head)

Returns how a villager lies in the bed of world whose head is at head.

void QcVillagerHomes::moveIn(QcVillage &village, QcVillager &villager, quint64 holder, const QcVec3 &near)

The homeless villager (persistent id holder) moves into village: it counts there, a settlement without a style takes its style, and it claims the free bed nearest to near.

void QcVillagerHomes::moveOut(QcVillages &villages, QcVillager &villager, quint64 holder, const QcVillagerSettings &settings)

villager (persistent id holder) leaves its village among villages for good while it lives (relocated, decision E-490): its claims are freed, the village counts one less (a settlement left empty is forgotten) and it is homeless (village 0); one without experience loses its profession with its workstation (settings).

void QcVillagerHomes::release(QcVillages &villages, const QcVillager &villager, quint64 holder)

villager (persistent id holder) died or was taken out of the world: its claims among villages are freed, the population counts one less unless the village was reconciled without it (QcVillage::Residents), and a settlement left without spots and villagers is forgotten.

QcVillager QcVillagerHomes::settle(QcVillage &village, QcBlockPos bed, quint64 holder, const QcVillagerSettings &settings, quint32 look)

Returns a new villager of village with the persistent id holder in its free bed bed, its species settings and the seed of its look look: the bed claimed, the population counted. Its profession is the unemployed one until it claims a workstation.