#pragma once
#include "AttributeInstance.h"
#include "Utils/MemoryUtils.h"
#include "Utils/FileUtils.h"

class BaseAttributeMap {
public:
	AttributeInstance* getInstance(unsigned int id) {
		static void* sig;
		if (!sig) {
			if (Utils::File::getVersion() == _("1.21.80"))
				sig = Utils::Memory::FindPattern(_("E8 3F A3 79 FE"));
			else if (Utils::File::getVersion() == _("1.21.73"))
				sig = Utils::Memory::FindPattern(_("E8 3F A3 79 FE"));
			else if (Utils::File::getVersion() == _("1.21.72"))
				sig = Utils::Memory::FindPattern(_("E8 2F A2 79"));
			else if (Utils::File::getVersion() == _("1.21.71"))
				sig = Utils::Memory::FindPattern(_("E8 EF AC 79"));
			else if (Utils::File::getVersion() == _("1.21.70"))
				sig = Utils::Memory::FindPattern(_("E8 EF AC 79"));
			else
				sig = Utils::Memory::FindPattern(_("E8 80 F6 89 FE"));

			uintptr_t out = (uintptr_t)sig;
			out += *(int*)(out + 1) + (static_cast<unsigned long long>(1) + sizeof(int));
			sig = (void*)out;
		}

		return &((AttributeInstance&(*)(BaseAttributeMap*, unsigned int))sig)(this, id);
	}
};
