#pragma once

#include <string>

#if WITH_EDITOR

#define UE_INCLUDE_METRICS 1

#define METRICS_EXPR(expr) expr

namespace Metrics
{
	bool StartSession(const std::wstring& filePath);
	bool EndSession();

	void SetMapData(float minX, float maxX, float minY, float maxY);
	void SetMapImage(uint8_t* ptr, uint32_t width, uint32_t height);

	struct PlayerHandleSet;
	struct PlayerHandle
	{
	public:
		PlayerHandle();

		void OnPlayerSpawn(float playerX, float playerY);
		void OnPlayerUpdate(float playerX, float playerY);
		void OnPlayerDie(uint8_t source);
		void OnPlayerCast(uint32_t ability);
		void OnPlayerHealth(int32_t health);
		void OnPlayerMana(int32_t mana);
		void OnPlayerMaxHealth(int32_t maxHealth);
		void OnPlayerMaxMana(int32_t maxMana);
		void OnPlayerDealDamage(uint32_t ability, int32_t damage);
		void OnPlayerLevel(uint8_t level);

		bool IsValid() const;
		uint8_t Id() const;
		uint8_t Team() const;

	private:
		PlayerHandle(const PlayerHandle& other) = delete;
		PlayerHandle& operator=(const PlayerHandle& other) = delete;
		
		friend struct PlayerHandleSet;
		
		bool m_isValid;
		uint8_t m_id;
		uint8_t m_team;
		uint32_t m_updateTime;

		bool m_alive;
		int32_t m_health;
		int32_t m_mana;
		int32_t m_maxHealth;
		int32_t m_maxMana;
		uint8_t m_level;
		float m_playerX;
		float m_playerY;
	};

	PlayerHandle& RegisterPlayer(const std::wstring& name, uint8_t team);
	void RegisterAbility(uint32_t ability, const std::wstring& name);
}

#else

#define UE_INCLUDE_METRICS 0

#define METRICS_EXPR(expr)

#endif