#pragma once
#include "components.hpp"
#include "textures.hpp"
#include "easings.hpp"
#include "dinkyecs.hpp"
#include <SFML/Graphics/Rect.hpp>
#include <SFML/Graphics/Sprite.hpp>

namespace animation {
  struct AnimationManager {
    std::unordered_map<std::string, components::Animation> animations;
  };

  bool apply(components::Animation& anim, sf::Sprite& target);
  void rotate(sf::Sprite& target, float degrees);
  void center(sf::Sprite& target, sf::Vector2f pos);

  void init();
  components::Animation load(const std::string& name);
  bool has(const std::string& name);
  void configure(DinkyECS::World& world, DinkyECS::Entity entity);
  void step_animation(DinkyECS::World& world, DinkyECS::Entity entity, sf::Vector2f& scale_out, sf::Vector2f& pos_out, sf::IntRect& rect_out);
  void animate_entity(DinkyECS::World &world, DinkyECS::Entity entity);
}
