#pragma once
#include <array>
#include <map>
#include <vector>

#include "structs.h"

class GroundTileType;
static const int WORLD_WIDTH = 34;
static const int WORLD_HEIGHT = 34;

static const int TILE_WIDTH = 50;
static const int TILE_HEIGHT = 50;

class WorldTile;

enum TileDirection
{
	TopLeft,
	TopMiddle,
	TopRight,

	MiddleLeft,
	//me
	MiddleRight,

	BottomLeft,
	BottomMiddle,
	BottomRight
};

struct surroundingTiles
{

	std::map<TileDirection, WorldTile *> m_tiles;

	void SetTile(TileDirection direction, WorldTile* tile) {
		m_tiles[direction] = tile;
	}

	WorldTile* GetTile(TileDirection direction) {
		return m_tiles[direction];
	}

	// bool IsAllType(const GroundTileType& type) {
	// 	for (const auto& tile : m_tiles) {
	// 		if (tile.second == nullptr) {
	// 			return false;
	// 		}
	// 		if (tile.second->GetTileType() != &type) {
	// 			return false;
	// 		}
	// 	}
	// 	return true;
	// }
};

class WorldGridManager
{
public:
	WorldGridManager();
	~WorldGridManager();
	surroundingTiles GetSurroundingTiles(const WorldTile* world_tile);
	Vector2f GetIndexFromPosition(Vector2f position);

	WorldGridManager(const WorldGridManager& other) = default;

	WorldTile * GetTileAtIndex(const int x, const int y) const;
	WorldTile * GetTileAtWorldPos(const Vector2f& pos) const;

	void SetTileAtIndex(const int x, const int y, WorldTile* tile);

private:
	std::array<std::array<WorldTile *, WORLD_WIDTH>, WORLD_HEIGHT> m_worldTiles;


};
