EnemyBase class
#include <Jazz2/Actors/Enemies/EnemyBase.h>
Base class of an enemy.
Base for hostile creatures that hurt the player on contact. It provides the behavior shared by all enemies: collisions with the player and player shots, taking damage, freezing, awarding score, dropping random collectibles on death, and the white-mask hit-blinking effect.
Base classes
- class Jazz2::Actors::ActorBase
- Base class of an object.
Derived classes
- class Jazz2::Actors::Bosses::BossBase
- Base class of an enemy boss.
- class Jazz2::Actors::Bosses::Robot
- Robot (boss).
- class Bat
- Bat.
- class Bee
- Bee.
- class Caterpillar
- Caterpillar.
- class Crab
- Crab.
- class Demon
- Demon.
- class Doggy
- Doggy.
- class Dragon
- Dragon.
- class Dragonfly
- Dragonfly.
- class FatChick
- Fat chick.
- class Fencer
- Fencer.
- class Fish
- Fish.
- class Helmut
- Helmut.
- class LabRat
- Lab rat.
- class Lizard
- Lizard.
- class LizardFloat
- Floating lizard.
- class MadderHatter
- Madder hatter.
- class Monkey
- Monkey.
- class Rapier
- Rapier.
- class Raven
- Raven.
- class Skeleton
- Skeleton.
- class Sparks
- Sparks.
- class Sucker
- Sucker.
- class SuckerFloat
- Floating sucker.
- class Turtle
- Turtle.
- class TurtleShell
- Turtle shell.
- class TurtleTough
- Tough turtle.
- class TurtleTube
- Tube turtle.
- class Witch
- Witch.
- class Jazz2::Actors::Environment::RollingRock
- Rolling rock.
- class Jazz2::Actors::Solid::SpikeBall
- Spike ball.
Constructors, destructors, conversion operators
- EnemyBase()
- Creates a new instance.
Public functions
- auto OnHandleCollision(ActorBase* other) -> bool override
- Called when the object collides with another object.
- auto CanCauseDamage(ActorBase* collider) -> bool override
- Called to check whether
collidercan cause damage to the object. - auto CanHurtPlayer() const -> bool
- Whether the enemy can hurt player.
- auto IsFrozen() const -> bool
- Whether the enemy is currently frozen.
Public variables
- bool CanCollideWithShots
- Whether the enemy should collide with player shots.
Protected functions
- void OnUpdate(float timeMult) override
- Called every frame to update the object state.
- void OnHealthChanged(ActorBase* collider) override
- Called when health of the object changed.
- auto OnPerish(ActorBase* collider) -> bool override
- Called when the object has no health left and should perish.
- 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 AddScoreToCollider(ActorBase* collider)
- Awards the enemy's score value to the collider (or its owner).
-
void SetHealthByDifficulty(std::
int32_t health) virtual - Sets the enemy's health scaled by the current game difficulty.
- void PlaceOnGround()
- Snaps the enemy onto the ground below it.
- auto CanMoveToPosition(float x, float y) -> bool
- Returns whether the enemy can move to the specified relative offset.
- void TryGenerateRandomDrop()
- Randomly spawns a drop (collectible) at the enemy's position.
- void StartBlinking()
- Starts the white-mask blinking effect.
- void HandleBlinking(float timeMult)
- Advances the blinking effect.
Function documentation
void Jazz2:: Actors:: Enemies:: EnemyBase:: OnSerializeState(Stream& dest) override protected
Serializes the live state of the object to a level state snapshot.
Called only if IsSerializable() returns true. Anything that is initialized from the event parameters in OnActivatedAsync() doesn't need to be stored, because the object is spawned again with the same parameters before OnDeserializeState() is called. Derived classes must call the base implementation first and read the data back in the same order.
void Jazz2:: Actors:: Enemies:: EnemyBase:: OnDeserializeState(Stream& src) override protected
Restores the live state of the object from a level state snapshot.
Called right after the object was spawned again (i.e., after OnActivatedAsync()) and before it's added to the level. Running transitions are not restored, because their callbacks cannot be serialized, so derived classes have to put the object into a state that doesn't wait for such a callback.