2021-10-02 21:17:03 +03:00
|
|
|
//
|
|
|
|
// 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-30 21:07:14 +03:00
|
|
|
std::map<AnimationListTag, std::list<std::shared_ptr<Animation>>> _animations;
|
2021-10-17 19:38:16 +03:00
|
|
|
|
|
|
|
static Timeline* _instance;
|
2021-10-29 23:44:37 +03:00
|
|
|
static bool _validInstance;
|
2021-10-17 19:38:16 +03:00
|
|
|
|
|
|
|
Timeline() = default;
|
|
|
|
public:
|
|
|
|
Timeline(const Timeline&) = delete;
|
|
|
|
Timeline& operator=(Timeline&) = delete;
|
2021-10-02 21:17:03 +03:00
|
|
|
|
2021-10-17 19:38:16 +03:00
|
|
|
static void update();
|
2021-10-30 21:07:14 +03:00
|
|
|
static void animate(const AnimationListTag& listName, std::shared_ptr<Animation> anim);
|
2021-10-02 21:17:03 +03:00
|
|
|
|
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();
|
|
|
|
};
|
2021-10-02 21:17:03 +03:00
|
|
|
|
|
|
|
#endif //SHOOTER_TIMELINE_H
|