QcFishSwimming Class
How water creatures move (fish, decision E-502), part of QcMobBehaviour: in water they swim without gravity along routes to goals where their body has room (QcSwimRoutes, a fleeing one away from danger), rest a moment at each goal and keep their whole body in the water (QcSwimSpace), steered also towards their school (cohesion, alignment and separation among the nearest creatures of their kind, schooling); a creature that swims in pulses (the squid, QcMobDefinition::pulse, decision E-974) pushes at the start of each pulse, glides between and tilts its body along its way (QcCreature::tilt); one without a mind (QcCreature::noAi) holds its place; out of water they fall, flop about and count their dry ticks (QcCreature::dryTicks), which QcBodyBurning turns into suffocation. More...
| Header: | #include <server/mobbrains/QcFishSwimming.h> |
Public Functions
| void | startTick(std::span<const QcCreature> mobs, const QcContentRegistry &content) |
| void | swim(qsizetype index, std::span<QcCreature> mobs, const QcMobDefinition &definition, const QcBlockAccess &world, double dt) |
Static Public Members
| const double | driftRate |
| const double | flopChance |
| const double | glideRate |
| bool | inWater(const QcBlockAccess &world, const QcVec3 &position) |
| const double | minCellSize |
| const double | pulseTravel |
| const double | restMaxSeconds |
| const double | rightingRate |
| const double | routeSpareSeconds |
| const double | routeTimeFactor |
| const double | schoolWander |
| QcVec3 | schooling(const QcVec3 &position, const QList<const QcCreature *> &others, const QcAquaticDefinition &aquatic) |
| const double | slowDistance |
| const double | thrustRate |
| const double | tiltRate |
| const double | tiltSpeed |
| const double | waitMaxSeconds |
| const double | waitMinSeconds |
| const double | wishReach |
Detailed Description
The neighbours come from a grid of each kind built once a tick, its cells as large as the kind's school radius, so a member looks into 27 cells; the grid keeps its storage from tick to tick.
Member Function Documentation
[static] bool QcFishSwimming::inWater(const QcBlockAccess &world, const QcVec3 &position)
Returns whether the cell of world at position holds water (not lava).
[static] QcVec3 QcFishSwimming::schooling(const QcVec3 &position, const QList<const QcCreature *> &others, const QcAquaticDefinition &aquatic)
Returns the steering a school adds to one member at position moving with velocity: towards the centre of the others (cohesion), along their mean heading (alignment) and away from those closer than separationDistance (separation), each weighted by aquatic. Pure.
void QcFishSwimming::startTick(std::span<const QcCreature> mobs, const QcContentRegistry &content)
Files the awake water creatures of mobs (kinds from content) of this tick into the neighbour grid.
void QcFishSwimming::swim(qsizetype index, std::span<QcCreature> mobs, const QcMobDefinition &definition, const QcBlockAccess &world, double dt)
One tick of dt seconds of the water creature at index of mobs, of the kind definition, in world.
Member Variable Documentation
const double QcFishSwimming::driftRate
Rate per second at which the water stops a creature without a mind (QcCreature::noAi).
const double QcFishSwimming::flopChance
Chance per tick that a fish on dry ground flops.
const double QcFishSwimming::minCellSize
Smallest side of a cell of the neighbour grid, in metres (the school radius may be 0).
const double QcFishSwimming::restMaxSeconds
Seconds a creature rests at a goal, at most.
const double QcFishSwimming::schoolWander
Weight of its own route for a fish with a school around it.
const double QcFishSwimming::slowDistance
Within this distance of its goal, in metres, a creature slows down.
const double QcFishSwimming::wishReach
Metres a creature tests its wish ahead for room in the water (QcSwimSpace::keepInside).