QtCraft API C++ classes QML types Handbook

QcVillagerBreeding Class

Villagers getting children (decision E-415), checked every few seconds by QcVillagePopulation. More...

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

Public Types

struct Birth
struct Context

Public Functions

bool breedsNow(const QcVillage &village, const QcVillagerBreeding::Context &context, qsizetype worldPopulation) const
QList<QcVillagerBreeding::Birth> check(QList<QcCreature> &mobs, const QcVillagerBreeding::Context &context) const
bool willing(const QcCreature &mob) const

Detailed Description

Farmers holding more produce than shareAbove share it with villagers of their village nearby that lack food (QcVillagerBreedingSettings). Two adults of a village that are willing (awake, with a mind (QcCreature::noAi), standing, not fleeing or trading, resting no longer after their last child, each holding food produce) and see each other within partnerDistance get a child when their village breeds now: by day (the routine says neither home nor sleep), not in rain at its meeting point, with a free bed and more beds than villagers (one whose bed was broken claims the next free one), below the villagers per village and in the world (QcServerLimits). Each parent gives food produce and rests for cooldownSeconds; the child (QcVillagePopulation) moves into the free bed nearest to them. At most one child per village and check: a village fills its free beds over minutes, and only beds bound its size, as in the reference game.

Member Function Documentation

bool QcVillagerBreeding::breedsNow(const QcVillage &village, const QcVillagerBreeding::Context &context, qsizetype worldPopulation) const

Returns whether the villagers of village breed now in the tick of context (day, dry, a free bed and more beds than villagers, below the limits with worldPopulation villagers in the world).

QList<QcVillagerBreeding::Birth> QcVillagerBreeding::check(QList<QcCreature> &mobs, const QcVillagerBreeding::Context &context) const

Shares food and pairs the willing villagers among mobs of every village of context; returns the births, the parents' food given and their rest begun. The beds are claimed when the children settle.

bool QcVillagerBreeding::willing(const QcCreature &mob) const

Returns whether mob is a willing adult villager.