CoriEngine
Loading...
Searching...
No Matches
QuadAnimator.hpp
Go to the documentation of this file.
1#pragma once
2#include "AnimationPack.hpp"
4
5namespace Cori {
6 namespace World {
7 namespace Systems {
8 class Animation;
9 }
10
11 namespace Components {
12 namespace Entity {
13
20 public:
21 using StopCallbackFn = std::function<void()>;
22
25
30 void SetStopCallback(StopCallbackFn callback);
31
41 void Play(const Graphics::IsAnimationWithParams auto&... sequence) {
42 m_AnimationSequence.clear();
43 m_AnimationSequence.reserve(sizeof...(sequence));
44 (m_AnimationSequence.emplace_back(sequence), ...);
45 m_CurrentLoopedSequenceIndex = 0;
46 m_CurrentFrame = 0;
47 m_CurrentFrameTick = 0;
48 //m_TicksElapsedSinceStart = 0;
49 m_ActiveSequence = true;
50
51 bool loopedFlags[] = { sequence.second.LoopedInSequence ... };
52 m_LoopStartIndex = 0xFFFF;
53 for (uint32_t i = 0; i < sizeof...(sequence); ++i) {
54 if (loopedFlags[i]) {
55 m_LoopStartIndex = i;
56 break;
57 }
58 }
59
61 }
62
68 void Stop(const bool abruptStop);
69
76 void SetSizeScale(const glm::vec2 scale);
77
82 [[nodiscard]] glm::vec2 GetSizeScale() const;
83
84 //[[nodiscard]] uint64_t GetTicksElapsed() const;
85
86 protected:
87 friend Systems::Animation;
88
89 void OnTickUpdate();
90
92
93 private:
94 StopCallbackFn m_StopCallBack;
95 StopCallbackFn m_EngineCallBack;
96 bool m_ActiveSequence;
97 glm::vec2 m_SizeScale{ 1.0f, 1.0f };
98 uint16_t m_LoopStartIndex{ 0xFFFF };
99 uint16_t m_CurrentLoopedSequenceIndex{ 0 };
100
101 uint32_t m_CurrentFrame{ 0 };
102 uint32_t m_CurrentFrameTick{ 0 };
103 //uint64_t m_TicksElapsedSinceStart{ 0 };
104
105 std::vector<Graphics::AnimationWithParams> m_AnimationSequence;
106 World::Entity m_Entity{};
107 };
108 }
109 }
110 }
111}
void SetStopCallback(StopCallbackFn callback)
Sets a callback that will be fired when any animation sequence stops.
glm::vec2 GetSizeScale() const
Retrieves the current scale modifier.
void Stop(const bool abruptStop)
Stops the current animation.
void SetEngineStopCallback(StopCallbackFn callback)
void Play(const Graphics::IsAnimationWithParams auto &... sequence)
Plays a sequence of animations. @detials Animation sequence can be either looped or no,...
void SetSizeScale(const glm::vec2 scale)
Changes the size scale.
Entities are the essential part of WorldSystem.
Definition Entity.hpp:25
System that is responsible for Animations, every Scene has it by default.
Components that are used with the WorldSystem (ECS).
Anything connected to WorldSystem (ECS) is in this namespace.
Global engine namespace.