Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
ECS_Systems_Animation.h
Go to the documentation of this file.
1/**
2 * @file ECS_Systems_Animation.h
3 * @brief Animation system for 2D sprite animation
4 * @author Nicolas Chereau
5 * @date 2025
6 *
7 * ECS System that updates sprite animations frame-by-frame based on elapsed time.
8 * Integrates with AnimationManager and updates VisualSprite_data srcRect.
9 */
10
11#pragma once
12
13#include "ECS_Systems.h"
14#include "ECS_Components.h"
15
16/**
17 * @brief Animation system for sprite-based 2D animations
18 *
19 * Requires: VisualAnimation_data + VisualSprite_data
20 *
21 * Responsibilities:
22 * - Update animation frames based on elapsed time (GameEngine::fDt)
23 * - Resolve animation pointers from AnimationManager
24 * - Update VisualSprite_data::srcRect to current frame
25 * - Handle looping and non-looping animations
26 * - Support animation transitions via API calls
27 */
29{
30public:
32 virtual void Process() override;
33
34 /**
35 * @brief Play a specific animation on an entity
36 * @param entity Entity ID
37 * @param animName Animation name to play
38 * @param restart If true, restart animation even if already playing
39 */
40 void PlayAnimation(EntityID entity, const std::string& animName, bool restart = false);
41
42 /**
43 * @brief Pause animation playback
44 * @param entity Entity ID
45 */
46 void PauseAnimation(EntityID entity);
47
48 /**
49 * @brief Resume paused animation
50 * @param entity Entity ID
51 */
52 void ResumeAnimation(EntityID entity);
53
54 /**
55 * @brief Stop animation playback
56 * @param entity Entity ID
57 */
58 void StopAnimation(EntityID entity);
59
60 /**
61 * @brief Set playback speed multiplier
62 * @param entity Entity ID
63 * @param speed Speed multiplier (1.0 = normal, 2.0 = double speed, etc.)
64 */
65 void SetPlaybackSpeed(EntityID entity, float speed);
66
67 int GetCurrentFrame(EntityID entity) const;
68 bool IsAnimationComplete(EntityID entity) const;
69
70private:
71 /**
72 * @brief Update a single entity's animation
73 * @param entity Entity ID
74 * @param animData Animation component
75 * @param spriteData Sprite component
76 */
78
79 /**
80 * @brief Resolve animation sequence pointer from AnimationManager
81 * @param animData Animation component
82 * @return true if successfully resolved
83 */
85
88};
Core ECS component definitions.
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
std::uint64_t EntityID
Definition ECS_Entity.h:21
Animation system for sprite-based 2D animations.
void StopAnimation(EntityID entity)
Stop animation playback.
void PauseAnimation(EntityID entity)
Pause animation playback.
void UpdateSpriteRect(VisualSprite_data &spriteData, const VisualAnimation_data &animData)
void ResumeAnimation(EntityID entity)
Resume paused animation.
void PlayAnimation(EntityID entity, const std::string &animName, bool restart=false)
Play a specific animation on an entity.
int GetCurrentFrame(EntityID entity) const
void SetPlaybackSpeed(EntityID entity, float speed)
Set playback speed multiplier.
virtual void Process() override
bool ResolveAnimationSequence(VisualAnimation_data &animData)
Resolve animation sequence pointer from AnimationManager.
bool IsAnimationComplete(EntityID entity) const
void UpdateEntity(EntityID entity, VisualAnimation_data &animData, VisualSprite_data &spriteData)
Update a single entity's animation.
void AdvanceFrame(VisualAnimation_data &animData, float dt)
ECS component for animated sprites.