QcSpawnerRules Class
How monster spawners work (decision E-520), every game tick: a spawner with a creature kind counts its delay down while a player is within its block's range; at 0 it runs a cycle: unless maxNearby creatures of its kind are within nearbyRange of its block or the world holds QcServerLimits::spawnerCreatures creatures of spawners, it tries count random cells of its area and spawns a creature on each fitting one (room for the body's height and width, ground below unless it flies, block light at most maxLight for every kind, sky light not counted). More...
| Header: | #include <server/spawners/QcSpawnerRules.h> |
Public Functions
| void | announceChanges() |
| bool | fits(QcBlockPos feet, const QcSpawnerDefinition &rules, QcCreatureKindId type) const |
| int | nearbyOf(QcBlockPos pos, const QcSpawnerDefinition &rules, QcCreatureKindId type) const |
| int | spawnedCount() const |
| void | tick() |
Static Public Members
| QcMsg::SpawnerDisplay | displayOf(const QcServerWorld &world, QcBlockPos pos) |
Detailed Description
After a cycle that spawned (or found its area full) it waits a random delay in [minDelay, maxDelay]; a cycle that found no fitting cell tries again in the next tick. Kinds a spawner may not bring forth (QcSpawnerContent::refusal) wait. Without a player in the world nothing is done. The creatures are ordinary, not persistent, remember their spawner and take its confined.
Member Function Documentation
void QcSpawnerRules::announceChanges()
Tells the clients that have a chunk about the spawners in it that changed (QcMsg::SpawnerDisplay).
[static] QcMsg::SpawnerDisplay QcSpawnerRules::displayOf(const QcServerWorld &world, QcBlockPos pos)
Returns what a client is told about the spawner at pos of world: its kind's index, -1 for none.
bool QcSpawnerRules::fits(QcBlockPos feet, const QcSpawnerDefinition &rules, QcCreatureKindId type) const
Returns whether a creature of kind type may appear with its feet in cell feet by rules.
int QcSpawnerRules::nearbyOf(QcBlockPos pos, const QcSpawnerDefinition &rules, QcCreatureKindId type) const
Returns the creatures of kind type within the nearbyRange of rules of the spawner block at pos on every axis.
int QcSpawnerRules::spawnedCount() const
Returns the creatures of spawners awake in the world.
void QcSpawnerRules::tick()
Counts the delays down and runs the cycles of this game tick.