QcProjectileManager Class
The projectiles of a world (decision E-425), the table of their kind in the entity register. More...
| Header: | #include <server/projectiles/QcProjectileManager.h> |
Public Types
| struct | BlockHit |
| struct | Handlers |
| struct | Hit |
| struct | Launch |
| struct | PlayerView |
Public Functions
| bool | add(QcProjectile projectile) |
| qsizetype | adopt(const QList<QcProjectile> &projectiles, const std::function<quint32 ()> &newId) |
| const QList<QcProjectile> & | all() const |
| bool | anyFlying() const |
| void | clear() |
| qint64 | crowdedOut() const |
| QList<QcProjectile> & | editableAll() |
| bool | launch(const QcProjectileManager::Launch &shot, quint32 id) |
| qsizetype | limit() const |
| qsizetype | perChunk() const |
| void | setLimit(qsizetype limit) |
| void | setPerChunk(qsizetype perChunk) |
| void | tick(const QcBlockAccess &world, const QList<QcProjectileFlight::Body> &bodies, const QList<QcProjectileManager::PlayerView> &players, double dt, const QcProjectileManager::Handlers &handlers) |
Static Public Members
| const double | bounceFactor |
| const qsizetype | defaultLimit |
| const qsizetype | defaultPerChunk |
| const double | pickupReach |
Detailed Description
Flying ones follow QcProjectileFlight and hit bodies or stick in blocks; stuck ones fall again when their block changes, can be picked up by players and go after their definition's despawnSeconds; flying ones go after flightSeconds and in the void. Only projectiles in loaded chunks move and age.
Bounds (QcServerLimits): at most limit projectiles in the world (a launch beyond is refused, the launcher keeps its ammunition) and perChunk stuck in one chunk (the oldest stuck there goes).
Member Function Documentation
bool QcProjectileManager::add(QcProjectile projectile)
Adds projectile as it is (tests, a chunk coming back); returns false (nothing added) beyond the limit or in the void (QcWorld::isInVoid).
qsizetype QcProjectileManager::adopt(const QList<QcProjectile> &projectiles, const std::function<quint32 ()> &newId)
Adds projectiles of a chunk that came back (decision E-374), with new ids from newId; returns how many were left out beyond the limits.
const QList<QcProjectile> &QcProjectileManager::all() const
Returns every projectile of the world.
bool QcProjectileManager::anyFlying() const
Returns whether any projectile flies (and needs the bodies of the tick).
void QcProjectileManager::clear()
Removes every projectile.
qint64 QcProjectileManager::crowdedOut() const
Returns the projectiles that went for the per-chunk bound since the start.
QList<QcProjectile> &QcProjectileManager::editableAll()
Returns every projectile of the world for changes in place (loading, tests).
bool QcProjectileManager::launch(const QcProjectileManager::Launch &shot, quint32 id)
Adds shot with the id id; returns false (nothing added) beyond the limit, for an unknown type, a speed beyond QcProjectileDefinition::maxSpeed or in the void.
qsizetype QcProjectileManager::limit() const
Returns the most projectiles the world holds.
See also setLimit().
qsizetype QcProjectileManager::perChunk() const
Returns the most stuck projectiles in one chunk.
See also setPerChunk().
void QcProjectileManager::setLimit(qsizetype limit)
Sets limit() to limit.
See also limit().
void QcProjectileManager::setPerChunk(qsizetype perChunk)
Sets perChunk() to perChunk.
See also perChunk().
void QcProjectileManager::tick(const QcBlockAccess &world, const QList<QcProjectileFlight::Body> &bodies, const QList<QcProjectileManager::PlayerView> &players, double dt, const QcProjectileManager::Handlers &handlers)
One tick of dt seconds of every projectile that does not rest: flight against the blocks of world and bodies, unsticking, pickup by players, ageing and despawning; what happens goes to handlers.
Member Variable Documentation
const double QcProjectileManager::bounceFactor
A projectile that hits a body during its short invulnerability bounces back with this share of its velocity, like the reference's arrows.
const qsizetype QcProjectileManager::defaultLimit
The default of limit(), QcServerLimits::projectiles.
const qsizetype QcProjectileManager::defaultPerChunk
The default of perChunk(), QcServerLimits::projectilesPerChunk.
const double QcProjectileManager::pickupReach
A player picks up a stuck projectile when it is within their box grown by this much.