Bat class
#include <Jazz2/Actors/Enemies/Bat.h>
Bat.
Hangs from its roost, twitching now and then, until a player comes within 125 px. It then takes off and flutters towards the player, sideways by a random step every tick and up or down by a new random speed every wing beat. When the player is more than 256 px from its roost, it flies back and hangs there again. All of it as measured in JJ2+.
Base classes
- class EnemyBase
- Base class of an enemy.
Public types
-
enum class BatState : std::
uint8_t { Hanging, Waking, Flying } - State of the bat.
Public static functions
- static void Preload(const ActorActivationDetails& details)
- Preloads all assets required by this actor.
Constructors, destructors, conversion operators
- Bat()
- Creates a new instance.
Public functions
- auto GetBatState() const -> BatState
- Returns the current state.
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.
- 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.
Enum documentation
enum class Jazz2:: Actors:: Enemies:: Bat:: BatState : std:: uint8_t
State of the bat.
| Enumerators | |
|---|---|
| Hanging |
Hangs from its roost |
| Waking |
Takes off |
| Flying |
Flies towards the player or back to its roost |
Function documentation
void Jazz2:: Actors:: Enemies:: Bat:: 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:: Enemies:: Bat:: 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.