QtCraft API C++ classes QML types Handbook

QcVillagerRelocation Class

Villagers moving between villages (decision E-490), checked every few seconds by QcVillagePopulation. More...

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

Public Types

struct Context

Public Functions

int check(QList<QcCreature> &mobs, const QcVillagerRelocation::Context &context) const

Static Public Members

const int searchRadius
bool strayed(const QcVillage &village, const QcVec3 &at)

Detailed Description

A villager that stands more than QcVillagerHomes::strayReach beyond its village's area (carried off in a minecart, pushed or led away) leaves it: its claims are freed and the village counts one less. A villager without a bed whose village has none free, and a homeless one (no village, a settlement that is gone, or away when its village was reconciled), moves into the village with the free bed nearest to it within searchRadius, if that village has more beds than villagers, room below the villagers per village, and the villager does not stand beyond its area by more than strayReach (it would move out again at once). A bed whose claim lapsed is thus taken by any homeless villager near it, not only by a child. Villagers a structure confines (QcCreature::confined) and ones without a mind (QcCreature::noAi) never move.

Member Function Documentation

int QcVillagerRelocation::check(QList<QcCreature> &mobs, const QcVillagerRelocation::Context &context) const

Moves the awake villagers among mobs that strayed out of their villages of context and into new homes; returns the number of villagers that moved out or in.

[static] bool QcVillagerRelocation::strayed(const QcVillage &village, const QcVec3 &at)

Returns whether a villager at at stands beyond the area of village by more than strayReach.

Member Variable Documentation

const int QcVillagerRelocation::searchRadius

Homeless villagers find beds this far (horizontally) from where they stand.