Page MenuHomeFeedback Tracker

Retrieving UIInfo instances via prefab source data returns null
Closed, ResolvedPublic

Description

When trying to access the UIInfo of an InventoryItemComponent via the ItemAttributeCollection it is null. You are able to get the collection instance, but inside no data appears to be present. Other collection info like GetCommonType return their default values. I would assume this is a bug because the information is otherwise known.

What I tried:

static UIInfo GetUIInfo(ResourceName prefab)
{
    UIInfo resultInfo;
    
    Resource resource = Resource.Load(prefab);
    if (resource && resource.IsValid())
    {
        IEntitySource entitySource = resource.GetResource().ToEntitySource();
        if (entitySource)
        {
            for(int nComponent, componentCount = entitySource.GetComponentCount(); nComponent < componentCount; nComponent++)
            {
                IEntityComponentSource componentSource = entitySource.GetComponent(nComponent);
                if(componentSource.GetClassName().ToType().IsInherited(InventoryItemComponent))
                {
                    ItemAttributeCollection itemAttributes;
                    componentSource.Get("Attributes", itemAttributes);
                    Print(itemAttributes);
                    if (itemAttributes)
                    {
                        BaseItemAttributeData data = itemAttributes.FindAttribute(UIInfo);
                        Print(data);
                        
                        ECommonItemType type = itemAttributes.GetCommonType();
                        Print(type);
                        
                        resultInfo = itemAttributes.GetUIInfo();
                        Print(resultInfo);
                        if (resultInfo) break;
                    }
                }
            }
        }
    }

    return resultInfo;
}

SCRIPT : ItemAttributeCollection itemAttributes = SCR_ItemAttributeCollection<0x0000025C39B43AB0>
SCRIPT : BaseItemAttributeData data = NULL
SCRIPT : int type = 0
SCRIPT : UIInfo resultInfo = NULL

When I manually navigate to the source information of the UIInfo however I am able to read the data just fine:

IEntitySource entitySource = SCR_BaseContainerTools.FindEntitySource(Resource.Load(prefab));
if (entitySource)
{
    for(int nComponent, componentCount = entitySource.GetComponentCount(); nComponent < componentCount; nComponent++)
    {
        IEntityComponentSource componentSource = entitySource.GetComponent(nComponent);
        if(componentSource.GetClassName().ToType().IsInherited(InventoryItemComponent))
        {
            BaseContainer attributesContainer = componentSource.GetObject("Attributes");
            if (attributesContainer)
            {
                BaseContainer itemDisplayNameContainer = attributesContainer.GetObject("ItemDisplayName");
                if (itemDisplayNameContainer)
                {
                    string name, description;
                    ResourceName icon;
                    itemDisplayNameContainer.Get("Name", name);
                    itemDisplayNameContainer.Get("Description", description);
                    itemDisplayNameContainer.Get("Icon", icon);

                    // DATA IS VALID HERE YAAAY
                    
                    break;
                }
            }
        }
    }
}

Using BaseContainerTools.CreateInstanceFromContainer sadly also does not work this this. An instance is returned but it has no values.

IEntitySource entitySource = SCR_BaseContainerTools.FindEntitySource(Resource.Load(prefab));
if (entitySource)
{
    for(int nComponent, componentCount = entitySource.GetComponentCount(); nComponent < componentCount; nComponent++)
    {
        IEntityComponentSource componentSource = entitySource.GetComponent(nComponent);
        if(componentSource.GetClassName().ToType().IsInherited(InventoryItemComponent))
        {
            BaseContainer attributesContainer = componentSource.GetObject("Attributes");
            if (attributesContainer)
            {
                BaseContainer itemDisplayNameContainer = attributesContainer.GetObject("ItemDisplayName");
                if (itemDisplayNameContainer)
                {
                    resultInfo = UIInfo.Cast(BaseContainerTools.CreateInstanceFromContainer(itemDisplayNameContainer));
                    Print(resultInfo);
                    Print("GetName: " + resultInfo.GetName());
                    Print("GetDescription: " + resultInfo.GetDescription());
                    Print("GetIconPath: " + resultInfo.GetIconPath());
                    break;
                }
            }
        }
    }
}

SCRIPT : UIInfo resultInfo = UIInfo<0x000001782971E868>
SCRIPT : GetName:
SCRIPT : GetDescription:
SCRIPT : GetIconPath:

Details

Severity
Major
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Category
General

Event Timeline

Arkensor created this task.Sep 3 2022, 10:03 AM
Geez changed the task status from New to Assigned.Sep 20 2022, 12:53 PM
Arkensor updated the task description. (Show Details)Nov 9 2022, 3:56 PM
Arkensor changed Severity from Minor to Major.
Geez closed this task as Resolved.Nov 9 2022, 4:23 PM
Geez claimed this task.
Geez added a subscriber: Geez.

Hello Arkensor.
This has been resolved internally and the fix will appear in one of the future updates.
Regards,
Geez