QtCraft API C++ classes QML types Handbook

QcMobBreeding Class

Breeding of peaceful animals (decision E-293), on the timers of QcCreature. More...

Header: #include <server/animals/QcMobBreeding.h>

Public Types

struct Birth
enum class Fed { No, Love, Young }

Public Functions

QcMobBreeding::Fed feed(QcCreature &mob, const QString &item) const
bool roomFor(const QList<QcCreature> &mobs, QcCreatureKindId type, const QcVec3 &position) const
void setLimits(qint64 crowd, qint64 bredPerKind)
QList<QcMobBreeding::Birth> tick(const QcBlockAccess &world, QcMobManager &mobs, double dt) const
bool wouldEat(const QcCreature &mob, const QString &item) const

Static Public Members

const double courtshipSeconds
const int crowdLimit
const double feedGrowUpShare
const int maxBredPerKind

Detailed Description

An adult fed with one of its breeding.food falls in love (unless it is in love already or still resting after breeding); two awake animals of a kind in love within partnerDistance that see each other get a young one at the feet of one of them and rest for cooldownSeconds. Feeding a young one brings it closer to growing up. Timers only run while the animal is awake (its chunk loaded).

Member Type Documentation

enum class QcMobBreeding::Fed

What feeding did (feed()).

ConstantValueDescription
QcMobBreeding::Fed::No0It does not eat that now.
QcMobBreeding::Fed::Love1It is in love.
QcMobBreeding::Fed::Young2A young one grew up a little.

Member Function Documentation

QcMobBreeding::Fed QcMobBreeding::feed(QcCreature &mob, const QString &item) const

Feeds mob with the item named item; returns what happened (No: it does not eat that now).

bool QcMobBreeding::roomFor(const QList<QcCreature> &mobs, QcCreatureKindId type, const QcVec3 &position) const

Returns whether another young one of type may be born at position among mobs.

void QcMobBreeding::setLimits(qint64 crowd, qint64 bredPerKind)

Sets the bounds of breeding: crowd animals around the birth place and bredPerKind bred ones of a kind in the world.

QList<QcMobBreeding::Birth> QcMobBreeding::tick(const QcBlockAccess &world, QcMobManager &mobs, double dt) const

Advances the timers of mobs by dt seconds and pairs animals in love (the crowd around the birth place read from world); returns the young ones to spawn.

bool QcMobBreeding::wouldEat(const QcCreature &mob, const QString &item) const

Returns whether mob would eat the item named item now (in love or growing up).

Member Variable Documentation

const double QcMobBreeding::courtshipSeconds

Seconds an animal is in love before it pairs (others see it in love first).

const double QcMobBreeding::feedGrowUpShare

Share of the time to grow up that feeding a young one takes off.