Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | List of all members
AnimationSystem Class Reference

Animation system for sprite-based 2D animations. More...

#include <ECS_Systems_Animation.h>

+ Inheritance diagram for AnimationSystem:
+ Collaboration diagram for AnimationSystem:

Public Member Functions

 AnimationSystem ()
 
virtual void Process () override
 
void PlayAnimation (EntityID entity, const std::string &animName, bool restart=false)
 Play a specific animation on an entity.
 
void PauseAnimation (EntityID entity)
 Pause animation playback.
 
void ResumeAnimation (EntityID entity)
 Resume paused animation.
 
void StopAnimation (EntityID entity)
 Stop animation playback.
 
void SetPlaybackSpeed (EntityID entity, float speed)
 Set playback speed multiplier.
 
int GetCurrentFrame (EntityID entity) const
 
bool IsAnimationComplete (EntityID entity) const
 
- Public Member Functions inherited from ECS_System
 ECS_System ()
 
virtual void Render ()
 
virtual void RenderDebug ()
 
void AddEntity (EntityID entity)
 
void RemoveEntity (EntityID entity)
 

Private Member Functions

void UpdateEntity (EntityID entity, VisualAnimation_data &animData, VisualSprite_data &spriteData)
 Update a single entity's animation.
 
bool ResolveAnimationSequence (VisualAnimation_data &animData)
 Resolve animation sequence pointer from AnimationManager.
 
void AdvanceFrame (VisualAnimation_data &animData, float dt)
 
void UpdateSpriteRect (VisualSprite_data &spriteData, const VisualAnimation_data &animData)
 

Additional Inherited Members

- Public Attributes inherited from ECS_System
ComponentSignature requiredSignature
 
std::set< EntityIDm_entities
 

Detailed Description

Animation system for sprite-based 2D animations.

Requires: VisualAnimation_data + VisualSprite_data

Responsibilities:

Definition at line 28 of file ECS_Systems_Animation.h.

Constructor & Destructor Documentation

◆ AnimationSystem()

AnimationSystem::AnimationSystem ( )

Definition at line 19 of file ECS_Systems_Animation.cpp.

References GetComponentTypeID_Static(), and ECS_System::requiredSignature.

+ Here is the call graph for this function:

Member Function Documentation

◆ AdvanceFrame()

void AnimationSystem::AdvanceFrame ( VisualAnimation_data animData,
float  dt 
)
private

◆ GetCurrentFrame()

int AnimationSystem::GetCurrentFrame ( EntityID  entity) const

◆ IsAnimationComplete()

bool AnimationSystem::IsAnimationComplete ( EntityID  entity) const

◆ PauseAnimation()

void AnimationSystem::PauseAnimation ( EntityID  entity)

Pause animation playback.

Parameters
entityEntity ID

Definition at line 298 of file ECS_Systems_Animation.cpp.

References World::Get(), World::GetComponent(), GetComponentTypeID_Static(), World::HasComponent(), and VisualAnimation_data::isPaused.

+ Here is the call graph for this function:

◆ PlayAnimation()

void AnimationSystem::PlayAnimation ( EntityID  entity,
const std::string &  animName,
bool  restart = false 
)

Play a specific animation on an entity.

Parameters
entityEntity ID
animNameAnimation name to play
restartIf true, restart animation even if already playing

Definition at line 269 of file ECS_Systems_Animation.cpp.

References VisualAnimation_data::currentAnimName, World::Get(), World::GetComponent(), GetComponentTypeID_Static(), World::HasComponent(), and ResolveAnimationSequence().

Referenced by UpdateEntity().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Process()

void AnimationSystem::Process ( )
overridevirtual

Reimplemented from ECS_System.

Definition at line 33 of file ECS_Systems_Animation.cpp.

References World::Get(), World::GetComponent(), GetComponentTypeID_Static(), World::HasComponent(), ECS_System::m_entities, and UpdateEntity().

+ Here is the call graph for this function:

◆ ResolveAnimationSequence()

bool AnimationSystem::ResolveAnimationSequence ( VisualAnimation_data animData)
private

Resolve animation sequence pointer from AnimationManager.

Parameters
animDataAnimation component
Returns
true if successfully resolved

Definition at line 242 of file ECS_Systems_Animation.cpp.

References OlympeAnimation::AnimationManager::Get(), OlympeAnimation::AnimationManager::GetAnimationSequence(), GetComponentTypeID_Static(), and SYSTEM_LOG.

Referenced by PlayAnimation(), and UpdateEntity().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ResumeAnimation()

void AnimationSystem::ResumeAnimation ( EntityID  entity)

Resume paused animation.

Parameters
entityEntity ID

Definition at line 309 of file ECS_Systems_Animation.cpp.

References World::Get(), World::GetComponent(), GetComponentTypeID_Static(), World::HasComponent(), and VisualAnimation_data::isPaused.

+ Here is the call graph for this function:

◆ SetPlaybackSpeed()

void AnimationSystem::SetPlaybackSpeed ( EntityID  entity,
float  speed 
)

Set playback speed multiplier.

Parameters
entityEntity ID
speedSpeed multiplier (1.0 = normal, 2.0 = double speed, etc.)

Definition at line 334 of file ECS_Systems_Animation.cpp.

References World::Get(), World::GetComponent(), GetComponentTypeID_Static(), World::HasComponent(), and VisualAnimation_data::playbackSpeed.

+ Here is the call graph for this function:

◆ StopAnimation()

void AnimationSystem::StopAnimation ( EntityID  entity)

Stop animation playback.

Parameters
entityEntity ID

Definition at line 320 of file ECS_Systems_Animation.cpp.

References World::Get(), World::GetComponent(), GetComponentTypeID_Static(), World::HasComponent(), and VisualAnimation_data::isPlaying.

+ Here is the call graph for this function:

◆ UpdateEntity()

void AnimationSystem::UpdateEntity ( EntityID  entity,
VisualAnimation_data animData,
VisualSprite_data spriteData 
)
private

Update a single entity's animation.

Parameters
entityEntity ID
animDataAnimation component
spriteDataSprite component

Definition at line 54 of file ECS_Systems_Animation.cpp.

References Olympe::AnimationFrame::duration, GameEngine::fDt, OlympeAnimation::AnimationManager::Get(), DataManager::Get(), OlympeAnimation::AnimationManager::GetBank(), GetComponentTypeID_Static(), DataManager::GetSprite(), Olympe::AnimationFrame::hotSpot, PlayAnimation(), ResolveAnimationSequence(), Olympe::AnimationSequence::speed, Olympe::AnimationFrame::srcRect, and SYSTEM_LOG.

Referenced by Process().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UpdateSpriteRect()

void AnimationSystem::UpdateSpriteRect ( VisualSprite_data spriteData,
const VisualAnimation_data animData 
)
private

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