Zappy GUI
C++ graphic client: renderer, camera, network
Loading...
Searching...
No Matches
IncantationBehavior Class Reference

Ritual animation for players participating in an incantation. More...

#include <IncantationBehavior.hpp>

+ Inheritance diagram for IncantationBehavior:
+ Collaboration diagram for IncantationBehavior:

Public Member Functions

 IncantationBehavior (VisualState &visual, Player &player, int playerIndex, int totalPlayers, float tileCenterX, float tileCenterZ, float tileSize, float serverTickRate)
 
void update (float dt) override
 
bool isDone () const override
 Returns true when the behavior has completed and can be removed.
 
float getDuration () const override
 Total duration of this behavior in seconds.
 
float minDuration () const override
 Minimum duration below which this behavior is skipped entirely.
 
- Public Member Functions inherited from ADrawableBehavior
const std::vector< Particle > & getParticles () const
 
const std::vector< LineSegment > & getLines () const
 
- Public Member Functions inherited from IBehavior
virtual ~IBehavior ()=default
 

Private Types

enum class  Phase { SPREAD , HOLD , END }
 

Private Member Functions

void _spawnParticles ()
 
void _updateParticles (float dt)
 

Private Attributes

VisualState_visual
 
Player_player
 
bool _isParticleOwner
 
Phase _phase = Phase::SPREAD
 
float _elapsed = 0.0f
 
float _elapsedEnd = 0.0f
 
float _duration
 
Vector3 _startPos
 
Vector3 _slotPos
 
float _startAngle
 
float _targetFaceAngle
 
float _savedAngle = 0.0f
 
bool _angleSaved = false
 
Vector3 _tileCenter
 
bool _particlesSpawned = false
 

Static Private Attributes

static constexpr float SPREAD_DURATION = 0.5f
 
static constexpr float END_DURATION = 0.35f
 
static constexpr float CIRCLE_RADIUS = 0.32f
 
static constexpr int PARTICLE_COUNT = 12
 

Additional Inherited Members

- Protected Attributes inherited from ADrawableBehavior
std::vector< Particle_particles
 
std::vector< LineSegment_lines
 

Detailed Description

Ritual animation for players participating in an incantation.

Players spread to fixed circle slots around the tile center, face inward, and hold position while ethereal particles drift at the center. On end signal (success or failure), they rotate back and return to tile center.

Definition at line 15 of file IncantationBehavior.hpp.

Member Enumeration Documentation

◆ Phase

enum class IncantationBehavior::Phase
strongprivate
Enumerator
SPREAD 
HOLD 
END 

Definition at line 31 of file IncantationBehavior.hpp.

Constructor & Destructor Documentation

◆ IncantationBehavior()

IncantationBehavior::IncantationBehavior ( VisualState visual,
Player player,
int  playerIndex,
int  totalPlayers,
float  tileCenterX,
float  tileCenterZ,
float  tileSize,
float  serverTickRate 
)

Member Function Documentation

◆ _spawnParticles()

void IncantationBehavior::_spawnParticles ( )
private

Definition at line 53 of file IncantationBehavior.cpp.

References ADrawableBehavior::_particles, _particlesSpawned, _tileCenter, Particle::active, Particle::alpha, Particle::color, Particle::delay, PARTICLE_COUNT, Particle::pos, Particle::size, and Particle::vel.

Referenced by update().

+ Here is the caller graph for this function:

◆ _updateParticles()

void IncantationBehavior::_updateParticles ( float  dt)
private

Definition at line 82 of file IncantationBehavior.cpp.

References _elapsed, ADrawableBehavior::_particles, and _tileCenter.

Referenced by update().

+ Here is the caller graph for this function:

◆ getDuration()

float IncantationBehavior::getDuration ( ) const
inlineoverridevirtual

Total duration of this behavior in seconds.

Implements IBehavior.

Definition at line 22 of file IncantationBehavior.hpp.

References _duration.

◆ isDone()

bool IncantationBehavior::isDone ( ) const
overridevirtual

Returns true when the behavior has completed and can be removed.

Implements IBehavior.

Definition at line 158 of file IncantationBehavior.cpp.

References _elapsedEnd, ADrawableBehavior::_particles, _phase, END, and END_DURATION.

◆ minDuration()

float IncantationBehavior::minDuration ( ) const
inlineoverridevirtual

Minimum duration below which this behavior is skipped entirely.

Implements IBehavior.

Definition at line 23 of file IncantationBehavior.hpp.

◆ update()

void IncantationBehavior::update ( float  dt)
overridevirtual

Implements IBehavior.

Definition at line 111 of file IncantationBehavior.cpp.

References _angleSaved, _elapsed, _elapsedEnd, _isParticleOwner, ADrawableBehavior::_particles, _particlesSpawned, _phase, _player, _savedAngle, _slotPos, _spawnParticles(), _startAngle, _startPos, _targetFaceAngle, _tileCenter, _updateParticles(), _visual, VisualState::angle, END, END_DURATION, HOLD, lerpAngle(), lerpv(), VisualState::pos, smoothstep(), SPREAD, and SPREAD_DURATION.

+ Here is the call graph for this function:

Member Data Documentation

◆ _angleSaved

bool IncantationBehavior::_angleSaved = false
private

Definition at line 50 of file IncantationBehavior.hpp.

Referenced by update().

◆ _duration

float IncantationBehavior::_duration
private

Definition at line 43 of file IncantationBehavior.hpp.

Referenced by getDuration().

◆ _elapsed

float IncantationBehavior::_elapsed = 0.0f
private

Definition at line 41 of file IncantationBehavior.hpp.

Referenced by _updateParticles(), and update().

◆ _elapsedEnd

float IncantationBehavior::_elapsedEnd = 0.0f
private

Definition at line 42 of file IncantationBehavior.hpp.

Referenced by isDone(), and update().

◆ _isParticleOwner

bool IncantationBehavior::_isParticleOwner
private

Definition at line 38 of file IncantationBehavior.hpp.

Referenced by update().

◆ _particlesSpawned

bool IncantationBehavior::_particlesSpawned = false
private

Definition at line 53 of file IncantationBehavior.hpp.

Referenced by _spawnParticles(), and update().

◆ _phase

Phase IncantationBehavior::_phase = Phase::SPREAD
private

Definition at line 40 of file IncantationBehavior.hpp.

Referenced by isDone(), and update().

◆ _player

Player& IncantationBehavior::_player
private

Definition at line 37 of file IncantationBehavior.hpp.

Referenced by update().

◆ _savedAngle

float IncantationBehavior::_savedAngle = 0.0f
private

Definition at line 49 of file IncantationBehavior.hpp.

Referenced by update().

◆ _slotPos

Vector3 IncantationBehavior::_slotPos
private

Definition at line 46 of file IncantationBehavior.hpp.

Referenced by IncantationBehavior(), and update().

◆ _startAngle

float IncantationBehavior::_startAngle
private

Definition at line 47 of file IncantationBehavior.hpp.

Referenced by IncantationBehavior(), and update().

◆ _startPos

Vector3 IncantationBehavior::_startPos
private

Definition at line 45 of file IncantationBehavior.hpp.

Referenced by IncantationBehavior(), and update().

◆ _targetFaceAngle

float IncantationBehavior::_targetFaceAngle
private

Definition at line 48 of file IncantationBehavior.hpp.

Referenced by IncantationBehavior(), and update().

◆ _tileCenter

Vector3 IncantationBehavior::_tileCenter
private

◆ _visual

VisualState& IncantationBehavior::_visual
private

Definition at line 36 of file IncantationBehavior.hpp.

Referenced by update().

◆ CIRCLE_RADIUS

constexpr float IncantationBehavior::CIRCLE_RADIUS = 0.32f
staticconstexprprivate

Definition at line 28 of file IncantationBehavior.hpp.

Referenced by IncantationBehavior().

◆ END_DURATION

constexpr float IncantationBehavior::END_DURATION = 0.35f
staticconstexprprivate

Definition at line 27 of file IncantationBehavior.hpp.

Referenced by isDone(), and update().

◆ PARTICLE_COUNT

constexpr int IncantationBehavior::PARTICLE_COUNT = 12
staticconstexprprivate

Definition at line 29 of file IncantationBehavior.hpp.

Referenced by _spawnParticles().

◆ SPREAD_DURATION

constexpr float IncantationBehavior::SPREAD_DURATION = 0.5f
staticconstexprprivate

Definition at line 26 of file IncantationBehavior.hpp.

Referenced by update().


The documentation for this class was generated from the following files: