R-Type
Distributed multiplayer game engine in C++
Loading...
Searching...
No Matches
Animation.hpp
Go to the documentation of this file.
1/*
2** EPITECH PROJECT, 2025
3** RTYPE
4** File description:
5** Animation
6*/
7
8#pragma once
9
10#include <string>
11#include "IComponent.hpp"
12
13namespace ecs {
21 class Animation : public IComponent {
22 public:
29 Animation(const std::string &initialClip = "idle", bool loop = true, bool isPlaying = true)
30 : _currentClipName(initialClip),
31 _timer(0.0f),
34 _loop(loop) {}
35
36 ~Animation() override = default;
37
42 std::string getCurrentClipName() const { return _currentClipName; }
43
48 float getTimer() const { return _timer; }
49
55
60 bool isPlaying() const { return _isPlaying; }
61
66 bool isLooping() const { return _loop; }
67
72 void setCurrentClipName(const std::string &clipName) { _currentClipName = clipName; }
73
78 void setTimer(float timer) { _timer = timer; }
79
84 void setCurrentFrameIndex(int frameIndex) { _currentFrameIndex = frameIndex; }
85
90 void setPlaying(bool playing) { _isPlaying = playing; }
91
96 void setLoop(bool loop) { _loop = loop; }
97
102 ComponentType getType() const override { return getComponentType<Animation>(); }
103
104 private:
105 std::string _currentClipName;
106 float _timer;
109 bool _loop;
110 };
111} // namespace ecs
Component managing current animation playback state.
Definition Animation.hpp:21
float _timer
Playback timer in seconds.
void setCurrentFrameIndex(int frameIndex)
Set the current frame index.
Definition Animation.hpp:84
std::string _currentClipName
Current animation clip name.
std::string getCurrentClipName() const
Get the current animation clip name.
Definition Animation.hpp:42
bool _loop
Animation looping flag.
int _currentFrameIndex
Current frame index.
~Animation() override=default
ComponentType getType() const override
Get the component type ID.
bool isPlaying() const
Check if animation is playing.
Definition Animation.hpp:60
int getCurrentFrameIndex() const
Get the current frame index.
Definition Animation.hpp:54
bool isLooping() const
Check if animation is looping.
Definition Animation.hpp:66
bool _isPlaying
Animation playing state.
void setCurrentClipName(const std::string &clipName)
Set the current animation clip name.
Definition Animation.hpp:72
void setLoop(bool loop)
Set the looping state.
Definition Animation.hpp:96
float getTimer() const
Get the playback timer.
Definition Animation.hpp:48
void setPlaying(bool playing)
Set the playing state.
Definition Animation.hpp:90
Animation(const std::string &initialClip="idle", bool loop=true, bool isPlaying=true)
Constructor with animation parameters.
Definition Animation.hpp:29
void setTimer(float timer)
Set the playback timer.
Definition Animation.hpp:78
Base interface for all ECS components.
Maximum number of distinct component types supported by the Registry.
Definition GameLogic.hpp:26
std::size_t ComponentType
Type alias for component identification.