QtCraft API C++ classes QML types Handbook

QcSwimRoutes Class

Routes of creatures that swim (decisions E-502, E-972), like the swimming goals of the role model: a goal only in a cell of water where the whole body has room (QcSwimSpace::fits), reached through such cells. More...

Header: #include <server/pathing/QcSwimRoutes.h>

Public Functions

QcSwimRoutes(QRandomGenerator &random)
bool plan(QcCreature &mob, QcPhysics::BodySize body, const QcBlockAccess &world, const QcVec3 &away)
QcVec3 towardsNext(QcCreature &mob, QcPhysics::BodySize body, const QcBlockAccess &world)

Static Public Members

const int depthReach
const int lookAhead
const int maxCells
const double minGoalDistance
const int reach
const double waypointReach

Detailed Description

A route is planned by a flood through the water around the creature, cell by cell across faces, within reach cells sideways and depthReach up and down; the goal is drawn from the cells found (a fleeing creature takes the one farthest along its way away). The route is kept in the creature's QcMobPath: purpose Wander or Flee, goal the goal's feet and cells the cells to swim through, of which the creature heads for the farthest it sees in a straight line. In a pool too small to swim in, the route leads to the middle of the creature's own cell, where it idles.

Member Function Documentation

[explicit] QcSwimRoutes::QcSwimRoutes(QRandomGenerator &random)

Creates the routes; the goals are drawn from random.

bool QcSwimRoutes::plan(QcCreature &mob, QcPhysics::BodySize body, const QcBlockAccess &world, const QcVec3 &away)

Plans a new route of mob, a body of body, in world: a wandering one, or one away from danger towards away when that is not zero. Returns whether it found any (none where its body has no room at all; its path is then cleared).

QcVec3 QcSwimRoutes::towardsNext(QcCreature &mob, QcPhysics::BodySize body, const QcBlockAccess &world)

Returns the way from the feet of mob, a body of body in world, to its next waypoint, after passing the waypoints it reached and skipping those it can cut across to; zero once the route is done (QcMobPath::finished).

Member Variable Documentation

const int QcSwimRoutes::lookAhead

How many waypoints ahead a creature looks for one it can swim to in a straight line.

const int QcSwimRoutes::maxCells

Most cells one flood looks at.

const double QcSwimRoutes::minGoalDistance

A wandering goal lies at least this far away, in metres, where the water allows.

const double QcSwimRoutes::waypointReach

A waypoint this close to the feet, in metres, counts as reached.