/***********************************************************
This class will deal with all the aspects about animation related things.
To spawn a new animation state - reset it's state using state reset functions

Active - currently active animation state 
Default - when the active animation state expires it goes back to default state 

Normal - normal frame progression from 0 to maxFrameCount 
Reverse - reverse frame progression from maxFrameCount to 0 

doLoop - keep the animation in Loop 
isActive - only render if the state is active else it is ignored 
			default state is always isActive = true and doLoop = true
************************************************************/
#pragma once
#include "Animation.h"
#include "Position.h"

class AnimationState
{
	bool isActive = false;
	bool doReverse = false;
	bool doLoop = false;

	int activeFrameNo = 0;
	std::chrono::system_clock::time_point lastUpdate;
	Animation* ptrToAnimation = nullptr;

	void updateReverse();
	void updateNormal();
	bool needUpdate();
	void updateState();
public:

	void setActiveNormal(Animation* animPtr);
	void setActiveReverse(Animation* animPtr);
	void setDefaultNormal(Animation* animPtr);
	void setDefaultReverse(Animation* animPtr);
	void clearState();
	
	const bool& active();

	void drawFrame(Position& objPos, Position& camPos, float& xScale, float& yScale, ALLEGRO_COLOR& tint);
	void drawFrame(Position& objPos, Position& camPos, float& xScale, float& yScale);
	void drawFrame(Position& objPos, Position& camPos);

	void drawFrame(Position& objPos, float& xScale, float& yScale, ALLEGRO_COLOR& tint);
	void drawFrame(Position& objPos, float& xScale, float& yScale);
	void drawFrame(Position& objPos);
	
	AnimationState();
	~AnimationState();
};


