shooter/engine/animation/Timeline.h

47 lines
1.3 KiB
C
Raw Normal View History

//
// Created by Иван Ильин on 03.10.2021.
//
#ifndef SHOOTER_TIMELINE_H
#define SHOOTER_TIMELINE_H
#include "Animation.h"
2021-10-17 11:41:58 +03:00
class AnimationListTag final {
2021-10-17 10:21:10 +03:00
private:
const std::string _name;
public:
explicit AnimationListTag(std::string name = "") : _name(std::move(name)) {}
[[nodiscard]] std::string str() const { return _name; }
bool operator==(const AnimationListTag& tag) const { return _name == tag._name; }
bool operator!=(const AnimationListTag& tag) const { return _name != tag._name; }
bool operator<(const AnimationListTag& tag) const { return _name < tag._name; }
};
2021-10-17 19:38:16 +03:00
class Timeline {
private:
2021-10-25 22:32:55 +03:00
// TODO: replace Animation* with shared_ptr<Animation> & check for possible memory leaks
2021-10-17 19:38:16 +03:00
std::map<AnimationListTag, std::list<Animation*>> _animations;
static Timeline* _instance;
Timeline() = default;
public:
Timeline(const Timeline&) = delete;
Timeline& operator=(Timeline&) = delete;
2021-10-17 19:38:16 +03:00
static void update();
static void animate(const AnimationListTag& listName, Animation* anim);
2021-10-17 19:38:16 +03:00
static void deleteAllAnimations();
static void deleteAnimationList(const AnimationListTag& listName);
[[nodiscard]] static bool isInAnimList(const AnimationListTag& listName);
static void init();
static void free();
};
#endif //SHOOTER_TIMELINE_H