QtCraft API C++ classes QML types Handbook

QcDoorPassage Class

How creatures that open doors (QcPathRules::opensDoors, decision E-423) go through them: they open the closed wooden door on their path ahead (QcMobNavigator::Navigation::door) and close the one they opened once they are through, and they take turns at a door, one at a time (decision E-411). More...

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

Public Types

struct Moves

Public Functions

void startTick()
std::optional<QcPhysics::Steering> waitAtDoor(QcCreature &mob, const QcMobNavigator::Navigation &navigation, const QcPathGround &ground)

Static Public Members

const double passed
const double queue
const double reach
const double stepBack
QcDoorPassage::Moves use(const QcCreature &mob, std::optional<QcBlockPos> opened, const QcMobNavigator::Navigation &navigation)

Detailed Description

The door a creature opened is its own state (opened, a villager's QcVillager::openedDoor); what it does to the world comes back as Moves for the caller to carry out.

Member Function Documentation

void QcDoorPassage::startTick()

A new tick: the turns of the last one decide.

[static] QcDoorPassage::Moves QcDoorPassage::use(const QcCreature &mob, std::optional<QcBlockPos> opened, const QcMobNavigator::Navigation &navigation)

Returns the door moves of mob following navigation: it opens the door on the path ahead and closes the one it went through (opened, the door it held open).

std::optional<QcPhysics::Steering> QcDoorPassage::waitAtDoor(QcCreature &mob, const QcMobNavigator::Navigation &navigation, const QcPathGround &ground)

Lets mob, following navigation on ground, take its turn at a door.

One door, one creature at a time: of the creatures in a doorway or within queue of a door on their next waypoint, one goes through (the one in the doorway, else the one already going, else the nearest, as of the last tick); the others wait, stepping back out of the doorway where the ground allows. Returns the steering of one that waits; none for one that goes or has no door ahead (or flees).

Member Variable Documentation

const double QcDoorPassage::passed

A door counts as passed once the creature is this far from its cell (horizontally).

const double QcDoorPassage::reach

How close a creature comes to a door to open it.