class
#include <Jazz2/Actors/Player.h>
Player Represents a controllable player.
Base classes
- class ActorBase
- Base class of an object.
Derived classes
- class PlayerOnServer
- Player in online session.
- class RemotablePlayer
- Remotable player in online session.
Public types
-
enum class Modifier : std::
uint8_t { None, Airboard, Copter, LizardCopter } - Modifier.
-
enum class SpecialMoveType : std::
uint8_t { None, Buttstomp, Uppercut, Sidekick } - Special move type.
- enum class InvulnerableType { Transient, Blinking, Shielded }
- Type of invulnerability.
Constructors, destructors, conversion operators
Public functions
-
auto GetPlayerIndex() const -> std::
uint8_t - Returns player index.
- auto GetPlayerType() const -> PlayerType
- Returns player type.
- auto GetSpecialMove() const -> SpecialMoveType
- Returns current special move.
-
auto GetWeaponAmmo() const -> ArrayView<const std::
uint16_t> - Return weapon ammo.
-
auto GetWeaponUpgrades() const -> ArrayView<const std::
uint8_t> - Returns weapon upgrades.
- auto HasSugarRush() const -> bool
- Returns
true
if sugar rush is active. - auto CanJump() const -> bool
- Returns
true
if the player can jump. - auto CanBreakSolidObjects() const -> bool
- Returns
true
if the player can bread solid objects. - auto CanMoveVertically() const -> bool
- Returns
true
if the player can move vertically, i.e. not affected by gravity. -
auto OnLevelChanging(Actors::
ActorBase* initiator, ExitType exitType) -> bool virtual - Called when the level is about to change.
- void ReceiveLevelCarryOver(ExitType exitType, const PlayerCarryOver& carryOver)
- Called at the beginning of the next level to reveive carry over information.
- auto PrepareLevelCarryOver() -> PlayerCarryOver
- Returns current carry over information.
-
void InitializeFromStream(ILevelHandler* levelHandler,
Stream& src,
std::
uint16_t version) - Initializes player state from a stream.
- void SerializeResumableToStream(Stream& dest)
- Serializes player state to a stream.
- void Respawn(Vector2f pos)
- Respawns the player.
- void WarpToPosition(Vector2f pos, WarpFlags flags) virtual
- Warps to a given position.
- void WarpToCheckpoint()
- Warps to the last checkpoint.
- auto GetModifier() const -> Modifier
- Returns current modifier.
-
auto SetModifier(Modifier modifier,
const std::
shared_ptr<ActorBase>& decor = nullptr) -> bool - Sets current modifier.
-
auto TakeDamage(std::
int32_t amount, float pushForce = 0.0f) -> bool virtual - Takes damage.
- void SetInvulnerability(float time, InvulnerableType type)
- Sets invulnerability.
-
void AddScore(std::
uint32_t amount) - Adds score.
-
auto AddHealth(std::
int32_t amount) -> bool - Adds health.
-
auto AddLives(std::
int32_t count) -> bool - Adds lives.
-
void AddCoins(std::
int32_t count) - Adds coins.
-
void AddCoinsInternal(std::
int32_t count) - Adds coins without notification (internal use only)
-
void AddGems(std::
uint8_t gemType, std:: int32_t count) - Adds gems.
- void ConsumeFood(bool isDrinkable)
- Consumes food.
- void ActivateSugarRush(float duration)
- Activates sugar rush.
-
auto AddAmmo(WeaponType weaponType,
std::
int16_t count) -> bool virtual - Adds weapon ammo.
-
void AddWeaponUpgrade(WeaponType weaponType,
std::
uint8_t upgrade) virtual - Adds weapon upgrade.
-
auto AddFastFire(std::
int32_t count) -> bool - Adds fast fire.
- auto MorphTo(PlayerType type) -> bool
- Morphs to a given player type.
- void MorphRevert()
- Reverts morpth to the original player type.
- auto SetDizzyTime(float time) -> bool
- Sets dizzy time left.
- auto GetActiveShield() const -> ShieldType
- Returns active shield.
- auto SetShield(ShieldType shieldType, float time) -> bool
- Sets active shield.
- auto IncreaseShieldTime(float time) -> bool
- Increases active shield time.
- auto SpawnBird(uint8_t type, Vector2f pos) -> bool
- Spawns bird companion.
- auto DisableControllable(float timeout) -> bool
- Disables controls for specified time.
- void SetCheckpoint(Vector2f pos, float ambientLight)
- Sets checkpoint.
- auto GetCarryingObject() const -> ActorBase*
- Returns carrying object.
- void CancelCarryingObject(ActorBase* expectedActor = nullptr)
- Cancels carrying object.
-
void UpdateCarryingObject(ActorBase* actor,
SuspendType suspendType = SuspendType::
None) - Updates carrying object.
-
void SwitchToWeaponByIndex(std::
uint32_t weaponIndex) - Switches current weapon to a given index.
- void GetFirePointAndAngle(Vector3i& initialPos, Vector2f& gunspotPos, float& angle)
- Returns weapon fire point and angle.
Protected types
- enum class LevelExitingState { None, Waiting, WaitingForWarp, Transition, Ready }
- State of level exiting.
- enum class WeaponWheelState { Hidden, Opening, Visible, Closing }
- State of HUD weapon wheel.
Protected functions
- auto OnActivatedAsync(const ActorActivationDetails& details) -> Task<bool> override
- Called when the object is created and activated.
- auto OnTileDeactivated() -> bool override
- Called when corresponding tile should be deactivated.
- auto OnPerish(ActorBase* collider) -> bool override
- Called when the object has no health left and should perish.
- 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 OnDraw(RenderQueue& renderQueue) -> bool override
- Called when the object needs to be drawn.
- void OnEmitLights(SmallVectorImpl<LightEmitter>& lights) override
- Called when emitting lights.
-
auto OnHandleCollision(std::
shared_ptr<ActorBase> other) -> bool override - Called when the object collides with another object.
- void OnHitFloor(float timeMult) override
- Called when the object hits a floor.
- void OnHitCeiling(float timeMult) override
- Called when the object hits a ceiling.
- void OnHitWall(float timeMult) override
- Called when the object hits a wall.
- void OnHitSpring(Vector2f pos, Vector2f force, bool keepSpeedX, bool keepSpeedY, bool& removeSpecialMove) virtual
- Called when a spring is hit.
- void OnWaterSplash(Vector2f pos, bool inwards) virtual
- Called when water should splash.
-
auto PlayPlayerSfx(StringView identifier,
float gain = 1.0f,
float pitch = 1.0f) -> std::
shared_ptr<AudioBufferPlayer> - auto SetPlayerTransition(AnimState state, bool cancellable, bool removeControl, SpecialMoveType specialMove, Function<void()>&& callback = {}) -> bool
- Starts a player animation transition.
- auto CanFreefall() -> bool
- Returns
true
if the player should freefall. - void EndDamagingMove()
- Ends active damaging move.
- auto FireCurrentWeapon(WeaponType weaponType) -> bool virtual
- Fires currently equipped weapon.
- void EmitWeaponFlare() virtual
- Emits weapon flare after firing.
- void SetCurrentWeapon(WeaponType weaponType) virtual
- Sets current weapon.
Protected static variables
- static float MaxDashingSpeed constexpr
- static float MaxRunningSpeed constexpr
- static float MaxVineSpeed constexpr
- static float MaxDizzySpeed constexpr
- static float MaxShallowWaterSpeed constexpr
- static float Acceleration constexpr
- static float Deceleration constexpr
- static const char* WeaponNames constexpr