#pragma once
#include "Utils/MemoryUtils.h"
#include "Client.h"

#include "SDK/CameraComponent.h"

namespace Hooks {
	class CameraComponents {
	private:
		typedef auto(__thiscall* CameraComponent_update_)(CameraComponent*, void*, void*) -> void;
		inline static CameraComponent_update_ cameracomponent_update;

		static auto callback_update(CameraComponent* _this, void* a2, void* a3) -> void;
	public:
		inline static int state = -1;
		static void Init() {
			std::thread([&] {
				void* pattern;
				if (Utils::File::getVersion() == _("1.21.80"))
					pattern = Utils::Memory::FindPattern(_("4C 8B DC 49 89 7B"));
				else if (Utils::File::getVersion() == _("1.21.73"))
					pattern = Utils::Memory::FindPattern(_("4C 8B DC 49 89 7B"));
				else if (Utils::File::getVersion() == _("1.21.72"))
					pattern = Utils::Memory::FindPattern(_("4C 8B DC 49 89 7B"));
				else if (Utils::File::getVersion() == _("1.21.71"))
					pattern = Utils::Memory::FindPattern(_("4C 8B DC 49 89 7B"));
				else if (Utils::File::getVersion() == _("1.21.70"))
					pattern = Utils::Memory::FindPattern(_("4C 8B DC 49 89 7B"));
				else
					pattern = Utils::Memory::FindPattern(_("4C 8B DC 49 89 5B 10 49 89 7B 20 55 41"));

				state = Utils::Memory::CreateHook(pattern, (void*)&callback_update, &cameracomponent_update);

				if (state == 0)
					MessageBoxA(0, _("The program was terminated due to an error.\nError code: 1-18"), _("Valkyrie"), MB_ICONERROR);
				else
					std::cout << _("Test 1-18... OK\n");
				}).detach();
		}
	};
}
