QtCraft API C++ classes QML types Handbook

QcMobFamilies Class

Parents and their children (QcMobDefinition::family, decision E-839; the Kjut), like a QObject and its children: a parent wounded and still alive splits off children of its family's kind (at most maxChildren of them live at once, maxSplits in its life); a child points to its parent (QcCreature::parent, and QcCreature::parentUid in a kept family). More...

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

Public Functions

QcMobFamilies(const QcMobFamilies &)
qint64 popped() const
void tick()
QcMobFamilies &operator=(const QcMobFamilies &)

Static Public Members

QList<quint32> childrenOf(const QcMobManager &creatures, quint32 parentId)
const int popSoundsPerTick
QList<quint32> split(QcServerState &state, quint32 parentId, int count)
const double splitLift
const double splitSpeed

Detailed Description

When a parent dies, every child of it pops in the next tick of the creatures, as QObject::deleteLater deletes later: it is gone with the family's pop sound and leaves the family's popDrops (no explosion, no block damage); a child killed on its own leaves only its own drops. When a parent leaves the world without a death (despawned, removed, fell into the void, or its chunk unloaded while it was not kept), its children vanish quietly with it. A kept parent whose chunk unloads rests with the chunk: its children stay and wait for it (QcCreature::parentUid; QcMobManager::relinkFamilies links them again when it loads); once the chunk it was last in is loaded without it (it died while they were unloaded), they are released as ordinary monsters. Children of a kept parent are kept too (QcMobManager::keep), those of a confined one confined.

Member Function Documentation

[delete] QcMobFamilies::QcMobFamilies(const QcMobFamilies &)

Copy-constructs an instance of QcMobFamilies. This function is deleted.

[static] QList<quint32> QcMobFamilies::childrenOf(const QcMobManager &creatures, quint32 parentId)

Returns the ids of the children of the parent parentId among creatures.

qint64 QcMobFamilies::popped() const

Returns the children that popped since the server started (tests, measurements).

[static] QList<quint32> QcMobFamilies::split(QcServerState &state, quint32 parentId, int count)

Splits up to count children off the parent parentId in state, no more than its family's maxChildren living at once and maxSplits in its life (counted in QcCreature::splits); returns the ids of the new children (none: no such parent, no family, no splits left).

void QcMobFamilies::tick()

Before the creatures move: the children of parents that left since the last call pop or vanish, the parents wounded since their last move split, and kept children note where their parent is or, waiting for one that is gone, are released.

[delete] QcMobFamilies &QcMobFamilies::operator=(const QcMobFamilies &)

Copy-assigns other to this QcMobFamilies instance. This function is deleted.

Member Variable Documentation

const int QcMobFamilies::popSoundsPerTick

Pop sounds per tick at most (many families dying at once).