QcInfestation Class
Infested blocks and the creatures that hide in them (silverfish, decision E-453). More...
| Header: | #include <server/mobs/QcInfestation.h> |
Public Functions
Static Public Members
| const double | hideChance |
| quint32 | release(QcServerState &state, const QcBlockDefinition &definition, QcBlockPos pos) |
| const int | wakeHeight |
| const int | wakeReach |
Detailed Description
An infested block (QcBlockDefinition::infestsBlock, infestsMob) lets its creature out when it breaks with drops (QcServerBlocks::breakBlock calls release). A creature of a kind that hides in blocks (QcMobDefinition::hidesInBlocks) that was hurt wakes its kind in the infested blocks around it; an idle one now and then turns a block next to it into the infested block of its kind and is gone. A creature that may not change the world (QcCreature::mayGrief: the game rule mobGriefing off, as in the reference, or the creature confined or without a mind; decision E-510) does not hide, and its waking puts the base block back instead of breaking the infested one (no creature comes out).
Member Function Documentation
bool QcInfestation::hide(const QcCreature &mob, QcBlockFace face)
Hides mob in the block next to the middle of its body towards face when that block has an infested block of its kind and it may change the world: the block turns into it and the creature is removed. Returns whether it hid.
[static] quint32 QcInfestation::release(QcServerState &state, const QcBlockDefinition &definition, QcBlockPos pos)
Returns the creature of the infested block definition that comes out into state where the block broke at pos; its id, 0 for none (no infested block, an unknown kind).
void QcInfestation::tick()
Before the creatures move: those hurt since their last move wake their kind, idle ones hide.
int QcInfestation::wake(const QcCreature &mob)
Wakes the kind of mob in the infested blocks around it: they break one after another, nearest layers first, and after each one the waking stops with even chance (as in the reference); with a creature that may not change the world each turns back into its base block instead. Returns how many blocks woke.
Member Variable Documentation
const double QcInfestation::hideChance
Chance per tick that an idle creature that hides in blocks tries to hide.