R-Type
Distributed multiplayer game engine in C++
Loading...
Searching...
No Matches
ecs::Animation Class Reference

Component managing current animation playback state. More...

#include <Animation.hpp>

Inheritance diagram for ecs::Animation:
Inheritance graph
Collaboration diagram for ecs::Animation:
Collaboration graph

Public Member Functions

 Animation (const std::string &initialClip="idle", bool loop=true, bool isPlaying=true)
 Constructor with animation parameters.
 
 ~Animation () override=default
 
std::string getCurrentClipName () const
 Get the current animation clip name.
 
float getTimer () const
 Get the playback timer.
 
int getCurrentFrameIndex () const
 Get the current frame index.
 
bool isPlaying () const
 Check if animation is playing.
 
bool isLooping () const
 Check if animation is looping.
 
void setCurrentClipName (const std::string &clipName)
 Set the current animation clip name.
 
void setTimer (float timer)
 Set the playback timer.
 
void setCurrentFrameIndex (int frameIndex)
 Set the current frame index.
 
void setPlaying (bool playing)
 Set the playing state.
 
void setLoop (bool loop)
 Set the looping state.
 
ComponentType getType () const override
 Get the component type ID.
 
- Public Member Functions inherited from ecs::IComponent
virtual ~IComponent ()=default
 Virtual destructor.
 

Private Attributes

std::string _currentClipName
 Current animation clip name.
 
float _timer
 Playback timer in seconds.
 
int _currentFrameIndex
 Current frame index.
 
bool _isPlaying
 Animation playing state.
 
bool _loop
 Animation looping flag.
 

Detailed Description

Component managing current animation playback state.

Stores the current animation state including which animation clip is playing, the current frame index, playback timer, and control flags for playback behavior.

Definition at line 21 of file Animation.hpp.

Constructor & Destructor Documentation

◆ Animation()

ecs::Animation::Animation ( const std::string &  initialClip = "idle",
bool  loop = true,
bool  isPlaying = true 
)
inline

Constructor with animation parameters.

Parameters
initialClipInitial animation clip name
loopWhether the animation should loop
isPlayingWhether animation starts playing immediately

Definition at line 29 of file Animation.hpp.

◆ ~Animation()

ecs::Animation::~Animation ( )
overridedefault

Member Function Documentation

◆ getCurrentClipName()

std::string ecs::Animation::getCurrentClipName ( ) const
inline

Get the current animation clip name.

Returns
std::string The current clip identifier.

Definition at line 42 of file Animation.hpp.

References _currentClipName.

Referenced by server::GameLogic::_applyPlayerInput(), and ecs::AnimationSystem::update().

◆ getCurrentFrameIndex()

int ecs::Animation::getCurrentFrameIndex ( ) const
inline

Get the current frame index.

Returns
int The index of the current frame.

Definition at line 54 of file Animation.hpp.

References _currentFrameIndex.

Referenced by ecs::AnimationSystem::update().

◆ getTimer()

float ecs::Animation::getTimer ( ) const
inline

Get the playback timer.

Returns
float The current timer value in seconds.

Definition at line 48 of file Animation.hpp.

References _timer.

Referenced by ecs::AnimationSystem::update().

◆ getType()

ComponentType ecs::Animation::getType ( ) const
inlineoverridevirtual

Get the component type ID.

Returns
ComponentType Unique ID for Animation component.

Implements ecs::IComponent.

Definition at line 102 of file Animation.hpp.

◆ isLooping()

bool ecs::Animation::isLooping ( ) const
inline

Check if animation is looping.

Returns
bool True if animation loops.

Definition at line 66 of file Animation.hpp.

References _loop.

◆ isPlaying()

bool ecs::Animation::isPlaying ( ) const
inline

Check if animation is playing.

Returns
bool True if animation is playing.

Definition at line 60 of file Animation.hpp.

References _isPlaying.

Referenced by ecs::AnimationSystem::update().

◆ setCurrentClipName()

void ecs::Animation::setCurrentClipName ( const std::string &  clipName)
inline

Set the current animation clip name.

Parameters
clipNameNew animation clip identifier

Definition at line 72 of file Animation.hpp.

References _currentClipName.

Referenced by server::GameLogic::_applyPlayerInput(), and ecs::AnimationSystem::update().

◆ setCurrentFrameIndex()

void ecs::Animation::setCurrentFrameIndex ( int  frameIndex)
inline

Set the current frame index.

Parameters
frameIndexNew frame index

Definition at line 84 of file Animation.hpp.

References _currentFrameIndex.

Referenced by server::GameLogic::_applyPlayerInput(), and ecs::AnimationSystem::update().

◆ setLoop()

void ecs::Animation::setLoop ( bool  loop)
inline

Set the looping state.

Parameters
loopTrue to enable looping

Definition at line 96 of file Animation.hpp.

References _loop.

◆ setPlaying()

void ecs::Animation::setPlaying ( bool  playing)
inline

Set the playing state.

Parameters
playingTrue to play, false to pause

Definition at line 90 of file Animation.hpp.

References _isPlaying.

Referenced by ecs::AnimationSystem::update().

◆ setTimer()

void ecs::Animation::setTimer ( float  timer)
inline

Set the playback timer.

Parameters
timerNew timer value in seconds

Definition at line 78 of file Animation.hpp.

References _timer.

Referenced by server::GameLogic::_applyPlayerInput(), and ecs::AnimationSystem::update().

Member Data Documentation

◆ _currentClipName

std::string ecs::Animation::_currentClipName
private

Current animation clip name.

Definition at line 105 of file Animation.hpp.

Referenced by getCurrentClipName(), and setCurrentClipName().

◆ _currentFrameIndex

int ecs::Animation::_currentFrameIndex
private

Current frame index.

Definition at line 107 of file Animation.hpp.

Referenced by getCurrentFrameIndex(), and setCurrentFrameIndex().

◆ _isPlaying

bool ecs::Animation::_isPlaying
private

Animation playing state.

Definition at line 108 of file Animation.hpp.

Referenced by isPlaying(), and setPlaying().

◆ _loop

bool ecs::Animation::_loop
private

Animation looping flag.

Definition at line 109 of file Animation.hpp.

Referenced by isLooping(), and setLoop().

◆ _timer

float ecs::Animation::_timer
private

Playback timer in seconds.

Definition at line 106 of file Animation.hpp.

Referenced by getTimer(), and setTimer().


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