Jazz2::Actors::Multiplayer::RemotePlayerOnServer class

Remote player in online session.

A connected client's player as simulated and shadowed on the server. Its input (pressed keys) and state are received from the owning client and applied here, with the reported position buffered and interpolated to smooth out network delay.

Base classes

class PlayerOnServer
Player on the server in online session.

Public types

enum class PlayerFlags { None = 0, SpecialMoveMask = 0x07, IsFacingLeft = 0x10, IsVisible = 0x20, IsActivelyPushing = 0x40, JustWarped = 0x100, EnableContinuousJump = 0x200, InMenu = 0x1000, InConsole = 0x2000 }
State flags of the remote player.

Constructors, destructors, conversion operators

RemotePlayerOnServer(std::shared_ptr<PeerDescriptor> peerDesc)
Creates a new instance.

Public functions

auto IsContinuousJumpAllowed() const -> bool override
Returns true if continuous jump is allowed.
auto IsLedgeClimbAllowed() const -> bool override
Returns true if ledge climbing is allowed.
auto OnHandleCollision(ActorBase* other) -> bool override
Called when the object collides with another object.
auto OnLevelChanging(Actors::ActorBase* initiator, ExitType exitType) -> bool override
Called when the level is about to change.
auto PrepareLevelCarryOver() -> PlayerCarryOver override
Returns current carry over information.
void WarpToPosition(Vector2f pos, WarpFlags flags) override
Warps to a given position.
auto SetModifier(Modifier modifier, const std::shared_ptr<ActorBase>& decor) -> bool override
Sets current modifier.
auto Freeze(float timeLeft) -> bool override
Freezes the player for specified time.
void SetInvulnerability(float timeLeft, InvulnerableType type) override
Sets invulnerability.
void AddScore(std::int32_t amount) override
Adds score.
auto AddHealth(std::int32_t amount) -> bool override
Adds health.
auto AddLives(std::int32_t count) -> bool override
Adds lives.
auto AddAmmo(WeaponType weaponType, std::int16_t count) -> bool override
Adds weapon ammo.
void AddWeaponUpgrade(WeaponType weaponType, std::uint8_t upgrade) override
Adds weapon upgrade.
auto SetDizzy(float timeLeft) -> bool override
Sets duration of dizziness.
auto SetShield(ShieldType shieldType, float timeLeft) -> bool override
Sets active shield.
auto IncreaseShieldTime(float timeLeft) -> bool override
Increases active shield time.
auto FireCurrentWeapon(WeaponType weaponType) -> bool override
Fires currently equipped weapon.
void EmitWeaponFlare() override
Emits weapon flare after firing.
void SetCurrentWeapon(WeaponType weaponType, SetCurrentWeaponReason reason) override
Sets current weapon.
void SyncWithServer(Vector2f pos, Vector2f speed, PlayerFlags flags)
Synchronizes the player with server.
void ForceResyncWithServer(Vector2f pos, Vector2f speed)
Forcefully resynchronizes the player with server (e.g., after respawning or warping).

Public variables

PlayerFlags Flags
State flags.
std::uint64_t PressedKeys
Pressed keys.
std::uint64_t PressedKeysLast
Previously pressed keys.
std::uint32_t UpdatedFrame
Last frame when pressed keys were updated.

Protected functions

auto OnActivatedAsync(const ActorActivationDetails& details) -> Task<bool> override
Called when the object is created and activated.
void OnUpdate(float timeMult) override
Called every frame to update the object state.
void OnPushSolidObject(float timeMult, float pushSpeedX) virtual
Called when a solid object is pushed.
void OnHitSpring(Vector2f pos, Vector2f force, bool keepSpeedX, bool keepSpeedY, bool& removeSpecialMove) override
Called when a spring is hit.

Enum documentation

enum class Jazz2::Actors::Multiplayer::RemotePlayerOnServer::PlayerFlags

State flags of the remote player.

Enumerators
None

None

SpecialMoveMask

Mask of the current special move

IsFacingLeft

Player is facing left

IsVisible

Player is visible

IsActivelyPushing

Player is actively pushing against something

JustWarped

Player has just warped

EnableContinuousJump

Continuous jump is enabled

InMenu

Player has a menu open

InConsole

Player has the console open

Function documentation

Jazz2::Actors::Multiplayer::RemotePlayerOnServer::RemotePlayerOnServer(std::shared_ptr<PeerDescriptor> peerDesc)

Creates a new instance.

Parameters
peerDesc Descriptor of the peer this player belongs to