QtCraft API C++ classes QML types Handbook

QcBoatManager Class

The boats of a world (decision E-920), the table of their kind in the entity register: adding, finding and removing them within the world's limit, and the step of the boats nobody drives: they push each other apart, living bodies push them, and each moves by the shared boat physics. More...

Header: #include <server/boats/QcBoatManager.h>

Public Functions

bool add(const QcBoat &boat)
qsizetype adopt(const QList<QcBoat> &boats)
const QList<QcBoat> &all() const
const QcBoat *carrying(quint32 creature) const
QcBoat *drivenBy(quint32 player)
const QcBoat *drivenBy(quint32 player) const
QList<QcBoat> &editableAll()
QcBoat *find(quint32 id)
const QcBoat *find(quint32 id) const
qsizetype lastStepped() const
qsizetype limit() const
std::optional<QcBoat> remove(quint32 id)
void setLimit(qsizetype limit)
void tick(const QcServerWorld &world, const QList<QcAabb> &bodies)

Static Public Members

QcAabb bodyOf(const QcBoat &boat)
const int maxBoats
const double pushPerTick
const double restSpeed
const double restSpin

Detailed Description

A driven boat is stepped with its driver's inputs instead (QcServerBoats::steer), so it moves as the driver's client predicts; nothing but blocks stops it. A boat that came to rest, still on the water or on the ground (QcBoat::Rest), is not stepped until something pushes or moves it, a rider gets in or its blocks change.

Member Function Documentation

bool QcBoatManager::add(const QcBoat &boat)

Adds boat. Returns false when the limit is reached.

qsizetype QcBoatManager::adopt(const QList<QcBoat> &boats)

Adds the boats of a chunk that came back (decision E-374); returns how many were left out at the limit.

const QList<QcBoat> &QcBoatManager::all() const

Returns every boat.

[static] QcAabb QcBoatManager::bodyOf(const QcBoat &boat)

Returns the box of the body of boat.

const QcBoat *QcBoatManager::carrying(quint32 creature) const

Returns the boat the creature (entity id) sits in; null for none.

QcBoat *QcBoatManager::drivenBy(quint32 player)

Returns the boat the player (entity id) drives; null for none.

const QcBoat *QcBoatManager::drivenBy(quint32 player) const

Returns the boat the player (entity id) drives; null for none.

QList<QcBoat> &QcBoatManager::editableAll()

Returns the boats for moving them from outside (pistons, riders); never add or remove through it.

QcBoat *QcBoatManager::find(quint32 id)

Returns the boat with entity id, or null when there is none.

const QcBoat *QcBoatManager::find(quint32 id) const

Returns the boat with entity id, or null when there is none.

qsizetype QcBoatManager::lastStepped() const

Returns how many boats the latest tick stepped (neither driven, dormant nor at rest).

qsizetype QcBoatManager::limit() const

Returns the number of boats the world may hold.

See also setLimit().

std::optional<QcBoat> QcBoatManager::remove(quint32 id)

Removes the boat with entity id. Returns it, or nothing when there is none.

void QcBoatManager::setLimit(qsizetype limit)

Sets the number of boats the world may hold to limit.

See also limit().

void QcBoatManager::tick(const QcServerWorld &world, const QList<QcAabb> &bodies)

Pushes between boats and from bodies (boxes of living bodies that sit in no boat) on the boats nobody drives, then steps each of them one tick in world. Boats whose chunk is not loaded (dormant) and boats at rest wait.

Member Variable Documentation

const int QcBoatManager::maxBoats

Boats in the world by default (QcServerLimits::maxBoats).

const double QcBoatManager::pushPerTick

How fast an overlapping boat or body pushes a boat nobody drives out of a full overlap (m/s added per tick, less for a smaller overlap).