#pragma once
#include <functional>
#include <string>

class Timer{
	friend struct std::hash<Timer>;
public:
	enum class TimerType{
		REPEAT,
		MANUAL,
	};

	using enum TimerType;
private:
	std::string timerName;
	float originalVal;
	float timer;
	TimerType autoRepeat;
	std::function<void()>callback;
public:
	Timer(const std::string timerName,const float timer,const std::function<void()>callback,const TimerType autoRepeat=MANUAL);
	const bool Update(const float fElapsedTime); //Returns false when the timer is completed.
	void Reset(); //Resets the timer to the original given time it had.
	void Reset(const float newTime); //Resets the timer to the specified time.
	void Cancel(); //Stops the timer such that it is no longer running. (Doesn't invoke the callback)
	const bool IsRunning()const;
	const bool IsDone()const;
	const float RemainingTime()const;
	bool operator==(const Timer&timer){return timerName==timer.timerName;};
};

template <>
struct std::hash<Timer>
{
  std::size_t operator()(const Timer&timer) const
  {
	  return std::hash<std::string>()(timer.timerName);
  }
};