QcServerBoats Class
What players do with boats and how boats move in the server tick (decision E-920): placing a boat from its item on water or on the ground, breaking it with a hit (it drops its item), getting in with a use and out with sneak, and driving it: each input of the driver steps their boat by the shared boat physics (QcBoatState::step) with the input's keys, the same step the driver's client predicts, so driving needs no correction. More...
| Header: | #include <server/boats/QcServerBoats.h> |
Public Functions
| bool | fits(const QcCreature &creature) const |
| bool | hit(QcServerClient &client, quint32 id) |
| void | leave(QcServerClient &client) |
| bool | place(QcServerClient &client, const QcMsg::UseItem &message) |
| QcBoat * | spawn(QcBoat boat) |
| std::optional<QcBoatState> | stateOf(const QcServerClient &client) const |
| bool | steer(QcServerClient &client, const QcPlayerInput &input) |
| QcBoat * | summon(const QString &item, const QcVec3 &wanted, float yaw) |
| void | tick() |
| bool | use(QcServerClient &client, quint32 id) |
| quint32 | vehicleOf(const QcServerClient &client) const |
Static Public Members
| QcVec3 | exitSpot(const QcBlockAccess &world, const QcBoat &boat) |
| const double | pickupReach |
| const double | seatTolerance |
Detailed Description
In the tick the boats nobody drives move (QcBoatManager), a boat picks up a creature it touches into its free front seat, and drivers and passengers are put on their seats.
Member Function Documentation
[static] QcVec3 QcServerBoats::exitSpot(const QcBlockAccess &world, const QcBoat &boat)
Returns free ground of world for a driver getting out of boat: beside the boat on a bank, else on top of the boat. Also where a driver is saved (QcServerPersistence).
bool QcServerBoats::fits(const QcCreature &creature) const
Returns whether creature, by its kind, fits into a boat: it walks (no fish, flyer or hoverer) and is narrower than the boat.
bool QcServerBoats::hit(QcServerClient &client, quint32 id)
Handles a hit of client on the boat id, which breaks it (dropping its item, except in creative mode); its riders get out. Returns false when id is no boat.
void QcServerBoats::leave(QcServerClient &client)
Gets the player client out of the boat, onto the bank beside it or on top of it; nothing when not driving.
bool QcServerBoats::place(QcServerClient &client, const QcMsg::UseItem &message)
Places a boat from the held item of client on the water or ground message clicked. Returns false when the item places no boat. A refused placement (too far, no room, limit) still returns true.
QcBoat *QcServerBoats::spawn(QcBoat boat)
Adds boat (commands, tests) with a new id. Returns it, or null when the limit is reached.
std::optional<QcBoatState> QcServerBoats::stateOf(const QcServerClient &client) const
Returns the state of the boat the player client drives, for their client's prediction; none when not driving.
bool QcServerBoats::steer(QcServerClient &client, const QcPlayerInput &input)
Handles the input of the driver client: the view turns, sneak gets out, otherwise the keys paddle and steer and the boat moves one tick. Returns false when the player drives no boat (the input moves the player).
QcBoat *QcServerBoats::summon(const QString &item, const QcVec3 &wanted, float yaw)
Returns a new boat of the boat item item at wanted facing yaw (/summon), or null when the item places no boat or the limit is reached.
void QcServerBoats::tick()
Moves the boats nobody drives, lets boats pick up creatures and seats drivers and passengers.
bool QcServerBoats::use(QcServerClient &client, quint32 id)
Handles a use of the boat id by client: the player gets in as its driver. Returns false when id is no boat.
quint32 QcServerBoats::vehicleOf(const QcServerClient &client) const
Returns the entity id of the boat the player client drives, 0 for none.
Member Variable Documentation
const double QcServerBoats::pickupReach
A creature this close to a boat's box (horizontally) touches it and gets in.
const double QcServerBoats::seatTolerance
A driver or passenger found further than this from the seat was moved by something else (a teleport, a knock-back, a respawn) and is no longer in the boat.