#pragma once
#include "Behaviour.hpp"
#include <vector>
#include "sre/Sprite.hpp"

class SpriteRenderer;

class CharacterAnimator : public Behaviour {
public:
	CharacterAnimator(GameObject*);
	enum class State{Idle, WalkLeft, WalkRight, Jump, Air, Fall};
	void SetState(State);
	class Mutator {
	private:
		inline static void AddSprite(CharacterAnimator& target, sre::Sprite sprite) {
			target.sprites.push_back(sprite);
		}
		friend class LevelBuilder;
	};
protected:
	void InitialiseSelf() override;
	void Initialise() override{}
	void Update(float) override;
private:
	std::shared_ptr<SpriteRenderer> renderer;
	State currentState;
	bool stateChanged;
	float clipTime = 0.25f;
	float clipTimer = 0;
	int currentWalkFrame = 0;

	std::vector<sre::Sprite> sprites;

	friend class Mutator;
};
