#pragma once
#include <Exam_HelperStructs.h>
#include <chrono>
#include <vector>
#include "WorldExplorationGrid.h"

class Thinker final {
public:

	struct HouseMemory {
		bool newHouse{ true };
		HouseInfo info;
		std::chrono::steady_clock::time_point lastSaw;
	};

	struct ItemMemory
	{
		ItemInfo ItemInfo;
		int invIndex;
	};

	Thinker() = default;

	~Thinker() = default;
	Thinker(const Thinker&) = default;
	Thinker& operator=(const Thinker&) = default;
	Thinker(Thinker&&) = default;
	Thinker& operator=(Thinker&&) = default;

	/*bool NewHouseToExplore();
	bool HouseToReExplore();
	void SetTargetHouseExpireDate(const HouseInfo& targetHouse);
	HouseInfo CheckHouseValidTarget(Elite::Vector2 playerPos, float maxRadius) const;
	bool CheckHousesForMemory(const std::vector<HouseInfo>& FOVHouses);*/

	std::vector<ItemMemory>::iterator FindLeastValueItem(const eItemType& itemType);
	bool IsInvNotFull() const;
	bool IsItemInInv(const eItemType& itemType);
	bool EmptyValue();
	int FindEmptyValue(const ItemInfo& item);
	int AddItemToMemory(const ItemInfo& item);
	int CheckItem(const ItemInfo& item);

	bool CheckIfTargetIsInside(const HouseInfo& targetHouse, Elite::Vector2 playerPos);
	bool CheckIfTargetIsExplored(Elite::Vector2 target, float offset) const;
	bool NewHouseToExplore();
	bool HouseToReExplore();
	void SetTargetHouseExpireDate(const HouseInfo& targetHouse);
	HouseInfo CheckHouseValidTarget(Elite::Vector2 playerPos, float maxRadius) const;
	bool CheckHousesForMemory(const std::vector<HouseInfo>& FOVHouses);


	WorldExplorationGrid m_ExplorationGrid;
private:
	std::vector<HouseMemory> m_HousesMemory{};
	const float m_MaxWaitTimer{ 360.f };

	std::vector<ItemMemory> m_ItemMemory{};
	const size_t m_MaxStorageSlots{ 5 };

	std::vector<HouseMemory>::iterator FindHouseInMemory(const HouseInfo& targetHouse);

	
	float m_GridCellSize = 50.f; // Adjust based on your needs
};
