Jazz2::Actors::Multiplayer::RemoteActor class

Remote object in online session.

A generic actor whose transform, animation and miscellaneous state are synchronized from a remote authority (the server). It has no gameplay logic of its own; the received position is buffered and interpolated on the receiving side to smooth out network delay.

Base classes

class Jazz2::Actors::ActorBase
Base class of an object.

Derived classes

class RemoteElectroShot
Remote representation of the electro shot in online session.
class RemoteThunderbolt
Remote representation of the thunderbolt in online session.

Public static functions

static auto Create(StringView metadataPath) -> std::shared_ptr<RemoteActor>
Creates the remote representation for an actor with the specified metadata.

Constructors, destructors, conversion operators

RemoteActor()
Creates a new instance.
~RemoteActor()

Public functions

void AssignMetadata(std::uint8_t flags, ActorState state, StringView path, AnimState anim, float rotation, float scaleX, float scaleY, ActorRendererType rendererType, DrawableNode::BlendingPreset blendingPreset) virtual
Initializes the actor from metadata received from the server.
void SetPlayerColor(std::uint32_t furColor)
Sets the per-player recolor (0 = none); reloads the sprites indexed and (re)applies the palette.
void ChangeMetadata(StringView path)
Changes the metadata (e.g., on character change), keeping the current recolor applied.
void SyncPositionWithServer(Vector2f pos)
Synchronizes the position with the server.
void SyncAnimationWithServer(AnimState anim, float rotation, float scaleX, float scaleY, Actors::ActorRendererType rendererType)
Synchronizes the animation and transform with the server.
void SyncMiscWithServer(std::uint8_t flags)
Synchronizes miscellaneous state flags with the server.
void SyncLightsWithServer(ArrayView<const LightEmitter> lights)
Synchronizes the emitted lights with the server.
void SetShield(ShieldType shieldType, float timeLeft)
Sets the active shield shown around this remote player (synced from the server).
void SetModifierDecor(std::shared_ptr<ActorBase> decor)
Attaches a decoration that follows this remote player, or detaches it with nullptr.
void SetSugarRush(float timeLeft)
Starts (or ends with zero) the sugar rush of this remote player, whose star trail is replayed locally.

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.
auto OnDraw(RenderQueue& renderQueue) -> bool override
Called when the object needs to be drawn.
void OnEmitLights(SmallVectorImpl<LightEmitter>& lights) override
Called when emitting lights.
void OnAttach(ActorBase* parent) override
Called when the object is attached to an another object.
void OnDetach(ActorBase* parent) override
Called when the object is detached from the previously attached object.
void RefreshColorPalette()
void ApplyBlendingPreset()

Function documentation

static std::shared_ptr<RemoteActor> Jazz2::Actors::Multiplayer::RemoteActor::Create(StringView metadataPath)

Creates the remote representation for an actor with the specified metadata.

Most actors are covered by the generic synchronization, but some render through something else than their own sprite (e.g., locally-spawned particles), which has to be replayed on the receiving side by a specialized subclass. This factory picks the right one from the metadata path the server sent.

void Jazz2::Actors::Multiplayer::RemoteActor::SyncLightsWithServer(ArrayView<const LightEmitter> lights)

Synchronizes the emitted lights with the server.

Parameters
lights Lights to emit, positioned relative to the actor

void Jazz2::Actors::Multiplayer::RemoteActor::SetModifierDecor(std::shared_ptr<ActorBase> decor)

Attaches a decoration that follows this remote player, or detaches it with nullptr.

Used for the lizard copter a player hangs on. It's a separate actor that the server destroys as soon as it is mounted (see Player::SetModifier()), so the reference kept here is what keeps it alive and drawn.