Jazz2::Actors::Collectibles::CollectibleBase class

Base class of a collectible object.

Base for pickups that grant the player a bonus when collected on contact. It provides the behavior shared by all collectibles: the floating/bobbing animation, optional light emission when illuminated, and dispatching the collection logic to the deriving type.

Base classes

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

Derived classes

class AmmoCollectible
Ammo (collectible).
class CarrotCollectible
Carrot (collectible).
class CarrotFlyCollectible
Fly carrot (collectible).
class CarrotInvincibleCollectible
Invincible carrot (collectible).
class CoinCollectible
Coin (collectible).
class FastFireCollectible
Fast fire (collectible).
class FoodCollectible
Food (collectible).
class GemCollectible
Gem (collectible).
class GemRing
Gem ring.
class OneUpCollectible
1up (collectible)
class Stopwatch
Stopwatch.

Public types

class IlluminateLights
Swarm of lights orbiting an illuminated collectible.

Public static variables

static float ThrownPickupDelay constexpr
How long a collectible thrown out of a container can't be picked up, 17 ticks of the original.

Constructors, destructors, conversion operators

CollectibleBase()
Creates a new instance.

Public functions

auto OnHandleCollision(ActorBase* other) -> bool override
Called when the object collides with another object.
void SetPickupDelay(float frames)
Makes the collectible untouchable for the specified number of frames, as one thrown out of a container is.

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 OnSerializeState(Stream& dest) override
Serializes the live state of the object to a level state snapshot.
void OnDeserializeState(Stream& src) override
Restores the live state of the object from a level state snapshot.
void OnEmitLights(SmallVectorImpl<LightEmitter>& lights) override
Called when emitting lights.
void OnEmitRemotedLights(SmallVectorImpl<LightEmitter>& lights) override
Called when emitting lights that have to be replicated to remote peers.
auto IsIlluminatedStateRemoted() const -> bool override
Whether an observer reproduces this object's ActorState::Illuminated decoration itself.
void OnCollect(Player* player) virtual
Called when the collectible is collected.
void SetFacingDirection(bool inverse = false)
Sets facing direction.

Function documentation

void Jazz2::Actors::Collectibles::CollectibleBase::OnSerializeState(Stream& dest) override protected

Serializes the live state of the object to a level state snapshot.

State set from the event parameters needn't be stored, the object is spawned again with them. Derived classes call the base first and read the data back in the same order.

void Jazz2::Actors::Collectibles::CollectibleBase::OnDeserializeState(Stream& src) override protected

Restores the live state of the object from a level state snapshot.

Called after OnActivatedAsync(), before the object is added to the level. Running transitions aren't restored, so the restored state must not wait for a transition callback.

void Jazz2::Actors::Collectibles::CollectibleBase::OnEmitRemotedLights(SmallVectorImpl<LightEmitter>& lights) override protected

Called when emitting lights that have to be replicated to remote peers.

Defaults to OnEmitLights(). Override it to leave out lights that clients produce on their own.

bool Jazz2::Actors::Collectibles::CollectibleBase::IsIlluminatedStateRemoted() const override protected

Whether an observer reproduces this object's ActorState::Illuminated decoration itself.

Only for objects that turn the flag into lights. They leave those lights out of OnEmitRemotedLights() and every observer spawns its own.