#pragma once

#include "adapters/il2cpp/Il2CppObjectInstance.h"

namespace ta::adapters::eft::items::object_access
{
    using GetObjectFn = Il2CppObject*(*)(Il2CppObject*);

    inline Il2CppObject* contained_item(Il2CppObject* slot)
    {
        if (!slot)
            return nullptr;

        ta::adapters::il2cpp::Il2CppObjectInstance instance(slot);
        const auto getter = instance.get_method<GetObjectFn>("get_ContainedItem", 0);
        return getter ? getter(slot) : nullptr;
    }
}
