PlayerOnServer class
Player on the server in online session.
Server-side base for a player simulated on the host, adding server-authoritative behavior on top of MpPlayer. It handles damage, lives and morphing as the authority, and player-vs-player collisions (keeping overlapping players apart and applying bump impulses).
Base classes
- class MpPlayer
- Player in online session.
Derived classes
- class LocalPlayerOnServer
- Local player in online session.
- class RemotePlayerOnServer
- Remote player in online session.
Constructors, destructors, conversion operators
- PlayerOnServer()
- Creates a new instance.
Public functions
- auto OnHandleCollision(ActorBase* other) -> bool override
- Called when the object collides with another object.
- auto CanCauseDamage(ActorBase* collider) -> bool override
- Called to check whether
collidercan cause damage to the object. -
auto TakeDamage(std::
int32_t amount, float pushForce = 0.0f, bool ignoreInvulnerable = false) -> bool override - Takes damage.
-
auto AddLives(std::
int32_t count) -> bool override - Adds lives.
- auto MorphTo(PlayerType type) -> bool override
- Morphs to a given player type.
- auto MorphToInstantly(PlayerType type) -> bool override
- Changes the player type immediately, without any transition or effect.
- auto Respawn(Vector2f pos) -> bool override
- Respawns the player.
-
auto SetModifier(Modifier modifier,
const std::
shared_ptr<ActorBase>& decor) -> bool override - Sets current modifier.
- auto SetShield(ShieldType shieldType, float timeLeft) -> bool override
- Sets active shield.
- auto IncreaseShieldTime(float timeLeft) -> bool override
- Increases active shield time.
- void DecreaseShieldTime(float time) override
- Reduces remaining shield time when a hit is absorbed (only if more than
timeremains).
Protected functions
- void OnUpdate(float timeMult) override
- Called every frame to update the object state.
- auto IsAttacking() const -> bool
- Returns
trueif the player is currently performing a damaging move.
Protected variables
-
std::
shared_ptr<ActorBase> _lastAttacker - Actor that last attacked this player (cleared once _
lastAttackerTimeout elapses). - float _lastAttackerTimeout
- Remaining time before the last attacker reference is cleared.
- bool _canTakeDamage
- Whether the player can currently take damage.
- bool _justWarped
- Whether the player has just warped (consumed once by the outgoing broadcast to flag interpolation reset).
- float _bumpCooldown
- Remaining cooldown before this player can be bumped by another player again.
- bool _bumpInitialized
- Whether player-vs-player collision dispatch has been enabled (done lazily after activation).
- bool _sugarRushLastSent
- Whether sugar rush was active when it was last sent to the peers, to only resync on change.
-
std::
int32_t _gemsLostOnHit - Gems the next hit takes in Treasure Hunt, as the weapon of the shot says (see WeaponOptions::
GemsLost).
Function documentation
bool Jazz2:: Actors:: Multiplayer:: PlayerOnServer:: MorphTo(PlayerType type) override
Morphs to a given player type.
Returns false if the player already has the type or its sprites aren't available.
bool Jazz2:: Actors:: Multiplayer:: PlayerOnServer:: MorphToInstantly(PlayerType type) override
Changes the player type immediately, without any transition or effect.
Returns false if the player already has the type or its sprites aren't available.