vectozavr-shooter/engine/animation/Timeline.h

56 lines
1.3 KiB
C
Raw Normal View History

//
// Created by Иван Ильин on 03.10.2021.
//
#ifndef SHOOTER_TIMELINE_H
#define SHOOTER_TIMELINE_H
#include <memory>
#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)) {}
2021-10-31 11:39:08 +03:00
2021-10-17 10:21:10 +03:00
[[nodiscard]] std::string str() const { return _name; }
2021-10-31 11:39:08 +03:00
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 10:21:10 +03:00
};
2021-10-17 19:38:16 +03:00
class Timeline {
private:
std::map<AnimationListTag, std::list<std::shared_ptr<Animation>>> _animations;
2021-10-17 19:38:16 +03:00
2021-10-31 11:39:08 +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;
2021-10-31 11:39:08 +03:00
2021-10-17 19:38:16 +03:00
public:
2021-10-31 11:39:08 +03:00
Timeline(const Timeline &) = delete;
Timeline &operator=(Timeline &) = delete;
2021-10-17 19:38:16 +03:00
static void update();
2021-10-31 11:39:08 +03:00
static void animate(const AnimationListTag &listName, std::shared_ptr<Animation> anim);
2021-10-17 19:38:16 +03:00
static void deleteAllAnimations();
2021-10-31 11:39:08 +03:00
static void deleteAnimationList(const AnimationListTag &listName);
[[nodiscard]] static bool isInAnimList(const AnimationListTag &listName);
2021-10-17 19:38:16 +03:00
static void init();
2021-10-31 11:39:08 +03:00
2021-10-17 19:38:16 +03:00
static void free();
};
#endif //SHOOTER_TIMELINE_H