ActorBase class
#include <Jazz2/Actors/ActorBase.h>
Base class of an object.
Common base of every object that lives in the game world. It provides the shared lifecycle and behavior of an actor: activation from the event map, per-frame update, movement and collisions (with tiles, other actors and solid objects), rendering and light emission, and health and perishing. Concrete actors derive from it and override the relevant virtual callbacks.
Derived classes
- class CollectibleBase
- Base class of a collectible object.
- class GemGiant
- Giant gem.
- class EnemyBase
- Base class of an enemy.
- class AirboardGenerator
- Airboard generator.
- class AmbientBubbles
- Ambient bubbles.
- class AmbientSound
- Ambient sound.
- class Bird
- Bird.
- class Bomb
- Bomb.
- class BonusWarp
- Bonus warp.
- class Checkpoint
- Checkpoint.
- class Copter
- Copter.
- class EndOfLevel
- End of level sign.
- class Eva
- Eva.
- class IceBlock
- Ice block.
- class Moth
- Moth.
- class Spring
- Spring.
- class SteamNote
- Steam note.
- class SwingingVine
- Swinging vine.
- class Explosion
- Explosion effects.
- class FlickerLight
- Flickering light.
- class PulsatingRadialLight
- Pulsating radial light.
- class StaticRadialLight
- Static radial light.
- class RemoteActor
- Remote object in online session.
- class Player
- Represents a controllable player.
- class PlayerCorpse
- Represents a dead corpse of a player.
- class Bridge
- Bridge.
- class Pole
- Pole.
- class SolidObjectBase
- Base class of a (pushable) solid object.
- class ShotBase
- Base class of a shot from a player's weapon.
- class TNT
- TNT.
- class Jazz2::Scripting::ScriptActorWrapper
- Wraps a scripted actor, forwarding engine callbacks to the AngelScript object.
Constructors, destructors, conversion operators
- ActorBase()
- Creates a new instance.
- ~ActorBase() virtual
Public functions
- auto IsFacingLeft() const -> bool
- Returns
trueif the object is currently facing left. - auto OnActivated(const ActorActivationDetails& details) -> Task<bool>
- Called after the object is created.
- auto OnHandleCollision(ActorBase* other) -> bool virtual
- Called when the object collides with another object.
- auto CanCauseDamage(ActorBase* collider) -> bool virtual
- Called to check whether
collidercan cause damage to the object. - auto IsInvulnerable() -> bool
- Returns
trueif the object is invulnerable. -
auto GetHealth() -> std::
int32_t - Returns current health.
-
void SetHealth(std::
int32_t value) - Sets current health.
-
auto GetMaxHealth() -> std::
int32_t - Returns maximum health.
-
void DecreaseHealth(std::
int32_t amount = 1, ActorBase* collider = nullptr) - Decreases health by specified amount.
-
auto MoveInstantly(Vector2f pos,
MoveType type,
Tiles::
TileCollisionParams& params) -> bool - Moves the object.
- auto MoveInstantly(Vector2f pos, MoveType type) -> bool
- void AddExternalForce(float x, float y)
- Adds external force.
- auto IsCollidingWith(ActorBase* other) -> bool
- Returns
trueif this object is colliding with a given object. - auto IsCollidingWith(const AABBf& aabb) -> bool
- Returns
trueif this object is colliding with a given AABB. - void UpdateAABB()
- Updates AABB for current position, rotation and animation frame.
- auto GetPos() -> Vector2f
- Returns current position.
- auto GetSpeed() -> Vector2f
- Returns current speed.
- auto GetState() const -> ActorState constexpr noexcept
- Returns actor state.
- auto GetState(ActorState flag) const -> bool constexpr noexcept
Public variables
Protected types
- class ActorRenderer
- Actor renderer.
Protected static functions
- static void PreloadMetadataAsync(StringView path)
- Preloads specified metadata and its linked assets to cache.
Protected functions
- void SetParent(SceneNode* parent)
- Sets internal parent node.
- void SetFacingLeft(bool value)
- Sets whether the object is facing left.
- auto OnActivatedAsync(const ActorActivationDetails& details) -> Task<bool> virtual
- Called when the object is created and activated.
- auto OnTileDeactivated() -> bool virtual
- Called when corresponding tile should be deactivated.
- void OnAttach(ActorBase* parent) virtual
- Called when the object is attached to an another object.
- void OnDetach(ActorBase* parent) virtual
- Called when the object is detached from the previously attached object.
- void OnHealthChanged(ActorBase* collider) virtual
- Called when health of the object changed.
- auto OnPerish(ActorBase* collider) -> bool virtual
- Called when the object has no health left and should perish.
- void OnUpdate(float timeMult) virtual
- Called every frame to update the object state.
- void OnUpdateHitbox() virtual
- Called when the hitbox needs to be updated.
- auto OnDraw(RenderQueue& renderQueue) -> bool virtual
- Called when the object needs to be drawn.
- void OnEmitLights(SmallVectorImpl<LightEmitter>& lights) virtual
- Called when emitting lights.
- void OnHitFloor(float timeMult) virtual
- Called when the object hits a floor.
- void OnHitCeiling(float timeMult) virtual
- Called when the object hits a ceiling.
- void OnHitWall(float timeMult) virtual
- Called when the object hits a wall.
-
void OnTriggeredEvent(EventType eventType,
std::
uint8_t* eventParams) virtual - Called when an event is triggered.
-
void TryStandardMovement(float timeMult,
Tiles::
TileCollisionParams& params) - Performs standard movement behavior.
-
void UpdateHitbox(std::
int32_t w, std:: int32_t h) - Updates hitbox to a given size.
- void UpdateFrozenState(float timeMult)
- Updates frozen state of the object.
- void HandleFrozenStateChange(ActorBase* shot)
- Handles change of frozen state after collision with other object.
- void CreateParticleDebrisOnPerish(ActorBase* collider)
- Creates a particle debris from a sprite when the object is going to perish.
- void CreateParticleDebrisOnPerish(ParticleDebrisEffect effect, Vector2f speed)
-
void CreateSpriteDebris(AnimState state,
std::
int32_t count) - Creates a sprite debris.
- auto GetIceShrapnelScale() const -> float virtual
- Returns scale of ice shrapnels.
-
auto PlaySfx(StringView identifier,
float gain = 1.0f,
float pitch = 1.0f) -> std::
shared_ptr<AudioBufferPlayer> - Plays a sound effect for the object.
- auto SetAnimation(AnimState state, bool skipAnimation = false) -> bool
- Sets an animation of the object.
- auto SetTransition(AnimState state, bool cancellable, Function<void()>&& callback = {}) -> bool
- Sets a transition animation of the object.
- void CancelTransition()
- Cancels a cancellable transition.
- void ForceCancelTransition()
- Cancels any transition.
- void OnAnimationStarted() virtual
- Called when an animation started.
- void OnAnimationFinished() virtual
- Called when an animation finished.
- void OnPacketReceived(MemoryStream& packet) virtual
- Called when the object receives a network packet.
-
void SendPacket(ArrayView<const std::
uint8_t> data) - Sends a packet to the other side of a non-local session.
- void RequestMetadata(StringView path, bool forceIndexed = false)
- Loads specified metadata and its linked assets.
- void RequestMetadataAsync(StringView path, bool forceIndexed = false)
- Loads specified metadata and its linked assets asynchronously if supported.
- void SetState(ActorState flags) constexpr noexcept
- Sets actor state.
- void SetState(ActorState flag, bool value) constexpr noexcept
Constants
-
static std::
uint8_t AlphaThreshold protected constexpr - Alpha transparency threshold.
- static float CollisionCheckStep protected constexpr
- Step for collision checking.
-
static std::
int32_t PerPixelCollisionStep protected constexpr - Step for per-pixel collisions.
-
static std::
int32_t AnimationCandidatesCount protected constexpr - Maximum number of animation candidates.
Function documentation
bool Jazz2:: Actors:: ActorBase:: MoveInstantly(Vector2f pos,
MoveType type)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
bool Jazz2:: Actors:: ActorBase:: GetState(ActorState flag) const constexpr noexcept
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Jazz2:: Actors:: ActorBase:: CreateParticleDebrisOnPerish(ParticleDebrisEffect effect,
Vector2f speed) protected
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Jazz2:: Actors:: ActorBase:: RequestMetadata(StringView path,
bool forceIndexed = false) protected
Loads specified metadata and its linked assets.
| Parameters | |
|---|---|
| path | Relative path to the metadata asset |
| forceIndexed | Load linked graphics as indexed (for shader-based recoloring, e.g. the player) |
void Jazz2:: Actors:: ActorBase:: SetState(ActorState flag,
bool value) protected constexpr noexcept
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.