#pragma once

/**
 * \file TickCounter.h
 * \brief File containing the blitz::utils::TickCounter class
 */

#include <cstdint>

namespace blitz {
namespace utils {

/**
 * \class TickCounter
 * \brief Class used to count ticks
 */
class TickCounter {
  private:
	float m_TPS;
	float m_MSPT;
	std::uint64_t m_LastTPSTime;
	std::uint8_t m_TickCount;
	int m_TargetTPS;

  public:
	/**
	 * \brief Constructor
	 * \param tps The target ticks per second
	 */
	TickCounter(int tps) : m_TargetTPS(tps) {}

	/**
	 * \brief Reset the tick counter
	 */
	void Reset();
	/**
	 * \brief Update the tick counter
	 * \return True if the tick counter has been updated
	 */
	bool Update();

	/**
	 * \brief Get the ticks per second
	 * \return The ticks per second
	 */
	float GetTPS() const {
		return m_TPS;
	}

	/**
	 * \brief Get the milliseconds per tick
	 * \return The milliseconds per tick
	 */
	float GetMSPT() const {
		return m_MSPT;
	}

	/**
	 * \brief Set the ticks per second
	 * \param mspt The ticks per second
	 */
	void SetMSPT(float mspt) {
		m_MSPT = mspt;
	}
};

}  // namespace utils
}  // namespace blitz