QcLineOfSight Namespace
Server checks that a player can reach and see what they act on (decision E-092): the same voxel raycast the client aims with (QcRaycast, visible blocks; liquids do not block) from the eye towards sample points of the target. More...
| Header: | #include <server/gameplay/QcLineOfSight.h> |
Functions
| QcAabb | blockBox(QcBlockPos pos) |
| bool | canSee(const QcBlockAccess &world, const QcServerClient &player, QcBlockPos pos) |
| bool | canSee(const QcBlockAccess &world, const QcServerClient &player, const QcAabb &body) |
| double | eyeHeight(const QcServerClient &player) |
| QcVec3 | eyeOf(const QcServerClient &player) |
| bool | isWithinReach(const QcServerClient &player, QcBlockPos pos) |
| bool | reaches(const QcBlockAccess &world, const QcVec3 &eye, const QcAabb &box, std::optional<QcBlockPos> target = std::nullopt) |
| bool | seesPoint(const QcBlockAccess &world, const QcVec3 &eye, const QcVec3 &point) |
Detailed Description
Seeing any one of them is enough, so a target that only shows a corner still counts.
Function Documentation
QcAabb QcLineOfSight::blockBox(QcBlockPos pos)
Returns the cell of the block at pos as a box.
bool QcLineOfSight::canSee(const QcBlockAccess &world, const QcServerClient &player, QcBlockPos pos)
Returns whether player sees the block at pos of world from the eyes (standing, or crouching while he sneaks or sneaked on the input before, decision E-961), now or before the last input (decision E-092); the block does not hide itself.
bool QcLineOfSight::canSee(const QcBlockAccess &world, const QcServerClient &player, const QcAabb &body)
Returns whether player sees the body in world from the eyes (standing, or crouching while he sneaks or sneaked on the input before, decision E-961), now or before the last input (decision E-092).
double QcLineOfSight::eyeHeight(const QcServerClient &player)
Returns the height of the eyes of player above his feet: QcPhysics::sneakEyeHeight while he crouches (sneaks on foot; in flight sneak descends, and the vehicles clear a rider's sneak), else QcPhysics::playerEyeHeight (decision E-961).
QcVec3 QcLineOfSight::eyeOf(const QcServerClient &player)
Returns where the eyes of player are now (eyeHeight()): rays and projectiles start there.
bool QcLineOfSight::isWithinReach(const QcServerClient &player, QcBlockPos pos)
Returns whether the block at pos is within the reach of player from the eyes, standing or, while he sneaks or sneaked on the input before, crouching (decision E-961): QcRaycast::playerReach plus a metre of slack for movement between the client's decision and the server's check.
bool QcLineOfSight::reaches(const QcBlockAccess &world, const QcVec3 &eye, const QcAabb &box, std::optional<QcBlockPos> target = std::nullopt)
Returns whether a point of box in world (centre, corners and face centres, pulled 10 % towards the centre) is reached from eye without a visible block in between. Blocks of target itself do not count, nor does the block in the eye's own cell (unless that cell is the target).
bool QcLineOfSight::seesPoint(const QcBlockAccess &world, const QcVec3 &eye, const QcVec3 &point)
Returns whether point is reached from eye in world by one ray without a visible block in between (the block in the eye's own cell does not count): how a creature looks for a player (decision E-401).