#pragma once

#include <string>

#include "adapters/il2cpp/Il2CppResolver.h"
#include "adapters/il2cpp/Il2CppObjectAccess.h"
#include "adapters/il2cpp/Il2CppString.h"

namespace ta::adapters::eft::esp
{
class EspLootNameResolver
{
public:
    static Il2CppString* localized_short_name(Il2CppObject* item)
    {
        if (!item) return nullptr;

        static const Il2CppImage* assembly_csharp = ta::adapters::il2cpp::resolve_image("Assembly-CSharp.dll");
        static const Il2CppClass* localization_extensions_class =
            ta::adapters::il2cpp::resolve_class(assembly_csharp, "EFT", "LocalizationExtensions");
        static auto method = ta::adapters::il2cpp::get_method<Il2CppString*(*)(Il2CppObject*)>(
            localization_extensions_class,
            "LocalizedShortName",
            1);

        return method ? method(item) : nullptr;
    }

    static std::string item_short_name(Il2CppObject* item)
    {
        if (Il2CppString* name_str = localized_short_name(item))
            return ta::adapters::il2cpp::conv_string(name_str);
        return {};
    }
};
}
