Jazz2::Actors::Weapons::ElectroShot class

Electro (shot).

Projectile of the electro blaster, a high-strength energy ball that passes through solid tiles instead of stopping at walls and trails an expanding swirl of electric particles as it travels. The powered-up variant is slightly faster.

Base classes

class ShotBase
Base class of a shot from a player's weapon.

Public static variables

static AnimState PoweredUpAnimState constexpr
Animation state of the powered-up variant.

Public static functions

static void CreateParticles(ILevelHandler* levelHandler, Metadata* metadata, Vector2f pos, std::uint16_t layer, float currentStep, bool facingLeft, bool poweredUp)
Spawns one ring of swirl particles, shared with the remote representation of the shot.
static void EmitParticleLight(SmallVectorImpl<LightEmitter>& lights, Vector2f pos, float currentStep)
Emits the light surrounding the swirl, shared with the remote representation of the shot.

Constructors, destructors, conversion operators

ElectroShot()
Creates a new instance.

Public functions

void OnFire(const std::shared_ptr<ActorBase>& owner, Vector2f gunspotPos, Vector2f speed, float angle, bool isFacingLeft)
Called when the shot is fired.
auto GetWeaponType() -> WeaponType override
Returns weapon type.
auto OnHandleCollision(ActorBase* other) -> bool override
Called when the object collides with another object.

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 OnUpdateHitbox() override
Called when the hitbox needs to be updated.
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 OnPerish(ActorBase* collider) -> bool override
Called when the object has no health left and should perish.
void OnHitWall(float timeMult) override
Called when the object hits a wall.
void OnRicochet() override
Called on shot ricochet.

Function documentation

void Jazz2::Actors::Weapons::ElectroShot::OnEmitRemotedLights(SmallVectorImpl<LightEmitter>& lights) override protected

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

An object simulated on a multiplayer server is drawn on the clients by a stand-in that runs none of its logic, so the lights it emits have to be described to them explicitly. This defaults to OnEmitLights(), which is right for anything whose lighting belongs to the object itself.

Overriding it describes only the part that every observer must see. Lights that a client already produces on its own — decoration driven by a local preference, or an object whose stand-in replays the whole effect — are left out, so they aren't sent (and applied) twice.

Variable documentation

static AnimState Jazz2::Actors::Weapons::ElectroShot::PoweredUpAnimState constexpr

Animation state of the powered-up variant.

The shot is invisible (it renders only through locally-spawned particles), so its animation state is reused to carry the variant to remote clients over the existing animation synchronization.