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, GravityFlipped = 0x400, 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
trueif continuous jump 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.
- void EnableFlyCheat(bool active) override
- Enables or disables fly cheat behavior.
- auto Freeze(float timeLeft) -> bool override
- Freezes the player for specified time.
- void SetInvulnerability(float timeLeft, InvulnerableType type) override
- Sets invulnerability, replacing whatever is running.
-
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 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).
- void UpdateRendererPosition() override
- Re-applies the current position to the renderer.
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 SetGravityFlipped(bool value) override
- Sets whether gravity pulls the object up.
- void OnPushSolidObject(float timeMult, float pushSpeedX) override
- 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 |
| GravityFlipped |
Gravity pulls the player up |
| 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 |
void Jazz2:: Actors:: Multiplayer:: RemotePlayerOnServer:: SetInvulnerability(float timeLeft,
InvulnerableType type) override
Sets invulnerability, replacing whatever is running.
Can also weaken it, so server corrections go through it. timeLeft <= 0 clears it. Gameplay should use GrantInvulnerability() instead.
void Jazz2:: Actors:: Multiplayer:: RemotePlayerOnServer:: UpdateRendererPosition() override
Re-applies the current position to the renderer.
Called after the object updates itself, call it again if something else moves the object afterwards. An object drawn elsewhere than it is simulated overrides it.
void Jazz2:: Actors:: Multiplayer:: RemotePlayerOnServer:: SetGravityFlipped(bool value) override protected
Sets whether gravity pulls the object up.
The object is drawn upside down and the standard movement treats the ceiling as its floor. Its vertical speed and forces point along its gravity, so they're negated by the change and the motion is kept.